2016-08-20 198 views
1

可以從圖像或圖標 這樣 enter image description hereTkinter的創建自定義按鈕

enter image description here

的Tkinter有正常的按鈕,我不想添加圖像按鈕 我想創建一個新的按鈕或樣式Tkinter的自定義按鈕enter image description here

+0

是的,您可以創建帶圖片和文字的按鈕,或者只是圖片,帶或不帶凸起的邊框,以及任何你想要的顏色。這些都記錄在按鈕小部件的選項中。 –

回答

6

這是可能的!

如果您查看button documentation,您可以使用圖像顯示在按鈕上。

例如:

from tkinter import * 

root = Tk() 

button = Button(root, text="Click me!") 
img = PhotoImage(file="C:/path to image/example.gif") # make sure to add "/" not "\" 
button.config(image=img) 
button.pack() # Displaying the button 

root.mainloop() 

這是用於添加圖像按鈕控件一個簡單的例子,你可以用按鈕控件讓更多的很酷的事情。