-2
我在circel上有4个按钮,我想将按钮样式更改为椭圆形或圆形,以便将所有按钮都放入circel中!怎么能这样做?谢谢你的帮助!在Python上更改按钮样式2.7.9
我在circel上有4个按钮,我想将按钮样式更改为椭圆形或圆形,以便将所有按钮都放入circel中!怎么能这样做?谢谢你的帮助!在Python上更改按钮样式2.7.9
from Tkinter import Tk, W, E
from ttk import Frame, Button, Label, Style
from ttk import Entry
class AllButtons(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def callback(self, number):
print "click!", self, number
def initUI(self):
self.parent.title("mGUI")
Style().configure("TButton", padding=(0, 5, 0, 5),
font='serif 20', background="Black", foreground="red",
activebackground="Green,",activeforeground="Green")
self.columnconfigure(0, pad=3)
self.columnconfigure(1, pad=3)
self.columnconfigure(2, pad=3)
self.columnconfigure(3, pad=3)
self.rowconfigure(0, pad=3)
self.rowconfigure(1, pad=3)
self.rowconfigure(2, pad=3)
self.rowconfigure(3, pad=3)
self.rowconfigure(4, pad=3)
Funk_1 = Button(self, text="Funk_1", command=lambda:self.callback(1))
Funk_1.grid(row=1, column=0)
Funk_2 = Button(self, text="Funk_2", command=lambda:self.callback(2))
Funk_2.grid(row=1, column=1)
Funk_3 = Button(self, text="Funk_3", command=lambda:self.callback(3))
Funk_3.grid(row=1, column=3)
Funk_4 = Button(self, text="Funk_4", command=lambda:self.callback(4))
Funk_4.grid(row=3, column=0)
Funk_5 = Button(self, text="Funk_5", command=lambda:self.callback(5))
Funk_5.grid(row=3, column=1)
Funk_6 = Button(self, text="Funk_6", command=lambda:self.callback(6))
Funk_6.grid(row=3, column=3)
Funk_7 = Button(self, text="Funk_7", command=lambda:self.callback(7))
Funk_7.grid(row=5, column=0)
Funk_8 = Button(self, text="Funk_8", command=lambda:self.callback(8))
Funk_8.grid(row=5, column=1)
Funk_9 = Button(self, text="Funk_9", command=lambda:self.callback(9))
Funk_9.grid(row=5, column=3)
self.pack()
def main():
mGUI = Tk()
app = AllButtons(mGUI)
mGUI.mainloop()
if __name__ == '__main__':
main()
这不是一个答案。如果你想添加更多的信息到你的问题,你可以编辑问题。 –
您可以发布您的代码那么远?你使用什么GUI工具包? –
我发布了myCode!我想改变按钮1,3,7和9的样式,因为我有一个圆形的屏幕,我不能看到那些按钮的筛子,我想将它们拼接起来! (每个按钮只有一面) – Patrick
您是否在使用Tkinter? PyQt的? wxPython的? Kivy? ... –