[Tkinter-discuss] Method to call when gui is first displayed

mkieverpy at tlink.de mkieverpy at tlink.de
Mon Nov 27 09:55:18 CET 2006


Tony Cappellini askted:
>I want to call the function which talks to CVS after the gui is displayed,
>but without formal having to do anything.

>After I call mainloop(), the gui is displayed, but then nothing happens
>until the user selects a menu option. (as it should be).

>Is there a tk method that I can register a callback with that indicates the
>gui is displayed, and mainloop is running?

There are some events you can use (see the documentation of bind).
This example using the '' event of an Entry works for me (on Linux/X11):
---------------------------------------
from Tkinter import *

def ready(evt):
    print 'ready', evt.__dict__
    l.delete(0,END)
    l.insert(0, 'gui ready')

tk = Tk()
l = Entry(tk, width=20)
l.insert(0, 'building gui')
l.pack()
l.bind('', ready)
tk.mainloop()
---------------------------------------

The problem is: you should use the event callback just to start
the network activity, not monitoring it.
You'll need some kind of threading/subprocesses or other
to do this.
The event types are not well documented in my tk/tcl installation,
so I cannot tell you if '' is the best choice here.

Hope this helps,

Matthias Kievernagel
(mkiever - at - web - dot - de)



More information about the Tkinter-discuss mailing list