[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2010-07-22 Thread ankur

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] how i can change two lists into one directory

2010-07-22 Thread ANKUR AGGARWAL
hey i have just started making  a app using python and just gt a problem..

i have two list
a=["x","z"]
b=[1,2]

i want to make a directory like this
c={"x":1,"z":2}

is it possible i mean i tried it using loops and all but i cant append a
directory so i m unable to do this...
plz tell me if there's any way to get the directory like this Thanks in
advance :):)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] can i run the last saved input again

2010-07-23 Thread ANKUR AGGARWAL
hey this is a crazy question but i want to know it..
suppose i have this code

a=raw_input("enter the string :")
print a

then i type python prog.py

output:
enter the string:hello
hello


now i want to ask is there's any way that python remembers the input i gave
it to last time and it just give me the output when i again run python
prog.py?? i mean i dont need to give input again. I just need to give
input only first time and when i run the prog again it will pick up the
previous one output
is it possible???
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] hot to run python script at the startup

2010-07-24 Thread ANKUR AGGARWAL
hey fellas i have a script abc.py with me
i want to execute it as soon as i my linux gets start after entering
username and password thing (desktop thing)
how can i do that???
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] string editing

2010-07-31 Thread ANKUR AGGARWAL
hey although i knw string are mutable but i want to know if there is anyway
to add in the string.
like i m wrking on the tool and want to run the input from the user in the
terminal

like user makes input "this is ankur"
and i want it like "this\ is\ ankur"  ???
is it possible??
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] string conversion according to the terminal

2010-08-12 Thread ANKUR AGGARWAL
Hey- suppose we have a file name-"my file number"
if we want to execute it into the terminal it would be like - my\ file\
number

so wondering is there any one in the python that change the enter string
into the terminal string one-
like if user enter the file name with path- "my file number". i want to
automatically convert it into "my\ file\ number"
Plz help me out in this.
Thanks in advance
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] check the terminal keyword

2010-08-21 Thread ANKUR AGGARWAL
i m making a app in which i launch application using os.system("input from
user"). I want to check whether the input entered by the user matches with
the exact keyword in terminal or not.
like i want to launch vlc so user should provide me input as " vlc" in order
to launch the app just like he did from terminal. I want to make a check on
the input spell so that if he type "wlc" it shows an error to it. I have an
little idea abt sys.agrv but don't know how to use it... Plz help me guys.
Thanks in advance
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] input problem

2010-09-13 Thread ANKUR AGGARWAL
Suppose i am taking input or various variables like
a=raw_input("...") //hello
b=raw_input("")//hi
c=raw_input("...")//hello
d=raw_input("..")//hello
but i want to run a common function when input is hello

so instead of
if a=="hello":
 fun()
then again for b and then again for c then d and so on i have to apply the
code for the specific variable ,
i want to run the function whenever in the code input is "hello"
i am wondering is there is any way like
if input=="hello":
 fun()
i hope you get my point.. Help me out please
Thanks in advance
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Checkbox problem in Tkinter

2011-01-09 Thread ANKUR AGGARWAL
Hey I write this code up

from Tkinter import *
root=Tk()
var=StringVar()
c=Checkbutton(root,text="hello",variable=var,onvalue="",offvalue="")
c.pack()
root.mainloop()

and i got the output as -
[image: Screenshot.png]

When i take the var as of string variable type i am  unable to edit the
checkbox. It comes slected predefined and the widget in kindof Invisible and
u can say uneditable. Can anybody tell me whats i am  doing wrong in this???
Its works fine if i take the var variable as the integer variable. I can
deselect and select in that case and it gives me the desired result but in
string case i am unable to do so as checkbox is invisible type.
I am using Python 2.6
Thanks In Advance
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Alternate button hit problem in tkinter

2011-02-01 Thread ANKUR AGGARWAL
Hey
I am developing a zero-cross game from the basics of the tkinter. I want
something like this-

We have 4 buttons like 1 2 3 4
i want the output should change on the alternate button hit. Like inorder i
hit-
Button  return
1  1
3   0
2   1
4   0

