Hi all,

I have used Tkinter after() to do loop update GUI in my previous post.
See 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6b616abc236c345b/7df7684d33c969c5#7df7684d33c969c5

And I tried to change after() to time.sleep(), but it seems doesn't
work at all, the Queue send and receive data properly, but the GUI
didn't even appear?

//-----code changed-----
def draw_canvas_loop(canvas_b):
    while (True):
        board = data_queue.get(block = True, timeout=2)
        print 'get', data_queue.qsize()
        draw_canvas(board, canvas_b, x, y, block_width, block_height)
        time.sleep(0.3)
    ##canvas_b.after(300, lambda:draw_canvas_loop(canvas_b))
//--------------------------------

So, can I use time.sleep() in GUI application? Or Tkinter scheduler
just ignore the sleep() function?

And if I use after(), will the code form a recursive function call,
and the memory usage will boost as the program goes (I have watched
the task manager in WinXP and find the python.exe eat more and more
memory...).
//------code-----------
def draw_canvas_loop(canvas_b):
    board = data_queue.get(block = True, timeout=1)
    print 'get', data_queue.qsize()
    draw_canvas(board, canvas_b, x, y, block_width, block_height)
    canvas_b.after(300, lambda:draw_canvas_loop(canvas_b))
//-------------------------

Best regards,
Davy
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to