猿问

python Tkinter库之OptionMenu控件问题?

python Tkinter库之OptionMenu控件问题


三国纷争
浏览 1369回答 3
3回答

HUWWW

Tkinter居然没有这种组件,所以就只能模拟了123456789101112131415161718192021#! /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="选择项目")        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()
随时随地看视频慕课网APP

相关分类

Python
我要回答