3 回答

TA貢獻(xiàn)1874條經(jīng)驗(yàn) 獲得超12個(gè)贊
Tkinter居然沒(méi)有這種組件,所以就只能模擬了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #! /usr/bin/python # -*- coding: utf8 -*- from Tkinter import * class Select(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.label = Label(self, text="選擇項(xiàng)目") self.listBox = Listbox(self, height=1) self.button = Button(self, text='V', command=self.triggle) self.hideList = True for i in xrange(10): 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() def triggle(self): self.hideList ^= 1 self.listBox.config(height=[self.listBox.size(), 1][self.hideList]) app = Select() app.mainloop() |
添加回答
舉報(bào)