現在、Anacondaで入れたPythonをJupyter Notebookでプログラムを書いているのですが、他の人にも使えるようにGUIにしたいと考え、wxPythonを使用してGUI化しようとしています。ですが、サンプルのコードを動かしても、1回目は動くのですが、ウィンドウを消して2回目を実行するとエラーが出てきます。
コードとしては以下のようなものです
Python
1import wx 2 3class CustomFrame(wx.Frame): 4 5 def __init__(self,title): 6 wx.Frame.__init__(self,None,-1,title,size=(300, 300)) 7 8 Layout = wx.BoxSizer(wx.VERTICAL) 9 Layout.Add(wx.Button(self, wx.ID_OPEN))#, pos=(10, 10)) 10 Layout.Add(wx.Button(self, wx.ID_CLOSE))#, pos=(10, 40)) 11 Layout.Add(wx.Button(self, wx.ID_NEW))#, pos=(10, 70)) 12 Layout.Add(wx.Button(self, wx.ID_SAVE))#, pos=(10, 100)) 13 Layout.Add(wx.Button(self, wx.ID_HELP))#, pos=(10, 130)) 14 15 self.SetSizer(Layout) 16 17 self.Show() 18 19app = wx.App() 20CustomFrame('ID_RESERVED') 21app.MainLoop()
エラーは
PyNoAppError Traceback (most recent call last) <ipython-input-2-1abc047522f8> in <module>() 18 19 app = wx.App() ---> 20 CustomFrame('ID_RESERVED') 21 app.MainLoop() <ipython-input-2-1abc047522f8> in __init__(self, title) 4 5 def __init__(self,title): ----> 6 wx.Frame.__init__(self,None,-1,title,size=(300, 300)) 7 8 Layout = wx.BoxSizer(wx.VERTICAL) PyNoAppError: The wx.App object must be created first!
となっています。
これはどうして起きているのでしょうか?
また、JupyerNotebookで作製したPythonファイル(.ipynbファイル)をpyinstallerを使用してexe化しようとしたのですが、Fail to execute script ファイル名となり実行できません。この理由がわからないのですが、なぜなのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/11 08:15
2019/01/11 08:19
2019/01/11 08:28 編集
2019/01/11 09:28