Pmw ComboBox question

Matthew Dixon Cowles matt at mondoinfo.com
Tue Sep 4 13:56:05 EDT 2001


On 04 Sep 2001 16:50:09 +0100, Ken Guest <kwg at renre-europe.com> wrote:

>I've searched through the Pmw documentation and can't determine
>if it's possible to lock the ComboBox from keyboard input,
>in short I want to stop users from entering text into the ComboBox.
>
>anybody know how to do this?

Dear Ken,

It seems to be sufficient to the Entry widget's state to disabled:

>>> from Tkinter import *
>>> import Pmw
>>> r=Tk()
>>> c=Pmw.ComboBox(r,
...   scrolledlist_items=("Red","Green","Blue","Orange"),
...   entryfield_entry_state=DISABLED)
>>> c.pack()

Pmw passes configuration options that have underlines in them down to
the component widgets that have the name that's the part before the
underline. Since the combobox's text field is a Pmw.EntryField (called
entryfield) and the EntryField's actual text field is a Tkinter Entry
(called entry), setting entryfield_entry_state to disabled gets the
disabled setting down to the thing that actually needs disabling.
Conveniently, Pmw's EntryField automatically un-disables the entry and
re-disables it when its contents are being changed by the setentry()
method, which is what the ComboBox uses.

As is often the case, Pmw turns out to be somewhat subtle but very
convenient.

Regards,
Matt



More information about the Python-list mailing list