Re: Hook user loop into program



On Sat, Apr 16, 2011 at 5:04 AM, Marco <netuse lavabit com> wrote:
Where should I put the function
DoSomeStuff()? I attached a minimal example, it's written in lua.

You should call DoSomeStuff() immediately before gtk.main(), but at
the end of the loop in DoSomeStuff you will need to add this code:

while gtk.events_pending():
    gtk.main_iteration()

(sorry this example is in python because I'm not familiar with lua)

Anyway, this causes Gtk to do one iteration of it's mainloop, causing
the screen to display and update, without blocking your loop from
executing. Essentially you can think of it as synchronizing your loop
to the Gtk main loop.

Then once your loop completes and DoSomeStuff() returns, you call
gtk.main() in order to start the "real" mainloop and initiate user
interactions with whatever else your app does (if you simply want to
process some stuff and then exit immediately because your app doesn't
do anything else, don't bother calling gtk.main).

-- 
http://exolucere.ca



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