[wxpython-users] The best way to handle enable/disable mutually-exclusive groups of widgets

Raffaello Barella barbarossa.platz at gmail.com
Fri Mar 28 15:24:24 PDT 2008


Never used pyPubSub, so far.
My solution is to have a method in care of enabling or disabling  all
controls involved.
Inside the method a tuple contains the IDs of the controls, and a list of
their default enabling values in the same order. e.g.
def ResetControls(self):
controls =3D  button1, checkbox 1, combo1, button2, radiobutton1
enables =3D [False, False, True, True, False]
# Then the different situation are exposed:
if (condition):
     enables[2] =3D enables[4] =3D False
elif (condition):
    enables[0] =3D enables[5] =3D True
#and so on

#At the end of the method a simple "for" loop:
for j in range(len(enables)):
     controls[j].Enable(enables[j])

2008/3/28, Tony Cappellini <cappy2112 at gmail.com>:
>
> Thanks Christopher
>
> I see your point, and agree somewhat.
>
> >  first to enable it. As a rule, if at all possible, I let users put in
> >  data in any order they want, and only give an error when the ask for an
>
>
> However, in the case of a non-data entry situation...how would one
> approach this?
>
> >  answer that can not yet being provided.
>
>
> My gui is sending cmds across a serial port to an embedded device.
> The GUI allows the user to select which areas of memory to dump- lets
> say there are 5 different areas, and CheckBoxes for each area.
> The user selects any/all, then clicks a button to dump that info , and
> the text coming back is displayed in a TextControl.
>
>
> Just below the Text Control, and the checkboxes, is a Text Box, which
> lets the user send individual commands across the serial port.
> Typically these are diagnostic commands, not memory dumps as above.
>
> Now- if the user Enabled 1 or more checkboxes and clicks the button to
> dump those memory areas, they cannot be allowed to send diagnostic
> commands to the serial port, while the memory dumps are occurring (and
> vice versa).
>
> So when either action is being performed, I want to disable the other.
> The embedded device takes a long time to dump any of these memory
> areas. While that's occurring, it cannot service any other requests.
>
> To prevent the user from accidentally sending a command accidentally
> in the Text Box, I want to disable it while the device is dumping
> the memory (and vice versa)
>
>
> Have you used the pyPubSub?
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200803=
28/4b93e264/attachment.htm


More information about the wxpython-users mailing list