Q: How to Change Pmw.ComboBox width ??

Camilo Olarte colarte at telesat.com.co
Fri Sep 26 05:14:34 EDT 2003


Hello list, 
I was trying to make a Pmw.ComboBox and while using it i
needed to change its width. 
I tried to configure it's inner components  directly like _listbox.config 
but nothing changes.. 
By default in my computer this combobox width is of 12 (characters)
and since I am showing number of the month i need only 3 characters.
i could use a Pmw.Counter but my boss don't likes it's arrows  :(   ...

Here is some sample code of what i'm doing.

<PYTHON>
import Tkinter, Pmw
class DemoCombo:
    def __init__(self, parent):
        parent.configure(background = 'white')
        arrmes = [1,2,3,4,5,6,7,8,9,10,11,12] 
        # Create and pack the dropdown ComboBox.
        self.dropdown = Pmw.ComboBox(parent,label_text = 'Month:',
                 labelpos = 'n',scrolledlist_items = arrmes,
                 scrolledlist_usehullsize = 1,)
#       How do I change pmw combobox width ... 
#       self.dropdown.configure(width =2)       ...Na didn't change widht
#       self.dropdown._list.configure(width =2) ...Na didn't change widht
#       self.dropdown._list._listbox.configure(width =2) ...Na didn't cha
nge widht
        self.dropdown.pack(side = 'top')
        self.dropdown.selectitem(0) # Display the first element

    def fnShow(self):
        print self.dropdown.get()
###################################
# Create demo in root window for testing.
if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root, fontScheme = 'pmw1')
    widget = DemoCombo(root)
    Frm = Tkinter.Frame(root)
    testBtn = Tkinter.Button(Frm, text = 'Print Month',
    testBtn.pack(side = 'left')
    exitBtn = Tkinter.Button(Frm, text = 'Exit',
                 command = root.destroy)
    exitBtn.pack(side = 'right')
    Frm.pack()
    root.mainloop()

</PYTHON>

Camilo Olarte





More information about the Python-list mailing list