2016-08-20 156 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() 

这是用于添加图像按钮控件一个简单的例子,你可以用按钮控件让更多的很酷的事情。