การใช้งาน Python GUI (Tkinter) : การทำ ปุ่มกด Image

ตอบกระทู้

รูปแสดงอารมณ์
: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) : การทำ ปุ่มกด Image

การใช้งาน Python GUI (Tkinter) : การทำ ปุ่มกด Image

โดย Jom07 » 23/02/2018 4:46 pm

การใช้งาน Python GUI (Tkinter) : การทำ ปุ่มกด Image เป็นการสร้างปุ่มขึ้นเป็นรูปภาพ เช่น
ตัวอย่าง

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

from tkinter import *
from tkinter import ttk
rw = Tk()

b1=ttk.Button(rw, text="Click")
b1.pack()
mi = PhotoImage(file="md.png")
b1.config(image=mi, compound=RIGHT)

tmi = mi.subsample(5,5)
b1.config(image=tmi)
rw.mainloop()
ผลรัน

รูปภาพ

จะสามารถกดคลิกได้

ข้างบน