[Tkinter-discuss] How to automatically run some code upon GUI startup?
Fredrik Lundh
fredrik at pythonware.com
Tue Apr 8 19:01:25 CEST 2008
Snakey wrote:
> I have created a simple Tkinter GUI. I have a function that needs to be
> executed automatically upon launching the GUI application. How can it be
> done?
how about calling it from the script that creates the GUI, before you
enter the mainloop?
my_function()
root.mainloop()
if you want to call it when the GUI is up and running, you can use the
"wait_visibility" method on the root widget:
root.wait_visibility() # run event loop until window appears
my_function()
root.mainloop()
another approach is to use the "after_idle" method:
root.after_idle(my_function)
root.mainloop()
</F>
More information about the Tkinter-discuss
mailing list