โดย Jom07 » 13/02/2018 4:18 pm
การใช้งาน Python GUI (Tkinter) :Menus (เมนู) เป็นสคริปต์ Python สร้างหน้าต่างแอ็พพลิเคชันแบบง่ายพร้อมด้วยเมนู เช่น
ตัวอย่าง
โค้ด: เลือกทั้งหมด
from tkinter import *
def doNothing():
print ("ok I won't..")
root = Tk()
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=doNothing)
filemenu.add_command(label="Open...", command=doNothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=doNothing)
helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=doNothing)
mainloop()
ผลรัน
ศึกษาจาก :
https://www.python-course.eu/tkinter_menus.php
การใช้งาน Python GUI (Tkinter) :Menus (เมนู) เป็นสคริปต์ Python สร้างหน้าต่างแอ็พพลิเคชันแบบง่ายพร้อมด้วยเมนู เช่น
[b]ตัวอย่าง[/b]
[code]from tkinter import *
def doNothing():
print ("ok I won't..")
root = Tk()
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=doNothing)
filemenu.add_command(label="Open...", command=doNothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=doNothing)
helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=doNothing)
mainloop()
[/code]
[b]ผลรัน[/b]
[img]http://snap.mindphp.com/index.php?view=2018Feb13_5a82aa5baab45[/img]
ศึกษาจาก : [url]https://www.python-course.eu/tkinter_menus.php[/url]