本文整理汇总了Python中Tkinter.Listbox方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Listbox方法的具体用法?Python Tkinter.Listbox怎么用?Python Tkinter.Listbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.Listbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def __init__(self, root, resource_dir, lang="fr"):
ttk.Frame.__init__(self, root)
self.resource_dir = resource_dir
self._lang = None
langs = os.listdir(os.path.join(self.resource_dir, "master"))
if langs:
self._lang = (lang if lang in langs else langs[0])
self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
self.items.sort(key=lambda x: x.lower())
max_length = max([len(item) for item in self.items])
self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
#strVar = tkinter.StringVar()
self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)
for item in self.items:
self.masters.insert(tkinter.END, item)
示例2: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def __init__(self, parent, header, width=10, selectmode=tk.BROWSE):
tk.Frame.__init__(self, parent)
self.parent = parent
self.num_f = len(header)
self.headers = []
self.lbs = []
self.c = 0
self.sel_idxs = []
self.scroll = tk.Scrollbar(self, orient=tk.VERTICAL)
for i in range(0, self.num_f):
self.headers.append(tk.Label(self, text=header[i]))
self.headers[-1].grid(row=0, column=self.c, sticky=tk.EW)
self.lbs.append(tk.Listbox(self, width=width, selectmode=selectmode, yscrollcommand=self.yscroll, bg='white'))
self.lbs[-1].grid(row=1, column=self.c, sticky=tk.EW)
self.lbs[-1].bind("<<ListboxSelect>>", self.select)
self.c += 1
self.scroll.config(command=self.lbs[0].yview)
self.scroll.grid(row=1, column=self.c, sticky=tk.NS)
示例3: listbox
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def listbox(self, listOptions):
box = Tkinter.Frame(self)
self.lb = Tkinter.Listbox(box,height=len(listOptions),width=30,background='#f0f0ff', selectbackground='#c0e0ff'
,selectmode='single')
self.lb.pack()
for x in listOptions:
self.lb.insert(Tkinter.END,x)
box.pack()
示例4: create
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def create(self, **kwargs):
return tkinter.Listbox(self.root, **kwargs)
示例5: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def __init__(self, master, **kw):
tk.Listbox.__init__(self, master, **kw)
AutoScroll.__init__(self, master)
示例6: size_
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def size_(self):
sz = tk.Listbox.size(self)
return sz
示例7: static_analysis_frame_builder
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def static_analysis_frame_builder(self):
self.stat_service_frame = tk.LabelFrame(self.statics_data_frame, text="Service:", bd=1, relief='sunken', padx=5, pady=2)
self.stat_service_frame.grid(row=0, column=0, padx=5)
self.stat_ult_frame = tk.LabelFrame(self.statics_data_frame, text="Ultimate:", bd=1, relief='sunken', padx=5, pady=2)
self.stat_ult_frame.grid(row=0, column=1, padx=5)
wstat = 15
tk.Label(self.stat_service_frame, text="Source:", font=self.helv_res).grid(row=0, column=0, padx=5)
tk.Label(self.stat_service_frame, text="Load (kips):", font=self.helv_res).grid(row=0, column=1, padx=5)
tk.Label(self.stat_service_frame, text="Location (ft):", font=self.helv_res).grid(row=0, column=2, padx=5)
tk.Label(self.stat_service_frame, text="Moment Arm (ft):", font=self.helv_res).grid(row=0, column=3, padx=5)
tk.Label(self.stat_service_frame, text="Moment (ft-kips):", font=self.helv_res).grid(row=0, column=4, padx=5)
self.service_statics = []
self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
self.service_statics[0].grid(row=1, column=0)
self.service_statics[1].grid(row=1, column=1)
self.service_statics[2].grid(row=1, column=2)
self.service_statics[3].grid(row=1, column=3)
self.service_statics[4].grid(row=1, column=4)
tk.Label(self.stat_ult_frame, text="Source:", font=self.helv_res).grid(row=0, column=0, padx=5)
tk.Label(self.stat_ult_frame, text="Load (kips):", font=self.helv_res).grid(row=0, column=1, padx=5)
tk.Label(self.stat_ult_frame, text="Location (ft):", font=self.helv_res).grid(row=0, column=2, padx=5)
tk.Label(self.stat_ult_frame, text="Moment Arm (ft):", font=self.helv_res).grid(row=0, column=3, padx=5)
tk.Label(self.stat_ult_frame, text="Moment (ft-kips):", font=self.helv_res).grid(row=0, column=4, padx=5)
self.ultimate_statics = []
self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
self.ultimate_statics[0].grid(row=1, column=0)
self.ultimate_statics[1].grid(row=1, column=1)
self.ultimate_statics[2].grid(row=1, column=2)
self.ultimate_statics[3].grid(row=1, column=3)
self.ultimate_statics[4].grid(row=1, column=4)
示例8: create_song_list_panel
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def create_song_list_panel(self):
# Creating Picture Canvas as Background
background=Tkinter.PhotoImage(file="../Icons/background.gif")
mainframe=Tkinter.Canvas(self.root)
mainframe.pack(side='top', expand='yes', fill='both')
mainframe.image=background
mainframe.create_image(0, 0, anchor="nw", image=background)
frame0=Tkinter.Frame(mainframe)
frame0.pack(side='top')
Tkinter.Label(frame0, text='Search : ', bg='skyblue').pack(side='left', expand='yes', fill='x')
Tkinter.Entry(frame0, textvariable=self.var1).pack(side='left', expand='yes', fill='x')
frame0.bind_all('<Any-KeyPress>',self.search_song_trigger)
frame=Tkinter.Frame(mainframe, bg='skyblue')
frame.pack(side='top')
self.list_box=Tkinter.Listbox(frame, bg='powderblue', font=list_box_song_list_font, width=list_box_width, height=list_box_height)
scrollbar=Tkinter.Scrollbar(frame, bg='skyblue')
scrollbar.pack(side='right',expand='yes',fill='y')
scrollbar.config(command=self.list_box.yview)
self.list_box.config(yscrollcommand=scrollbar.set)
self.list_box.pack(expand='yes',fill='both',side='right')
frame1=Tkinter.Frame(mainframe, bg='blue')
frame1.pack(side='top', expand='yes',fill='x')
add_fileicon=Tkinter.PhotoImage(file="../Icons/add_file.gif")
add_directoryicon=Tkinter.PhotoImage(file="../Icons/add_directory.gif")
list_file=[
(add_fileicon,'self.ask_for_play_song_direct'),
(add_directoryicon,'self.ask_for_directory'),
]
for i,j in list_file:
storeobj=Tkinter.Button(frame1, image=i, command=eval(j), bg='blue')
storeobj.pack(side='left')
storeobj.image=i
self.list_box.bind('<Double-Button-1>',self.play_on_click)
return self.update_list_box_songs()
示例9: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def __init__(self, master):
tk.Frame.__init__(self, master)
self.pack()
tk.Label(self, text="This is a listbox").pack()
list_items = ["This is a listbox!", 'Item 1', 'Item 2', 'Item 3', 'etc.']
self.listbox = tk.Listbox(self, selectmode='extended', bg='white')
self.listbox.pack(padx=10, pady=10)
for l in list_items:
self.listbox.insert('end', l)
tk.Button(self, text='OK', command=self.ok).pack()
开发者ID:brysontyrrell,项目名称:MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter,代码行数:17,代码来源:Tkinter_Widget_Examples.py
示例10: ok
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def ok(self):
selection = self.listbox.curselection()
value = ', '.join(self.listbox.get(x) for x in selection)
print('Listbox Selection: {} "{}"'.format(selection, value))
开发者ID:brysontyrrell,项目名称:MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter,代码行数:6,代码来源:Tkinter_Widget_Examples.py
示例11: demo
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def demo():
root = Tkinter.Tk(className='ToolTip-demo')
l = Tkinter.Listbox(root)
l.insert('end', "I'm a listbox")
l.pack(side='top')
t1 = ToolTip(l, follow_mouse=1, text="I'm a tooltip with follow_mouse set to 1, so I won't be placed outside my parent")
b = Tkinter.Button(root, text='Quit', command=root.quit)
b.pack(side='bottom')
t2 = ToolTip(b, text='Enough of this')
root.mainloop()
示例12: setupSubCommands
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def setupSubCommands(self):
self.optMap = {}
if hasattr(self.options, 'subCommands'):
self.commandFrame = f = Tkinter.Frame(self)
self.cmdList = Tkinter.Listbox(f)
for (cmd, _, opt, desc) in self.options.subCommands:
self.cmdList.insert(Tkinter.END, cmd)
self.optMap[cmd] = opt()
self.cmdList.pack()
self.subCmdPoll = reactor.callLater(0.1, self.pollSubCommands)
f.grid(row=1, column=3)
示例13: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def __init__(self, parent):
scrollbar = tk.Scrollbar(parent, orient=tk.VERTICAL)
self.listbox = tk.Listbox(parent, yscrollcommand=scrollbar.set, selectmode=tk.EXTENDED)
scrollbar.configure(command=self.listbox.yview)
self.listbox.pack(side=tk.LEFT,fill=tk.BOTH, expand=1, pady=5)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y, pady=5)
示例14: addListBox
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def addListBox(self, master, title):
scrollbar = tk.Scrollbar(master, orient=tk.VERTICAL)
tipLabel = tk.Label(master, text="")
tipLabel.grid(row = self.row, sticky=tk.W, column=self.tipColumn)
lb = tk.Listbox(master, yscrollcommand=scrollbar, selectmode=tk.EXTENDED, height=3)
self.listboxEntries[title] = ListBoxEntry(lb,scrollbar,tipLabel)
self.row += 1
self.listboxEntries[title].scrollbar.configure(command=self.listboxEntries[title].listbox.yview)
self.listboxEntries[title].scrollbar.grid(row=self.row, sticky=tk.W+tk.N+tk.S, column=self.titleColumn)
return self.listboxEntries[title]
示例15: addListBox
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Listbox [as 别名]
def addListBox(self, master, title, height = 3):
scrollbar = tk.Scrollbar(master, orient=tk.VERTICAL)
tipLabel = tk.Label(master, text="")
tipLabel.grid(row = self.row, sticky=tk.W, column=self.tipColumn)
lb = tk.Listbox(master, yscrollcommand=scrollbar, selectmode=tk.EXTENDED, height=height)
self.listboxEntries[title] = ListBoxEntry(lb,scrollbar,tipLabel)
self.row += 1
self.listboxEntries[title].scrollbar.configure(command=self.listboxEntries[title].listbox.yview)
self.listboxEntries[title].scrollbar.grid(row=self.row, sticky=tk.W+tk.N+tk.S, column=self.titleColumn)
return self.listboxEntries[title]