2012-03-11 30 views
2

私はpythonでguiに問題があり、プログラムはボタンの自動作成からコマンドオプションを実行します。だから私はループで立ち往生している。このような ''」あなたはコマンドをリンクすると は、5-mrt. - 2012年Python GUI with Tkinter

@author: Max 
''' 
from Tkinter import * 


class main(Tk): 
    def __init__(self,parent): 
     self.mainWindow() 
    def mainWindow(self): 
     '''Make the main window ''' 
     self.quitAll() 
     self.app = Tk() 
     self.app.title('NMBS application') 
     self.makeAppButtons() 
     self.finish(self.app) 
    def makeAppButtons(self): 
     '''Make all the buttons for the main menu''' 
     button_lijn = Button(self.app, text="Voeg lijnritten toe", command = self.lijnritten()) 
     button_lijn.pack() 
    def finish(self,window): 
     ''' Make the main window''' 
     window.mainloop() 
    def endButton(self,window): 
     '''Make a quit button''' 
     button_back = Button(window,text="Sluiten",command = self.mainWindow()) 
     button_back.pack() 
    def quitAll(self): 
     '''Close all the current windows''' 
     self.lijn_window.quit() 
     self.app.quit() 
    def lijnritten(self): 
     ''' Make the lijnritten window''' 
     self.app.quit() 
     self.lijn_window = Tk() 
     self.lijn_window.title("lijnritten") 
     self.endButton(self.lijn_window) 
     self.finish(self.lijn_window) 
main(None) 
+0

あなたは '' '' '' '' ''の代わりに'#so'のような一行のコメントを行うことができます。 –

+2

@Alex、彼はそれを正しくやっています。その位置にある文字列は、関数のヘルプテキスト( "docstring")になります。 – alexis

+0

@alexis - ああ、右 - それを知らなかった:) –

答えて

1

を作成し、(なしにそれを行う)のでcommand=self.action、。また、この行はあなたにいくつかの問題を与えているようですself.quitAll() ...あなたがそれをどうしようとしているのかは分かりませんが、それは私の2セントです。

''' 
Created on 5-mrt.-2012 
@author: Max 
''' 
from Tkinter import * 


class main(Tk): 
    def __init__(self,parent): 
     self.mainWindow() 
    def mainWindow(self): 
     '''Make the main window ''' 
     #self.quitAll() 
     self.app = Tk() 
     self.app.title('NMBS application') 
     self.makeAppButtons() 
     self.finish(self.app) 
    def makeAppButtons(self): 
     '''Make all the buttons for the main menu''' 
     button_lijn = Button(self.app, text="Voeg lijnritten toe", command = self.lijnritten) 
     button_lijn.pack() 
    def finish(self,window): 
     ''' Make the main window''' 
     window.mainloop() 
    def endButton(self,window): 
     '''Make a quit button''' 
     button_back = Button(window,text="Sluiten",command = self.mainWindow) 
     button_back.pack() 
    def quitAll(self): 
     '''Close all the current windows''' 
     self.lijn_window.quit() 
     self.app.quit() 
    def lijnritten(self): 
     ''' Make the lijnritten window''' 
     self.app.quit() 
     self.lijn_window = Tk() 
     self.lijn_window.title("lijnritten") 
     self.endButton(self.lijn_window) 
     self.finish(self.lijn_window) 
main(None) 
関連する問題