Basically i want to change the output of the button alternatively. like for
example take this scenario-

Button   return
2 1
4  0
1  1
3   0

It depends on the user which button it hits first but i want the output to
be different for alternate button pick.
i tried to think upon this very much but unable to finally come up with any
idea. Cn anyone suggest me a way out.
Thanks in Advance.
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Update a button content on click

2011-02-15 Thread ANKUR AGGARWAL
Hey
I am looking for a method using Tkinter module to update the button on the
click.
Suppose I have a button with "hello" print on it. I want that when i click
on it "hello" got updated with the "hi". New value button should return on
the its click should be "hi". I tried it through event handling but failed
to do so.
Any help would be appreciated.
Thanks In Advance
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Update a button content on click

2011-02-15 Thread ANKUR AGGARWAL
hmmm... i got the point.
I applied it in image case.

b1=button(root,image=None,height=4,width=4,command=ok)

and then ok defination is as follows :
 def ok():
  b1["image"]=photo

now problem is that after clicking on the button, image is coming up like a
flash and then button becomes almost to zero size. I want to retain the
height=4,width=4 along with the image after clicking on the button. Image
size is smaller than the button size.

On Tue, Feb 15, 2011 at 5:58 PM, Alan Gauld wrote:

>
> "ANKUR AGGARWAL"  wrote
>
>
>  I am looking for a method using Tkinter module to update the button on the
>> click.
>>
>
> Define an event handler command for the button.
> Lets call it sayHi()
>
> def sayHi(self):
>self.myButton['text'] = 'hi'
># Note:event handlers don't return results so store it as an attribute
>self.myButtonResult = 'hi'
>
> Now create the widget with spam as the handler.
>
> self.myButton = Button(parent, text='hello', command = spam)
>
> That's it.
>
>
>  the its click should be "hi". I tried it through event handling but failed
>> to do so.
>>
>
> It would be more helpful if you posted the code that you tried
> and a more detailed explanation of "failed to do so".
> What happened? Did it update but not store a value?
> Did you get an error message? Did anything happen?
>
> The more specific information you provide the more likely you
> are to get a specific solution that works.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Update a button content on click

2011-02-15 Thread ANKUR AGGARWAL
from Tkinter import *
root=Tk()

photo=PhotoImage(file="Cross.gif")
def ok():
 b1["image"]=photo

b1=Button(root,text="",image=None,command=ok)
b1.grid()
root.mainloop()

Here's my code . Not getting the desired output

On Tue, Feb 15, 2011 at 10:26 PM, ALAN GAULD wrote:

> > b1=button(root,image=None,height=4,width=4,command=ok)
>
> This says you want the button to e 4 pixels squarte. Is that really
> what you want?, because
>
>  and then ok defination is as follows :
>  def ok():
>   b1["image"]=photo
>
> now problem is that after clicking on the button, image is coming
> up like a flash and then button becomes almost to zero size.
>
> Like to 4x4 pixels maybe, just as you asked?
> What happens if you change the size to something like 40x40?
>
> Also in Tkinter to display an image you usually have to firtst create
> a PhotoImage object and assign that to the image attribute. It's not
> clear from your code whether you are doing that or not.
> Is photo a PhotImage object?
>
> I want to retain the height=4,width=4 along with the image after
> clicking on the button. Image size is smaller than the button size.
>
> It sounds like your original size is greater than 4x4 and after setting
> the image it shrinks to 4x4...
>
> HTH,
>
> Alan G.
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Update a button content on click

2011-02-15 Thread ANKUR AGGARWAL
upper code posted earlier  is running fine

The problem is in the code below bcoz of the height nd width factor...
from Tkinter import *
root=Tk()

photo=PhotoImage(file="Cross.gif")
def ok():
 b1["image"]=photo

b1=Button(root,text="",image=None,height=4,width=4,command=ok)
b1.grid()

On Tue, Feb 15, 2011 at 10:34 PM, ANKUR AGGARWAL wrote:

