หน้า 1 จากทั้งหมด 1

การใช้งาน Python GUI (Tkinter) :Entry Widgets ( วิดเจ็ตรายการ)

โพสต์แล้ว: 12/02/2018 4:41 pm
โดย Jom07
การใช้งาน Python GUI (Tkinter) :Entry Widgets ( วิดเจ็ตรายการ) เป็นการสร้างหน้าาต่างให้ราสามารถกรอกข้อมูลและเก็บข้อมูลได้ เช่น

โค้ด: เลือกทั้งหมด

from tkinter import *

def show_entry_fields():
   print("First Name: %s\nLast Name: %s" % (e1.get(), e2.get()))

master = Tk()
Label(master, text="First Name").grid(row=0)
Label(master, text="Last Name").grid(row=1)

e1 = Entry(master)
e2 = Entry(master)

e1.grid(row=0, column=1)
e2.grid(row=1, column=1)

Button(master, text='Quit', command=master.quit).grid(row=3, column=0, sticky=W, pady=4)
Button(master, text='Show', command=show_entry_fields).grid(row=3, column=1, sticky=W, pady=4)

mainloop( )
ผลรัน

รูปภาพ


ศึกษาจาก : https://www.python-course.eu/tkinter_entry_widgets.php