Python Tkinter Listbox 全方位指南
1. 简单 Listbox 示例
以下是一个简单的 Listbox 示例代码:
import tkinter
class ListboxExample:
def __init__(self):
# Create the main window.
self.main_window = tkinter.Tk()
# Create a Listbox widget.
self.listbox = tkinter.Listbox(
self.main_window, height=0, width=0)
self.listbox.pack(padx=10, pady=10)
# Create a list with the days of the week.
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday',
'Sunday']
# Populate the Listbox with the data.
for day in days:
self.listbox.insert(tkinter.END, day)
# Start the main loop.
tkinter.mainloop(
超级会员免费看
订阅专栏 解锁全文
761

被折叠的 条评论
为什么被折叠?



