Difference between revisions of "Dabo.ui.callAfter"

From Dabo Wiki
Jump to: navigation, search
(Created page with "== Signature: == <syntaxhighlight lang="python"> dabo.ui.callAfter(fnc, *args, **kwargs) </syntaxhighlight> == Description: == In a GUI, there are times when you can't contr...")
(No difference)

Latest revision as of 14:16, 14 May 2020


dabo.ui.callAfter(fnc, *args, **kwargs)


In a GUI, there are times when you can't control the order in which things happen. For example, you can't guarantee that a refresh will happen after the value has been updated in a control; things like that are simply executed in the GUI's event loop. So when you find that you need to ensure that something happens after the rest of the processing is done, this is the function to use. It adds the function passed in the fnc parameter to the end of the event queue, and will call it then with any additional arguments you pass.




If you write some UI code and things don't seem to be behaving as you thought that they would, try using this function to delay processing until everything else is completed.


You call a refresh() function, but only some of the controls show the new values; the rest still show the old. If you open up a Command Window and manually call self.refresh() from there, you see the correct values displayed. The cure is to change:




In the PageFrame controls, we need to raise events to signal when the active page has been changed. But there might be other things that are still updating, and so raising the event immediately can cause objects to respond before the changes have completed, and as a result may generate incorrect values for the control's state. So instead of calling:


we call this instead (note the parameter is passed after the function):

dabo.ui.callAfter(pg.raiseEvent, dEvents.PageEnter)