Python GUI编程(Tkinter)Menu顶层菜单
import tkinterwin = tkinter.Tk()win.title("sunck")win.geometry("400x400+200+20")#菜单条menubar = tkinter.Menu(win)win.config(menu=menubar)def func(): print("sunck is a good man")#创建一个菜单选项menu1 = tkinter.Menu(menubar, tearoff=False)#给菜单选项添加内容for item in ["Python", "C", "C++", "OC", "Swift", "C#", "shell", "Java", "JS", "PHP", "汇编", "NodeJS", "退出"]: if item == "退出": #添加分隔线 menu1.add_separator() menu1.add_command(label=item, command=win.quit) else: menu1.add_command(label=item, command=func)#向菜单条上添加菜单选项menubar.add_cascade(label="语言", menu=menu1)menu2 = tkinter.Menu(menubar, tearoff=False)menu2.add_command(label="red")menu2.add_command(label="blue")menubar.add_cascade(label="颜色", menu=menu2)win.mainloop()
相关推荐
ITxiaobaibai 2020-02-19
Wendywubowen 2019-06-14
oXiRiShi 2019-06-13
AndroidAmelia 2020-05-19
lsjweiyi 2020-11-17
kikaylee 2020-05-31
singer 2020-05-07
Jonderwu 2020-05-07
xirongxudlut 2020-05-07
柠檬班 2020-02-03
chouliqingke 2019-12-24
liusarazhang 2019-10-29
canvaskin 2019-06-14
lanzh 2019-06-14
xavierri 2019-06-14
vevoly 2019-06-14
BmwGaara 2019-06-14
pythonxuexi 2019-06-14
ciqingloveless 2019-06-13