import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
win = tk.Tk()
win.title("Python组件演示!!!")
##标签框架容器
monty = ttk.LabelFrame(win, text="标签框架")
monty.grid(column=10, row=0, padx=10, pady=10)
aLabel = ttk.Label(monty, text="A Label!!!") ##没明白这句话是什么意思,跟结果好像没有什么关系
ttk.Label(monty, text="请选择一个数字:").grid(column=1, row=0) ##不定义为对象可以么
##按键
def ClickMe():
action.configure(text='Hello'+' '+numberChosen.get())
action = ttk.Button(monty, text="单击我", command=ClickMe)
action.grid(column=2, row=1)
##下拉列表框
num = tk.StringVar()
numberChosen = ttk.Combobox(monty, width=12, textvariable=num, state='readonly')
numberChosen['values'] = (1, 2, 3, 4, 5)
numberChosen.grid(column=1, row=1)
numberChosen.current(0)
##滚动文本框
scrolW = 30
scrolH = 3
scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH)
scr.grid(column=0, columnspan=3)
win.mainloop()