[PyQt] An "UI update" event/signal to update the GUI on
david at boddie.org.uk
Sun Jan 18 19:25:42 GMT 2009
On Sunday 18 January 2009, 09:44:56 -0800 (PST), eliben wrote:
> David Boddie wrote:
> > Can you give more information about your user interface? It would make it
> > easier to recommend the best approach for you to take.
> Thanks for the explanation, I'll think about it.
> Regarding my application. It's just a bunch of buttons, combo boxes and
> checkboxes that all disable and enable each other, with several possible
> configurations. The easiest approach in wxPython is to define "states" that
> are set by combinations of widgets. Now, in the wx.EVT_UI_UPDATE event
> handler of the window I just enable and disable widgets according to this
OK, so perhaps you're using widgets like QGroupBox to hold related checkboxes
or maybe using a free-form interface, with QButtonGroup to organize groups
> Dividing it into separate signals and slots per each widgets is kind-of
> kludgy in comparison, don't you think?
It depends on what level you're managing the interactions between widgets
and the complexity of the user interface. If, for example, simply checking
or unchecking a particular checkbox should cause a part of the user interface
to be disabled then using a connection to do that is probably the easiest
way. One way to tell if this is a possible approach is to try to construct
the interface in Qt Designer.
If you want to manage the state of the window at a higher level then it's
possible to connect signals from widgets (maybe just influential ones) to
a single slot in your window and manage the state from there. You can then
just treat this slot like you would the wx.EVT_UI_UPDATE event handler in
your original application, and perform all the updates there.
More information about the PyQt