optinmenu 选项菜单 scale 滑块
1、optinmenu 选项菜单
from tkinter import *
window = Tk()
window.geometry("500x200")
v = StringVar(window)
v.set('小涵')
optionmennu1 = OptionMenu(window, v, "小涵", "小绿", "小红")
optionmennu1["width"] = 10
optionmennu1.pack()
def text1():
print("你是:" + v.get())
Button(window, text="确定", command=text1).pack()
window.mainloop()
2、scale 滑块
from tkinter import *
window = Tk()
window.geometry("500x200")
def text1(value):
print("滑块的值:", value)
newFont = ("宋体", value)
a.config(font = newFont)
s1 = Scale(window, from_=10, to=50, length = 200, tickinterval = 5, orient = HORIZONTAL, command = text1 )
s1.pack()
a = Label(window, text="小涵", width=10, height=5, bg="black", fg="white")
a.pack()
window.mainloop()