> from Tkinter import *
> root=Tk()
>
> photo=PhotoImage(file="Cross.gif")
> def ok():
>  b1["image"]=photo
>
> b1=Button(root,text="",image=None,command=ok)
> b1.grid()
> root.mainloop()
>
> Here's my code . Not getting the desired output
>
> On Tue, Feb 15, 2011 at 10:26 PM, ALAN GAULD wrote:
>
>> > b1=button(root,image=None,height=4,width=4,command=ok)
>>
>> This says you want the button to e 4 pixels squarte. Is that really
>> what you want?, because
>>
>>  and then ok defination is as follows :
>>  def ok():
>>   b1["image"]=photo
>>
>> now problem is that after clicking on the button, image is coming
>> up like a flash and then button becomes almost to zero size.
>>
>> Like to 4x4 pixels maybe, just as you asked?
>> What happens if you change the size to something like 40x40?
>>
>> Also in Tkinter to display an image you usually have to firtst create
>> a PhotoImage object and assign that to the image attribute. It's not
>> clear from your code whether you are doing that or not.
>> Is photo a PhotImage object?
>>
>> I want to retain the height=4,width=4 along with the image after
>> clicking on the button. Image size is smaller than the button size.
>>
>> It sounds like your original size is greater than 4x4 and after setting
>> the image it shrinks to 4x4...
>>
>> HTH,
>>
>> Alan G.
>>
>>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Update a button content on click

2011-02-15 Thread ANKUR AGGARWAL
your code was fine. I am having problem with this code

from Tkinter import *
root=Tk()

photo=PhotoImage(file="Cross.gif")
def ok():
 b1["image"]=photo
b1=Button(root,text="",image=None,height=4,width=4,command=ok)
b1.grid()
root.mainloop()


On Tue, Feb 15, 2011 at 11:20 PM, ALAN GAULD wrote:

> I modified your code slightly for Python 3.1 to this:
>
> ###
> from tkinter import *
> root=Tk()
>
>
> def ok():
>  b1["image"]=photo
>
> photo=PhotoImage(file=r"M:\Photos\TomMcM\Chris.GIF")
>
> b1=Button(root,text="",image=None,command=ok)
> b1.grid()
>
> root.mainloop()
> #
>
> Which works perfectly for me.
> What happens for you?
> Do you get any error messages?
>
> Alan Gauld
> Author of the Learn To Program website
>
> http://www.alan-g.me.uk/
>
>
> *From:* ANKUR AGGARWAL 
> *To:* ALAN GAULD 
> *Cc:* tutor@python.org
> *Sent:* Tuesday, 15 February, 2011 17:04:06
> *Subject:* Re: [Tutor] Update a button content on click
>
> from Tkinter import *
> root=Tk()
>
> photo=PhotoImage(file="Cross.gif")
> def ok():
>  b1["image"]=photo
>
> b1=Button(root,text="",image=None,command=ok)
> b1.grid()
> root.mainloop()
>
> Here's my code . Not getting the desired output
>
> On Tue, Feb 15, 2011 at 10:26 PM, ALAN GAULD wrote:
>
>> > b1=button(root,image=None,height=4,width=4,command=ok)
>>
>> This says you want the button to e 4 pixels squarte. Is that really
>> what you want?, because
>>
>>  and then ok defination is as follows :
>>  def ok():
>>   b1["image"]=photo
>>
>> now problem is that after clicking on the button, image is coming
>> up like a flash and then button becomes almost to zero size.
>>
>> Like to 4x4 pixels maybe, just as you asked?
>> What happens if you change the size to something like 40x40?
>>
>> Also in Tkinter to display an image you usually have to firtst create
>> a PhotoImage object and assign that to the image attribute. It's not
>> clear from your code whether you are doing that or not.
>> Is photo a PhotImage object?
>>
>> I want to retain the height=4,width=4 along with the image after
>> clicking on the button. Image size is smaller than the button size.
>>
>> It sounds like your original size is greater than 4x4 and after setting
>> the image it shrinks to 4x4...
>>
>> HTH,
>>
>> Alan G.
>>
>>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Recommendation for Pygame

