faqts : Computers : Programming : Languages : Python : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 12 people (83%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I set the list items of a combobox based on the selected item from another combobox?

Oct 14th, 2002 06:53
Martin Franklin, Eric Meyer,


from Tkinter import * 
import Pmw 
 
root=Tk() 
 
## this is the listening combobox.... 
cb = Pmw.ComboBox(root, labelpos="w", label_text="I am  listening to 
the other combobox") 
 
def callback(thing): 
    print "called" 
    cb.setlist(thing) ## thing is a sequence  
    cb.setentry(thing[0]) ## the first item in the sequence 
 
 
## this is the calling combobox..... 
cb1 = Pmw.ComboBox(root, selectioncommand=callback,  
    labelpos="w", label_text="Select one of my options") 
list1=["aaaa", "bbbb", "cccc"] 
cb1.setlist(list1) 
     
     
     
 
## pack the comboboxes 
cb1.pack() 
cb.pack() 
 
## enter the tk mainloop 
root.mainloop()