|
Object Oriented PHP-GTK2 - Events Pending - Update the GUI
Object Oriented PHP-GTK2 - Events Pending - Update the GUI
|
||||
|
OOPS Site
Compile
Events Pending - Update the GUIWhen in a loop you need to explicitly tell the GUI to update. Topic: General PHP-GTK (View All Tutorials) In some cases, such as when you are stuck in a processing loop, the GUI will become unresponsive or 'lock up'. This is because on it's own, PHP only has a single thread to work in. There are multiple ways around this, and this way is the most simple. It involves checking for pending events (aka updates waiting) and if they exist, force them out.
This while loop is how we do that. You insert this wherever you need to take a break and force the GUI to update.
Refreshing a Progress Bar
Note 1
End GameIf you need to use the events pending loop multiple times, it might be cleaner to create a new method for it in your root class or something so that you can call it with a single line of code.
Did you notice the use of the round() function? If you did, did you wonder why it was there? Logically as the loop progresses we get 0.01, 0.02.... 0.99, 1.0 - which we do - however even as PHP prints "1" for some reason GtkProgressBar was sending Gtk Warnings out about trying to set it to a value higher than 1. My guess is that I have come across a bug in PHP core with an internal loss of precision... I have seen that sort of problem many times in multiple programs on multiple systems written in various languages. Was this document helpful? I appreciate your feedback. i can has web two point ooh // copyright © 2007-2008 bob majdak jr
[ xhtml css | firefox ie7 opera ] |
||||