Disabling a Pmw.ComboBox

Matthew Dixon Cowles matt at mondoinfo.com
Mon Jun 11 16:28:23 EDT 2001


On Mon, 11 Jun 2001 13:55:17 +0100, Martyn Quick
<mrq at for.mat.bham.ac.uk> wrote:

>I'm trying to work out how to `disable' a Pmw.ComboBox (in a similar
>manner to setting  state='disabled'  for a Tkinter.Button).  One way I
>thought of doing it was to try setting  state='disabled'  for the
>'arrowbutton' component of the ComboBox.  However, this arrowbutton is a
>Tkinter.Canvas, so doesn't have  state  as a valid configuration option.
>
>Does anybody have a decent way of doing this?  (My goal is to be able to
>allow it be available for use or disabled according to other information.)

Martyn,
You might want to do a couple of things to disable the widget. You'd
probably want to disable the entry:

c.component("entryfield").component("entry").configure(state=DISABLED)

You might want to gray-out the arrow:

c.component("arrowbutton").itemconfigure(ALL,fill="gray50")

(All seems safe here since the canvas only has one thing on it.) And
you'd want to disable mouse-clicks on the button:

c.component("arrowbutton").unbind("<Button-1>")

Actually, there are a bunch of events bound to the button. A look
through PmwComboBox.py should tell you which you'd want to mess around
with.

The only non-trivial part of re-enabling things is to rebind the mouse
button:

c.component("arrowbutton").bind("<Button-1>",c._postList)

Of course, I'm advocating messing around with private class attributes
so there's a decent chance that the code will break under a future
release of Pmw but I'm not aware of another way to do what you want.

Regards,
Matt



More information about the Python-list mailing list