この単純な wxpytohn スクリプトで次のエラーが発生します。何が問題なのですか? エラーメッセージは、スクリプトでエラーが発生した行を示していません。
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\spyderlib\plugins\externalconsole.py", line 721, in run_script_in_current_shell
"and try again.") % osp.basename(filename), QMessageBox.Ok)
File "c:\Python27\lib\ntpath.py", line 198, in basename
return split(p)[1]
File "c:\Python27\lib\ntpath.py", line 173, in split
while i and p[i-1] not in '/\\':
TypeError: 'in <string>' requires string as left operand, not QString
これはスクリプトです:
import wx
import os
def getParentFolder():
moduleFile = __file__
moduleDir = os.path.split(os.path.abspath(moduleFile))[0]
programFolder = os.path.abspath(moduleDir)
parentFolder = os.path.abspath(os.path.join(programFolder, os.pardir))
return programFolder, parentFolder
class MainWindow(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, title=title, pos=(150,150), size=(1200,900))
#self.Bind(wx.EVT_CLOSE, self.closeWindow)
self.SetIcon(wx.Icon("plane.ico", wx.BITMAP_TYPE_ICO))
self.Center()
icons_folder = getParentFolder()[1]
menubar = wx.MenuBar()
scenario_menu = wx.Menu()
database_menu= wx.Menu()
settings_menu = wx.Menu()
open_scenario = wx.MenuItem(scenario_menu, 101, '&Open\tCtrl+O', 'Open an existing scenario')
open_scenario.SetIcon((wx.Icon(icons_folder+"\\open_dir.ico", wx.BITMAP_TYPE_ICO)))
scenario_menu.AppendItem(open_scenario)
scenario_menu.Append(102, "&Create", "Create new scenario")
scenario_menu.Append(103, "&Save", "Save scenario")
menubar.Append(scenario_menu, "&File")
menubar.Append(database_menu, "&Database")
menubar.Append(settings_menu, "&Settings")
if __name__ == "__main__":
app = wx.App()
frame = MainWindow("CrewOpt")
frame.Show()
app.MainLoop()