Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Pmw ComboBox question

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


kwg at renre-europe

Sep 4, 2001, 8:50 AM

Post #1 of 3 (1418 views)
Permalink
Pmw ComboBox question

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?

thanks

K.


johngrayson at home

Sep 4, 2001, 10:50 AM

Post #2 of 3 (1357 views)
Permalink
Pmw ComboBox question [In reply to]

Ken,

Set the ComboBox's Entry widget to DISABLED...

... entry_state=Tkinter.DISABLED, ...

You may also want to change the relief so that you have
something that looks like Motif's OptionMenu button, and
set the background so that it is obviously not editable...

... entry_relief=RAISED, entry_border=2, entry_bg='gray' ...

Hope that helps!

John Grayson


matt at mondoinfo

Sep 4, 2001, 10:56 AM

Post #3 of 3 (1369 views)
Permalink
Pmw ComboBox question [In reply to]

On 04 Sep 2001 16:50:09 +0100, Ken Guest <kwg [at] renre-europe> 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

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.