2011-03-01 Thread ANKUR AGGARWAL
Hey
Any good recommendation (ebook,links,videos,Live Example) to get started
with the pygame api. I am totally new to pygame.
Thanks in advance. Waiting for the suggestions :):)
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] books Recommendation

2011-03-18 Thread ANKUR AGGARWAL
Any good ebooks or printed books to get started with the Django framework
and web based python??
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Difference

2011-03-20 Thread ANKUR AGGARWAL
Hey
want to know whats the difference between the pygame.display.update() and
pygame.display.flip()
An explanation with the example would be grea.
Thanks In Advance
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Recommendations required

2011-04-04 Thread ANKUR AGGARWAL
Hey
I am reading pygame module and experimenting with it in small codes too . I
want your help. I want you to  recommend the games ,beginner of this module
should try to develop as a practice or so.
Thanks
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] First Game Attempt

2011-04-18 Thread ANKUR AGGARWAL
Hey
I was reading Pygame API for a month and made out a very basic ,small game
named as "Hungry Snake" as practice. Want to share out the code with uou
guys. Here's the link
http://code.google.com/p/hungry-snakes/downloads/list
Thanks
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] 3 Level Snake Game Made using Pygame API

2011-05-11 Thread ANKUR AGGARWAL
Hey
Few weeks back I made out the basic of the snake game and released it on the
Web under the file name "hungry.py". Now I Upgraded It Into a 3 Level Game.
I test it on windows too and its working completely fine over there too.
Download the "Game.Zip" file to play all the three levels and "hungry.py" to
play the basic version. Releasing this under GPLv3 :):) Try it out and
feedback would be gr8. Here's the download link
http://code.google.com/p/hungry-snakes/downloads/list
Thanks
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Hungry Snake now on Softpedia

2011-05-14 Thread ANKUR AGGARWAL
Hey
I got a mail form softpedia today that they have added my game "Hungry
Snake"  to their site too under 100% free certificate. I am really happy
:):) I can feel the power of open source :):) Want to share this with you
people because I learned a lot from the python community .

Game Links - http://code.google.com/p/hungry-snakes/ ,
http://mac.softpedia.com/get/Games/Hungry-Snake.shtml
Certificate Link -
http://mac.softpedia.com/progClean/Hungry-Snake-Clean-98721.html

Thanks
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Algorithm for sequence matching

2011-07-02 Thread ANKUR AGGARWAL
Hey
I am looking for an algo for the largest sequence search in the two list.

Example : list a accepts some say 'm' numbers. list b accept says 'n'
numbers. I want to look for the largest same sequence between the two list
and then display it. I tried out but failed to do so.
Say A=[11,23,45,21,63,56,78,32]
B=[56,78,11,23,45,21,111,234,56543]

There are two  similar sequence matching over here [11,23] and [23,45,21] i
want to display second sequence because its larger in number. Plz help
Thanks in Advance :)

Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Store the output of os.system

2011-08-21 Thread ANKUR AGGARWAL
Hey
I am executing a grep command in my python program using os.system. I
want to store the output somewhere but because of GUI's involved
(generated using tkinter and pyzenity) I am unable to store my output
or the result of the executed grep command in some form. Can you guys
tell me how to store the output of a terminal or show the output in a
GUI in python??
Thanks in advance.

Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Github Pygame Example Repository

2011-12-17 Thread ANKUR AGGARWAL
I have created an pygame example repo on github to promote the
learning of this API. check this out
https://github.com/ankur0890/Pygame-Examples-For-Learning . I created
an blog post of the same on my linux blog :
http:.//flossstuff.wordpress.com/2011/12/17/github-repository-for-pygame-examples/
. Suggestions and feedback would be great. Looking for contribution
too :)

Regards
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Continuous Shooting

