1

Why is this wxpython code giving me the following error?

self.Bind(wx.EVT_MENU,self.onNewFile,self.New_File)

def onNewFile(self,evt):

    wx.FileDialog(None,'Choose a file',os.getcwd(),"",wx.OPEN)
    if dialog.ShowModal() == wx.ID_OK:
        print dialog.GetPath()
    dialog.Destroy()

Other codes to set up menubar and create items are there but when this is executed I get the following error:

Traceback (most recent call last):
  File "C:\Python27\Front_End.py", line 52, in onNewFile
    wx.FileDialog(None,'Choose a file',os.getcwd(),"",wx.OPEN)
  File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", line 2430, in __init__
    _windows_.FileDialog_swiginit(self,_windows_.new_FileDialog(*args, **kwargs))
TypeError: String or Unicode type required

What does this mean?

1 Answer 1

2

wx.FileDialog prototype is below

__init__(self, parent, id, title, pos, size, style, name)

you may miss one parameter. I also edit your code a bit as following.

def onNewFile(self,evt):

    dialog = wx.FileDialog(None,'Choose a file',os.getcwd(),"", "",wx.OPEN)
    if dialog.ShowModal() == wx.ID_OK:
        print dialog.GetPath()
    dialog.Destroy()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.