On Mon, Jul 23, 2012 at 8:03 PM, Nathan <[email protected]> wrote:
> On Mon, Jul 23, 2012 at 10:53 AM, anatoly techtonik <[email protected]> 
> wrote:
>> On Mon, Jul 23, 2012 at 7:27 PM, Nathan <[email protected]> wrote:
>>> On Mon, Jul 23, 2012 at 4:46 AM, anatoly techtonik <[email protected]> 
>>> wrote:
>>>> Hi,
>>>>
>>>> What is the correct way to initiate window redraw?
>>>
>>> If I understand correctly (correct me if I'm wrong, people), every
>>> Window's on_draw() function is called once each time the event "idle"
>>> loop runs.
>>
>> I've started with Hello World, and on Linux this means its window is
>> redrawn only once on startup and then each time a key is pressed.
>
> That doesn't sound right.  Can you post the entire hello world source
> code you have?

---[ fps.py ]---
import pyglet

window = pyglet.window.Window()

counter = 0
@window.event
def on_draw():
    global counter
    counter += 1
    window.clear()
    label = pyglet.text.Label('Count: %s' % counter,
                          font_name='Times New Roman',
                          font_size=36,
                          x=window.width//2, y=window.height//2,
                          anchor_x='center', anchor_y='center')
    label.draw()

pyglet.app.run()

---[ /fps.py ]---

>>> 2) Override the default idle policy of the event loop by subclassing
>>> it if you don't want it called exactly once per window per event loop.
>>>  See [a].
>>>
>>> [a] 
>>> http://www.pyglet.org/doc/programming_guide/customising_the_event_loop.html#id108
>>
>> Sounds complicated. It will be enough for me to send some event at the
>> end of on_draw to kick the loop again. I don't know how to do this
>> properly. Sending keyboard events doesn't sound right.
>
> Right.  Lets get the basic hello world working for you.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to