การใช้งาน Python GUI (Tkinter) :Menus (เมนู)

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้งาน Python GUI (Tkinter) :Menus (เมนู)

การใช้งาน Python GUI (Tkinter) :Menus (เมนู)

โดย 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

ข้างบน