โดย Jom07 » 12/02/2018 5:37 pm
การใช้งาน Python GUI (Tkinter) :Sliders (สไลด์) เป็นการใช้แถบเลื่อนคือวัตถุ Tkinter ที่ผู้ใช้สามารถตั้งค่าโดยการเลื่อนตัวบ่งชี้ ตัวเลื่อนสามารถจัดเรียงในแนวตั้งหรือแนวนอนได้ แถบเลื่อนถูกสร้างขึ้นด้วยวิธี Scale () เช่น
ตัวอย่าง
โค้ด: เลือกทั้งหมด
from tkinter import *
def show_values():
print (w1.get(), w2.get())
master = Tk()
w1 = Scale(master, from_=0, to=50)
w1.set(19)
w1.pack()
w2 = Scale(master, from_=0, to=100, orient=HORIZONTAL)
w2.set(23)
w2.pack()
Button(master, text='Show', command=show_values).pack()
mainloop()
ผลรัน
ศึกษาจาก :
https://www.python-course.eu/tkinter_sliders.php
การใช้งาน Python GUI (Tkinter) :Sliders (สไลด์) เป็นการใช้แถบเลื่อนคือวัตถุ Tkinter ที่ผู้ใช้สามารถตั้งค่าโดยการเลื่อนตัวบ่งชี้ ตัวเลื่อนสามารถจัดเรียงในแนวตั้งหรือแนวนอนได้ แถบเลื่อนถูกสร้างขึ้นด้วยวิธี Scale () เช่น
[b]ตัวอย่าง[/b]
[code]from tkinter import *
def show_values():
print (w1.get(), w2.get())
master = Tk()
w1 = Scale(master, from_=0, to=50)
w1.set(19)
w1.pack()
w2 = Scale(master, from_=0, to=100, orient=HORIZONTAL)
w2.set(23)
w2.pack()
Button(master, text='Show', command=show_values).pack()
mainloop()
[/code]
[b]ผลรัน[/b]
[img]http://snap.mindphp.com/index.php?view=2018Feb12_5a816b394dcd7[/img]
ศึกษาจาก : https://www.python-course.eu/tkinter_sliders.php