2016-10-06 1 views
0

次は、簡単なGUIのprogrammです。しかし、batファイルから開こうとすると、エラーが発生します。Python、コードは動作しますが、batファイルで開くエラーが発生します

BATファイル(2行):

ch10.2.py 
pause 

Iは受信エラーがある:

[ここに含まれるテキスト形式のエラーメッセージ]

マイコード:

# Lazy Buttons 2 
# Demonstrates using a class with Tkinter 

from tkinter import * 

class Application(Frame): 
    """ A GUI application with three buttons. """ 
    def __init__(self, master): 
     """ Initialize the Frame. """ 
     super(Application, self).__init__(master)  
     self.grid() 
     self.create_widgets() 

    def create_widgets(self): 
     """ Create three buttons that do nothing. """ 
     # create first button 
     self.bttn1 = Button(self, text = "I do nothing!") 
     self.bttn1.grid() 

     # create second button 
     self.bttn2 = Button(self) 
     self.bttn2.grid() 
     self.bttn2.configure(text = "Me too!") 

     # create third button 
     self.bttn3 = Button(self) 
     self.bttn3.grid() 
     self.bttn3["text"] = "Same here!" 

# main 
root = Tk() 
root.title("Lazy Buttons 2") 
root.geometry("200x85") 
app = Application(root) 
root.mainloop() 
+5

はエラーは何ですか?そして、あなたがエラーなくそれを実行するために使用する正確なコマンドは何ですか?2.xと3.xの両方がインストールされていますか? –

+2

投稿にスクリーンショットのテキストを含めないでください。ここに実際のエラーを貼り付けてください。 –

+2

あなたの主なインタプリタはPython 3.5ではないでしょうか? 2.7かそれ以上の年齢? – Broly

答えて

0

super(Application, self).__init__(master)でエラーが発生しています。
Frame.__init__(self, master)と交換すると、動作します。

# Lazy Buttons 2 
# Demonstrates using a class with Tkinter 

from tkinter import * 

class Application(Frame): 
    """ A GUI application with three buttons. """ 

    def __init__(self, master): 
     """ Initialize the Frame. """  
     Frame.__init__(self, master) 
     #super(Application, self).__init__(master) 
     self.grid() 
     self.createWidgets() 




    def createWidgets(self): 
     """ Create three buttons that do nothing. """ 
     # create first button 
     self.bttn1 = Button(self, text = "I do nothing!") 
     self.bttn1.grid() 

     # create second button 
     self.bttn2 = Button(self) 
     self.bttn2.grid() 
     self.bttn2.configure(text = "Me too!") 

     # create third button 
     self.bttn3 = Button(self) 
     self.bttn3.grid() 
     self.bttn3["text"] = "Same here!" 


# main 
root = Tk() 
root.title("Lazy Buttons 2") 
root.geometry("200x85") 
app = Application(root) 
root.mainloop() 

下記参照OUTPUT
enter image description here

+0

ありがとうございました。これは2.7バージョンと3.5バージョンがありました) – Grigorie

関連する問題