Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Forking, threading, wha?
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BuckMcCoy




PostPosted: Sun May 31, 2009 11:24 pm   Post subject: Forking, threading, wha?

Hi, basically all I'm trying to do in python is what you could do in Turing with the fork command. The reason being is there is some animation in my program that I don't want to be effected by a surrounding time.wait(). Unfortunately, although python does have os.fork() it doesn't work on Windows. Anyway, here's the animation as a function:
code:

def animate():
     dance = pygame.image.load("Images/Animations/dance.bmp").convert()
     Title = pygame.image.load("Images/Title.bmp").convert()
     ctr=0   
     while 1:
          ctr+=1
          if ctr==100000: #Animation
               dance=pygame.transform.flip(dance, True,False)
               screen.blit(dance, (391,330))
               screen.blit(tap, (118,385))         
               pygame.display.flip()
          elif ctr>=200000:
               screen.blit(Title,(118,385,25,19),(118,385,25,19))
               screen.blit(Title,(391,330,44,44),(391,330,44,44))
               pygame.display.flip()       
               ctr=0


What could I use to make this run parallel with my program without it just running and getting hung up in the while loop? (And how would I stop it when I'm through with it? Razz) Thanks!
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Tue Jun 02, 2009 7:17 am   Post subject: RE:Forking, threading, wha?

this looks like what you want: http://docs.python.org/library/threading.html#thread-objects
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: