from Tkinter import * import Pmw
class choiceBox( Frame ): def __init__( self, listItems ): Frame.__init__( self ) self.pack( expand = YES, fill = BOTH ) self.master.title( "Select" )
self.listBox = Pmw.ScrolledListBox( self, items = listItems, listbox_height = 5, vscrollmode = "static", listbox_selectmode = EXTENDED ) self.listBox.pack( side = LEFT, expand = YES, fill = BOTH,padx = 5, pady = 5 )
self.copyButton = Button( self,text = ">>>", command = self.addColor ) self.copyButton.pack( side = LEFT, padx = 5, pady = 5 )
self.chosen = Pmw.ScrolledText( self,text_height = 6,text_width = 20 ) self.chosen.pack( side = LEFT, expand = YES, fill = BOTH,padx = 5, pady = 5 )
def addColor( self ): self.chosen.clear() selected = self.listBox.getcurselection()
if selected: for item in selected: self.chosen.insert( END, item + "n" )
colorNames = ( "A", "B", "C", "D") choiceBox( colorNames ).mainloop()
|