[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame graphics window Freezes



Kris Schnee schrieb:
DR0ID wrote:
I tryed this in IDLE:

IDLE 1.1.1     >>> import pygame
 >>> pygame.init()
(6, 0)
 >>> screen = pygame.display.set_mode((800,600))
 >>> pygame.draw.line(screen, (255,255,255),(0,0),(100,100))
<rect(0, 0, 101, 101)>
 >>> pygame.display.update()
 >>> for i in range(100):
   pygame.display.update()

  >>> screen.set_at((50,50),(255,255,255))
 >>> pygame.display.update()
 >>> pygame.quit()
 >>>

But nothing happend in the pygame window.

Hmm, I don't know the answer! That should have made a line and a pixel appear. Maybe someone more experienced here can help.


To build a console within the pygame window, I know I have to render the text. It's not too slow to render the text if its not a lot text. Anyway thats not my question. I do not know how to build a console within the pygame window. Ok, when the problems of displaying and capturing the text have been solved, what must I do with the strings I get from the "inputbox"? I read something about the eval( ) or the exec( ) functions in the docs but do not understand if they are the functions to pass the strings. The idea is, that on could od the same things as in IDLE console (or as similar as possible). Ok there can be some problems. But such a console would be an interactive interface and the user could do everything (from loading images and display them to apply some transfomation or do whatever with the images). I supose it is possible some how, or not?

Assuming you have a way to display text on the screen, what I'd do is:

input_string = GetInputString() ## Or however you get the string.
exec( input_string )

...That's all. That should work for valid Python commands like declaring variables or drawing things. Two problems are:
-Calling a drawing command would seem to fail, because the image would get erased when the screen was refreshed. To test it you could try not blanking the screen between frames. A better way would be to have a list of entities that get drawn automatically each frame, with the console command just creating a new entity instead of drawing directly.
-You wouldn't get text feedback. For instance, "print 'Hello!'" would print "Hello!" to the console window, not to the graphics window.


But this method should let you run Python commands.

Kris


Hi

Thanks a lot. The problem with erasing the images by the refreshes: yes one could save this entities by the console or something like this. One could introduce some special commands for that.
The print statement could be treated perhaps in a special way by the console or perhaps one could redirect the stdoutput to the console, or not?



~DR0ID