2015-05-03 115 views
-2

我在circel上有4個按鈕,我想將按鈕樣式更改爲橢圓形或圓形,以便將所有按鈕都放入circel中!怎麼能這樣做?謝謝你的幫助!在Python上更改按鈕樣式2.7.9

+0

您可以發佈您的代碼那麼遠?你使用什麼GUI工具包? –

+0

我發佈了myCode!我想改變按鈕1,3,7和9的樣式,因爲我有一個圓形的屏幕,我不能看到那些按鈕的篩子,我想將它們拼接起來! (每個按鈕只有一面) – Patrick

+0

您是否在使用Tkinter? PyQt的? wxPython的? Kivy? ... –

回答

-1
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() 

+0

這不是一個答案。如果你想添加更多的信息到你的問題,你可以編輯問題。 –