Re: [pygame] refresh problem
Luke Paireepinart ha scritto: Lenard Lindstrom wrote: Luke Paireepinart wrote: In single process mode it will lock up the editor, but frees it when the window Pygame window closes. But if you have an error in your code, the window won't exit, and the editor won't unfreeze. That's the problem he's having. -Luke This works: import pygame from pygame.locals import * pygame.init() try: screen = pygame.display.set_mode( (640,480) ) done = False while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: raise Exception() finally: pygame.quit() But yes, if the program gets caught in an infinite loop I expect it is hard to kill. Ah, I see. Sorry, I was confused about what your code was doing. -Luke hi again.. the problem seemed fixed, but only because it shows and goes away quite randomly.. and the above code doesn't work for me!
Re: [pygame] refresh problem
hi again.. the problem seemed fixed, but only because it shows and goes away quite randomly.. and the above code doesn't work for me! I don't know what you mean by randomly, and if you don't give us any indication of failure conditions we can't help you figure out why the code doesn't work. -Luke
Re: [pygame] refresh problem
Lots of people forget to put 'pygame.event.pump()' in the main loop. Try that, see if it stabilizes.
Re: [pygame] refresh problem
pistacchio wrote: Lenard Lindstrom ha scritto: The IDLE problem isn't really a problem as such. Being an interactive session, the interpreter doesn't shut down when the Pygame code finishes. So pygame.quit is not called and the window remains visible. Restarting the interpreter or adding an explicit pygame.quit() closes the window. As for the OPs example code, I put it in a file and double-clicked. Worked fine. oh, thanks, this helped a lot. would the situation change with a different ide? any suggestion? (again, i'm working under windows xp) this thing that i have to work around the problem every time that the program rises an error or an exception it is quite boring as, like you made me understand, the cycle doesn't come to the point where it quits all the processes and hence pygame and i have to wait, termnate it and, in a word, lose 30 seconds every time i want to change a comma in the code. This works with IDLE in both single and subprocessed mode: import pygame from pygame.locals import * pygame.init() try: screen = pygame.display.set_mode( (640,480) ) done = False while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: done = True finally: pygame.quit() In single process mode it will lock up the editor, but frees it when the window Pygame window closes. -- Lenard Lindstrom [EMAIL PROTECTED]
Re: [pygame] refresh problem
In single process mode it will lock up the editor, but frees it when the window Pygame window closes. But if you have an error in your code, the window won't exit, and the editor won't unfreeze. That's the problem he's having. -Luke
Re: [pygame] refresh problem
Luke Paireepinart wrote: In single process mode it will lock up the editor, but frees it when the window Pygame window closes. But if you have an error in your code, the window won't exit, and the editor won't unfreeze. That's the problem he's having. -Luke This works: import pygame from pygame.locals import * pygame.init() try: screen = pygame.display.set_mode( (640,480) ) done = False while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: raise Exception() finally: pygame.quit() But yes, if the program gets caught in an infinite loop I expect it is hard to kill. -- Lenard Lindstrom [EMAIL PROTECTED]
Re: [pygame] refresh problem
Lenard Lindstrom wrote: Luke Paireepinart wrote: In single process mode it will lock up the editor, but frees it when the window Pygame window closes. But if you have an error in your code, the window won't exit, and the editor won't unfreeze. That's the problem he's having. -Luke This works: import pygame from pygame.locals import * pygame.init() try: screen = pygame.display.set_mode( (640,480) ) done = False while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: raise Exception() finally: pygame.quit() But yes, if the program gets caught in an infinite loop I expect it is hard to kill. Ah, I see. Sorry, I was confused about what your code was doing. -Luke
Re: [pygame] refresh problem
pistacchio wrote: hi to all! this is my first post in pygame (windows xp, python 2.5). i've started using pygame some days ago and after a bit of coding i'm completely stuck. the problem is that even the simpliest code like import pygame from pygame.locals import * pygame.init() screen = pygame.display.set_mode( (640,480) ) done = False while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: done = True get the game window to freeze. it just doesn't update and acts strangely. the window is like transparent, it makes me see what is behind it. if i minimize it and then reopen it, it shows the content, but if i drag it around the screen, it sort of collects the images it overlaps.. i've tried various code to get around the problem, like various flags in set_mode, flip and update and event pumping but nothing seems to work. it shows no problem in fullscreen mode, though. any idea? thanks in advance, gustavo display.flip() might be the problem, you might be better off using display.update() in windowed mode. That's really all I can think of, your code looks fine to me. -Luke
Re: [pygame] refresh problem
pistacchio wrote: while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: done = True Note that pygame.event.get() doesn't block, so you're spinning in an extremely busy loop here. The screen mightn't be getting a chance to update. Try putting a pygame.event.wait() call in the loop. -- Greg
Re: [pygame] refresh problem
James Paige wrote: On Tue, Sep 04, 2007 at 05:09:14PM +0200, pistacchio wrote: Greg Ewing ha scritto: pistacchio wrote: while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: done = True Note that pygame.event.get() doesn't block, so you're spinning in an extremely busy loop here. The screen mightn't be getting a chance to update. Try putting a pygame.event.wait() call in the loop. -- Greg hi there! still nothing.. i've altro tried with pygame's event pump and wait and stuff, and nothing. then, the program worked beautifully without a problem.. till a reboot of the computer, when the same code (now) shows the same problem.. Are you using the IDLE editor? I seem to remember some talk about it causing problems similer to this. There was a command-line option that you had to add to make it run programs in a separate interpreter, which prevented its own event handler from colliding with pygame's --- James Paige The IDLE problem isn't really a problem as such. Being an interactive session, the interpreter doesn't shut down when the Pygame code finishes. So pygame.quit is not called and the window remains visible. Restarting the interpreter or adding an explicit pygame.quit() closes the window. As for the OPs example code, I put it in a file and double-clicked. Worked fine. -- Lenard Lindstrom [EMAIL PROTECTED]
Re: [pygame] refresh problem
Lenard Lindstrom ha scritto: James Paige wrote: On Tue, Sep 04, 2007 at 05:09:14PM +0200, pistacchio wrote: Greg Ewing ha scritto: pistacchio wrote: while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: done = True Note that pygame.event.get() doesn't block, so you're spinning in an extremely busy loop here. The screen mightn't be getting a chance to update. Try putting a pygame.event.wait() call in the loop. -- Greg hi there! still nothing.. i've altro tried with pygame's event pump and wait and stuff, and nothing. then, the program worked beautifully without a problem.. till a reboot of the computer, when the same code (now) shows the same problem.. Are you using the IDLE editor? I seem to remember some talk about it causing problems similer to this. There was a command-line option that you had to add to make it run programs in a separate interpreter, which prevented its own event handler from colliding with pygame's --- James Paige The IDLE problem isn't really a problem as such. Being an interactive session, the interpreter doesn't shut down when the Pygame code finishes. So pygame.quit is not called and the window remains visible. Restarting the interpreter or adding an explicit pygame.quit() closes the window. As for the OPs example code, I put it in a file and double-clicked. Worked fine. oh, thanks, this helped a lot. would the situation change with a different ide? any suggestion? (again, i'm working under windows xp) this thing that i have to work around the problem every time that the program rises an error or an exception it is quite boring as, like you made me understand, the cycle doesn't come to the point where it quits all the processes and hence pygame and i have to wait, termnate it and, in a word, lose 30 seconds every time i want to change a comma in the code. thanks.
Re: [pygame] refresh problem
pistacchio wrote: Lenard Lindstrom ha scritto: James Paige wrote: On Tue, Sep 04, 2007 at 05:09:14PM +0200, pistacchio wrote: Greg Ewing ha scritto: pistacchio wrote: while not done: pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: done = True Note that pygame.event.get() doesn't block, so you're spinning in an extremely busy loop here. The screen mightn't be getting a chance to update. Try putting a pygame.event.wait() call in the loop. -- Greg hi there! still nothing.. i've altro tried with pygame's event pump and wait and stuff, and nothing. then, the program worked beautifully without a problem.. till a reboot of the computer, when the same code (now) shows the same problem.. Are you using the IDLE editor? I seem to remember some talk about it causing problems similer to this. There was a command-line option that you had to add to make it run programs in a separate interpreter, which prevented its own event handler from colliding with pygame's --- James Paige The IDLE problem isn't really a problem as such. Being an interactive session, the interpreter doesn't shut down when the Pygame code finishes. So pygame.quit is not called and the window remains visible. Restarting the interpreter or adding an explicit pygame.quit() closes the window. As for the OPs example code, I put it in a file and double-clicked. Worked fine. oh, thanks, this helped a lot. would the situation change with a different ide? any suggestion? (again, i'm working under windows xp) don't right-click and choose edit with IDLE. instead, open IDLE from the start menu and load your files from within IDLE (should be in 'recent documents') there's some problem with IDLE and using the separate subprocess that only comes up when you right click and edit, so the developers made it to where if you choose that option from the context menu IDLE boots with subprocess turned off. You can also edit the code for the 'edit with IDLE' menu item to get around this, but this isn't recommended because some people will run into whatever problem there is. I personally haven't had any problems with re-enabling the subprocess. -Luke
Re: [pygame] refresh problem
Luke Paireepinart ha scritto: ght-click and choose edit with IDLE. instead, open IDLE from the start menu and load your files from within IDLE (should be in 'recent documents') there's some problem with IDLE and using the separate subprocess that only comes up when you right click and edit, so the developers made it to where if you choose that option from the context menu IDLE boots with subprocess turned off. You can also edit the code for the 'edit with IDLE' menu item to get around this, but this isn't recommended because some people will run into whatever problem there is. I personally haven't had any problems with re-enabling the subprocess. -Luke thanks to all your kind replies. i solved the problem by changin ide. i'm using dr. python and it seems much more featured that the standard, raw idle. it only lacks an internal console, but i have i running in a separate window and it all works smoothly!