#!/usr/bin/python
# -*-編碼:utf8 -*-
來自Tkinter import *
類別選擇(框架):
def __init__(self,master=None):
框架。__init__(自身,主)
Self.label = Label(self,text= "select item ")
self.listBox = Listbox(self,height=1)
self.button = Button(self,text='V ',command=self.triggle)
self.hideList = True
對於xrange(10)中的I:
self.listBox.insert(i,' Item%d'%i '
self.label.grid(row=0,column=0,sticky=N)
self.listBox.grid(row=0,column=1,sticky=N)
self.button.grid(row=0,column=2,sticky=N)
self.grid()
定義觸發器(自身):
^= 1
self . listbox . config(height =[self . listbox . size(),1][self.hideList])
app = Select()
App.mainloop()僅供參考。