hi; On 27 August 2012 07:40, Frank Cox <thea...@melvilletheatre.com> wrote: > Both of the attached modifications of the program appears to work properly > every > time. > > So is my problem that the label isn't actually ready to be drawn on the first > call to sleep() for some reason?
you still fail at understanding the basic concept of event driven programming — i.e. you react to what the GUI tells you that happened, not the other way around — and, more importantly, at understanding the basic tenet of mainloop-driven toolkits, which is: Thou Shall Never Block Thy Main Loop. widgets are not "ready to be drawn" because you told them to: they have internal state that has to be updated, and given that the toolkit authors do not want to block the main loop, it will be mostly done lazily, and along with the full tree, instead of piecemeal. that's *the* main difference between event driven programming with graphical toolkits and programming done on the console: the widgets will tell *you* when they are being drawn, or when something happens. in other words, "in event driven programming, like in Soviet Russia, the toolkit updates you". another thing is that if you feel you need to call sleep() anywhere in a GUI then you are doing it wrong on an epic scale. the first rule of mainloop-driven toolkits (such as GTK+) is: you do not block the main loop. the second rule of mainloop-driven toolkits is: you do *not* block the main loop. even if you're using sleep() to demonstrate the fact that your long running operation is blocking the GUI, you're doing it wrong. let the main loop run; do not try and spin it yourself; do not try to block it; do not let long running operations in the same loop as your GUI loop, *ever*. everything I've seen from you code snippets contains at least one violation of these rules. stop trying to write code in GTK+ like you would do with ncurses. look at examples on the developer.gnome.org website; look at existing GTK+ applications; read books on event-driven programming. ciao, Emmanuele. -- W: http://www.emmanuelebassi.name B: http://blogs.gnome.org/ebassi/ _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list