2012-01-12 Thread ANKUR AGGARWAL
Hey
I was making a demo shooting game and problem is that I want
a continuous stream of bullets. As of now on pressing the space key only
one bullet comes out of the plane (I want this to be continuous stream). On
pressing space key again bullet starts from its initial point. My problem
in the code is that I am able to make a single object of Bullet only (thats
why it is throwing single bullet) and unable to find the another logic.
Please help me out. Attaching the files along with this mail.

import pygame
from pygame.locals import *
import random

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")

class Plane(pygame.sprite.Sprite):
def __init__(self,bullet):
self.bullet=bullet
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
pressed=pygame.key.get_pressed()
if pressed[K_DOWN]:
self.rect.centery+=self.dy
elif pressed[K_UP]:
self.rect.centery-=self.dy
elif pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter

if pressed[K_SPACE]:
self.bullet.x=self.rect.centerx
self.bullet.y=self.rect.centery



class Bullet(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('geometrybullet.png').convert_alpha()
self.rect=self.image.get_rect()
self.rect.center=(-100,-100)
self.x=-100
self.y=-100
self.dy=5


def update(self):
self.y-=self.dy
self.rect.center=(self.x,self.y)
if self.rect.top<0:
self.x=-100
self.y=-100


def main():
background=pygame.Surface(screen.get_size())
background=background.convert()
screen.blit(background,(0,0))
bullet=Bullet()
plane=Plane(bullet)
allSprites=pygame.sprite.Group(plane,bullet)

while 1:
for i in pygame.event.get():
quitPressed=pygame.key.get_pressed()
if i.type==QUIT or quitPressed[K_q]:
exit()

allSprites.clear(screen,background)
allSprites.update()
allSprites.draw(screen)
pygame.display.flip()


if __name__=='__main__':
main()

Thanks in advance :)

Regards
Ankur Aggarwal
<><>import pygame
from pygame.locals import *
import random

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")

class Plane(pygame.sprite.Sprite):
def __init__(self,bullet):
self.bullet=bullet
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
pressed=pygame.key.get_pressed()
if pressed[K_DOWN]:
self.rect.centery+=self.dy
elif pressed[K_UP]:
self.rect.centery-=self.dy
elif pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter

if pressed[K_SPACE]:
self.bullet.x=self.rect.centerx
self.bullet.y=self.rect.centery



class Bullet(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('geometrybullet.png').convert_alpha()
self.rect=self.image.get_rect()
self.rect.center=(-100,-100)
self.x=-100
self.y=-100

[Tutor] Delay Between iterations

2012-01-12 Thread ANKUR AGGARWAL
import pygame
from pygame.locals import *
import random

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")
background=pygame.Surface(screen.get_size())
background=background.convert()
screen.blit(background,(0,0))

class Plane(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
self.pressed=pygame.key.get_pressed()
if self.pressed[K_DOWN]:
self.rect.centery+=self.dy
elif self.pressed[K_UP]:
self.rect.centery-=self.dy
elif self.pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif self.pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter




class Bullet(pygame.sprite.Sprite):
def __init__(self,posx,posy,image):
pygame.sprite.Sprite.__init__(self)
if self.shootCount>10:
self.image=image
self.rect=self.image.get_rect()
self.rect.center=(posx,posy-30)
self.dy=5
else:
self.shootCount+=1


def update(self):
self.rect.centery-=self.dy
self.rect.center=(self.rect.centerx,self.rect.centery)
if self.rect.top<=0:
self.kill()


def main():
image=pygame.image.load('geometrybullet.png').convert()
plane=Plane()
allSprites=pygame.sprite.Group(plane)
clock=pygame.time.Clock()

while 1:
pressed=pygame.key.get_pressed()
for i in pygame.event.get():
if i.type==QUIT or pressed[K_q]:
exit()
*if  pressed[K_SPACE]:*
*bullet=Bullet(plane.rect.centerx,plane.rect.centery,image)*
*bullet.shootCount=0*
*allSprites.add(bullet)*


allSprites.clear(screen,background)
allSprites.update()
allSprites.draw(screen)
pygame.display.flip()


if __name__=='__main__':
main()


I was trying to make shooting game. whenever I press the space key bullet
object is called (bold code) . I want delay between iterations to produce
the gap between the bullets.Tried the time.wait() but its working. Any
Ideas??

Thanks In Advance

Regards
Ankur Aggarwal
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Delay Between iterations

2012-01-12 Thread ANKUR AGGARWAL
In the last code provided I messed up the Bullet Class Code. Apologies for
that. Below is my code :

import pygame
from pygame.locals import *
import random
import time

pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Hit The Stone")
background=pygame.Surface(screen.get_size())
background=background.convert()
screen.blit(background,(0,0))

class Plane(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load('plane.gif').convert()
self.rect=self.image.get_rect()
self.rect.centerx=random.randint(0,screen.get_width())
self.distancefromcenter=30
self.rect.centery=screen.get_height()-self.distancefromcenter
self.dx=2
self.dy=2

def update(self):
self.pressed=pygame.key.get_pressed()
if self.pressed[K_DOWN]:
self.rect.centery+=self.dy
elif self.pressed[K_UP]:
self.rect.centery-=self.dy
elif self.pressed[K_LEFT]:
self.rect.centerx-=self.dx
elif self.pressed[K_RIGHT]:
self.rect.centerx+=self.dx


if self.rect.bottom>=screen.get_height():
self.rect.bottom=screen.get_height()
elif self.rect.top<=0:
self.rect.top=0

if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
self.rect.centerx=screen.get_width()-self.distancefromcenter
elif self.rect.centerx<=self.distancefromcenter:
self.rect.centerx=self.distancefromcenter




class Bullet(pygame.sprite.Sprite):
def __init__(self,posx,posy,image):
pygame.sprite.Sprite.__init__(self)
self.image=image
self.rect=self.image.get_rect()
self.rect.center=(posx,posy-30)
self.dy=5



def update(self):
self.rect.centery-=self.dy
self.rect.center=(self.rect.centerx,self.rect.centery)
if self.rect.top<=0:
self.kill()
class Blank(pygame.sprite.Sprite):
def __init__(self,posx,posy):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.Surface((10,20))
self.image.fill((0,0,0))
self.rect=self.image.get_rect()
self.rect.center=(posx,posy-30)
self.dy=5


def update(self):
self.rect.centery-=self.dy
self.rect.center=(self.rect.centerx,self.rect.centery)
if self.rect.top<=0:
self.kill()


def main():
image=pygame.image.load('geometrybullet.png').convert()
plane=Plane()
allSprites=pygame.sprite.Group(plane)
clock=pygame.time.Clock()

while 1:
pressed=pygame.key.get_pressed()
for i in pygame.event.get():
if i.type==QUIT or pressed[K_q]:
exit()
if  pressed[K_SPACE]:
bullet=Bullet(plane.rect.centerx,plane.rect.centery,image)
bullet.shootCount=0
allSprites.add(bullet)


allSprites.clear(screen,background)
allSprites.update()
allSprites.draw(screen)
pygame.display.flip()


if __name__=='__main__':
main()



On Thu, Jan 12, 2012 at 11:01 PM, ANKUR AGGARWAL wrote:

> import pygame
> from pygame.locals import *
> import random
>
> pygame.init()
> screen=pygame.display.set_mode((640,480),0,24)
> pygame.display.set_caption("Hit The Stone")
> background=pygame.Surface(screen.get_size())
> background=background.convert()
> screen.blit(background,(0,0))
>
> class Plane(pygame.sprite.Sprite):
> def __init__(self):
> pygame.sprite.Sprite.__init__(self)
> self.image=pygame.image.load('plane.gif').convert()
> self.rect=self.image.get_rect()
> self.rect.centerx=random.randint(0,screen.get_width())
> self.distancefromcenter=30
> self.rect.centery=screen.get_height()-self.distancefromcenter
> self.dx=2
> self.dy=2
>
> def update(self):
> self.pressed=pygame.key.get_pressed()
> if self.pressed[K_DOWN]:
> self.rect.centery+=self.dy
> elif self.pressed[K_UP]:
> self.rect.centery-=self.dy
> elif self.pressed[K_LEFT]:
> self.rect.centerx-=self.dx
> elif self.pressed[K_RIGHT]:
> self.rect.centerx+=self.dx
>
>
> if self.rect.bottom>=screen.get_height():
> self.rect.bottom=screen.get_height()
> elif self.rect.top<=0:
> self.rect.top=0
>
> if self.rect.centerx>=screen.get_width()-self.distancefromcenter:
> self.rect.centerx=screen.get_width()-self.distancefromcenter
> elif self.rect.centerx<=self.distancefromcenter:
> self.rect.centerx=self.distancefromcenter
>
>
>
>
&g

[Tutor] Query with SOAP request generation, which other modules can be used.

2012-05-22 Thread ankur ~ अंकुर
Dear Pythoneers,

We want to butile the SOAP request request in below manner. -

In header we want to pass the wsse auth part and custom transref section
and both has different xmlns.


http://schemas.xmlsoap.org/soap/envelope/";
xmlns:com="http://some.xmlns.org/.1.0/Common.xsd"; xmlns:bil="
http://some.xmlns.org/Schema/Billing/1.0/Billing.xsd";>

   

  
 PORTAL
 123456
 123456
  

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
">
 http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
">
user
pass
 
  

   

   
  
 187000
  
   




Currently we are using pysimplesoap (
http://code.google.com/p/pysimplesoap/) module for this. The current
python code is attached.

But we are not able to pass the custom xmlns ( for bil and for com - the
very first line )  with pysimplesoap module.

*Any idea which other module we have to explore for generating the SOAP
request like above.*

Thank You,
Ankur.

from pysimplesoap.client import SoapClient
import sys,traceback

client = SoapClient(
location="http://www.abc.com/ABC/Billing";,
action = "http://www.abc.org/Service/getBill";,
namespace="http://www.abc.org/Service/Billing.wsdl";,
trace=True)

client['wsse:Security'] = {
'wsse:UsernameToken': {
'wsse:Username': 'username',
'wsse:Password': 'password',
}
}

client['com:TransRef'] = {
'com:SystemId': 'PORTAL',
'com:TxID': '20012001161378998',
'com:BID': '123456789'
}

try:
  response = client.getBill(AccountID=123456)
  print response
except:
  errortrace =  ''.join(traceback.format_exception(*sys.exc_info()))
  print("Unexpected error: %s" % (errortrace,))

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] using dynamic import statements

2012-07-09 Thread ankur ~ अंकुर
On Mon, Jul 9, 2012 at 6:40 AM, Chris Hare  wrote:

>
> Here is what I want to do:
>
> I have a bunch of modules to import. instead of duplicating a lot of code
> for each import, I want to do something like this:
>
> importList = [ "sys", "os", "imp", "stat", "re", "webbrowser", "Image",
>  "StringIO", "shutil", "datetime" ]
>
> for object in importList:
> try:
> if debug == "ON":
> print "Importing module %s" % (object)
> exec( "import  " + object)
> except ImportError as error:
> print "%s %s requires the Python %s library.  " % (
> appName,
>
> str(appVersion), object )
> print "An error occurred when attempting to load the
> library.  The error was '%s'." % ( error )
> exit()
>
> Everything "appears" to run okay, however, when the first piece of code
> that relies upon one of these imported modules is executed, I get an error:
>
> Traceback (most recent call last):
>   File "a.py", line 122, in 
> imp.load_module(object,fp,pathName,description)
>   File "./Modules/functions.py", line 133, in 
> def special_match(strg, search=re.compile(r'[^a-zA-Z0-9\.\
> \-\#\$\*\@\!\%\^\&]').search):
> NameError: name 're' is not defined
>
> Is is possible to do what I am trying to do, or am I doing something wrong?
>
> Thanks
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Hi,

How about using import imp
http://docs.python.org/library/imp.html

calling run time modules as per your need.

thank you
ankur.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor