TypeError: in method 'new_Dialog', expected argument 1 of type 'wxWindow *'
<p>I am trying to build a file browser that uses SSH to browse files in a remote location. My GUI code keeps throwing one error or another at me so I can't even test the SSH portion (not included in below code). My current error seems to be a problem with either my class constructor or the way I call it [SSHFileDialog]. I'd greatly appreciate it if someone could point out where I've gone wrong here. My knowledge of Python is self-taught and I've only recently started coding GUIs with wxPython.</p>

<p>Code:</p>

<pre><code>import wx,os

class SSHFileDialog(wx.Dialog): #, hostname = 'DefaultHost', username = 'DefaultUser', password = 'Password'

    def __init__(self, parent):
        super(SSHFileDialog, self).__init__(self, parent, -1, style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
        # self.hostname = kwargs['hostname']
        # self.username = kwargs['username']
        # self.password = kwargs['password']
        hostname = "Host"
        username = "User"
        self.SetMinSize((512,512))
        self.Centre()
        self.SetTitle("Remote File Browser: Connection established to %s as %s"% (hostname,username))
        #print password
        self.InitUI()

    def InitUI(self):

        currentDir = os.getcwd() #For Testing
        fileAttr = [("Test","Test","Test","Test")] #Need to get file attributes from all files/folders in directory: Name, Type, Size, ModDate

        pnl = wx.Panel(self)
        vbox =  wx.BoxSizer(wx.VERTICAL)

        h_Dir_Box = wx.BoxSizer(wx.HORIZONTAL)
        st_Dir = wx.StaticText(self, label = currentDir,style=wx.ALIGN_LEFT)
        btn_Back = wx.Button(self,label = 'Back')
        h_Dir_Box.Add(st_Dir,flag=wx.ALL, border = 5)
        h_Dir_Box.Add(btn_Back)


        stbox = wx.StaticBox(pnl, wx.ID_ANY, "Directory Contents")
        stboxS = wx.StaticBoxSizer(stbox, orient = wx.HORIZONTAL)
        list = wx.ListCtrl(stbox, style = wx.LC_REPORT|wx.LC_VRULES|wx.LC_SINGLE_SEL)
        list.InsertColumn(0,'Filename',width = 175)
        list.InsertColumn(1,'Type', width = 100)
        list.InsertColumn(2,'Size', width = 75)
        list.InsertColumn(3,'Date Modified',wx.LIST_FORMAT_RIGHT, 90)

        for i in fileAttr:
            index = list.InsertStringItem(len(fileAttr)+10,i[0])
            list.SetStringItem(index,1,i[1])
            list.SetStringItem(index,2,i[2])
            list.SetStringItem(index,3,i[3])

        pnl.SetSizer(stboxS)


        h_Open_Box = wx.BoxSizer(wx.HORIZONTAL)
        btn_Open = wx.Button(self, label = 'Open')
        btn_Can = wx.Button(self, label = 'Cancel')
        h_Open_Box.Add(btn_Open)
        h_Open_Box.Add(btn_Can,flag = wx.LEFT,border=10)


        vbox.Add(h_Dir_Box, flag=wx.ALL|wx.EXPAND, border = 10)
        vbox.Add(pnl, proportion =1 , flag=wx.ALL|wx.EXPAND|wx.ALIGN_CENTER, border = 20)
        vbox.Add(h_Open_Box, flag = wx.ALIGN_RIGHT)

        self.SetSizer(vbox)

        btn_Open.Bind(wx.EVT_BUTTON, self.OnClose)
        btn_Can.Bind(wx.EVT_BUTTON, self.OnClose)

    def OnClose(self,e):
        self.Destroy()


class TestGui(wx.Frame):

    def __init__(self,*args,**kwargs):
        super(TestGui,self).__init__(*args,**kwargs)

        self.InitUI()

    def InitUI(self):

        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        openFileItem = fileMenu.Append(wx.ID_OPEN,'&amp;Open')
        fileMenu.AppendSeparator()

        quitApp = fileMenu.Append(wx.ID_EXIT, "&amp;Quit\tCtrl+Q")

        menubar.Append(fileMenu, '&amp;File')

        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU,self.OnQuit,quitApp)
        self.Bind(wx.EVT_MENU,self.OnOpen,openFileItem)

        self.SetSize((500,500))
        self.SetTitle('File Manager example')
        self.Centre()
        self.Show(True)

    def OnQuit(self,e):
        self.Close()

    def OnOpen(self,e):
        args = {'hostname':'Host','username':'user','password':'password'}
        fileDialog = SSHFileDialog(None)
        fileDialog.ShowModal()
        fileDialog.Destroy()

def main():
    app = wx.App()
    TestGui(None)
    app.MainLoop()

if __name__ == '__main__':
    main()
</code></pre>

<p>Traceback:</p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\matthersa\Desktop\XML-Python Testing\SSHFileDialog.py", line 103, in OnOpen
    fileDialog = SSHFileDialog(None)
  File "C:\Users\matthersa\Desktop\XML-Python Testing\SSHFileDialog.py", line 6, in __init__
    super(SSHFileDialog, self).__init__(self, parent, -1, style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_windows.py", line 734, in __init__
    _windows_.Dialog_swiginit(self,_windows_.new_Dialog(*args, **kwargs))
TypeError: in method 'new_Dialog', expected argument 1 of type 'wxWindow *'
</code></pre>

<p>you are likely working off an old tutorial</p>

<pre><code>wx.Dialog.__init__(self,*args,**kwargs) #here you need self, as this does not pass self implicitly
</code></pre>

<p>whereas </p>

<pre><code>super(MyDialogClass,self).__init__(*args,**kwargs) # here self is passed implicitly (eg you do not pass self as the first arg)
</code></pre>

<p>however you should be a little careful with <code>super</code> and wxPython iirc there are some base classes that do not inherit from <code>object</code> which causes the MRO to break ... (tbh its probably fixed by now)</p>

<p>** TLDR; **</p>

<p>change </p>

<pre><code>super(SSHFileDialog, self).__init__(self, parent, -1, style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
</code></pre>

<p>to </p>

<pre><code>super(SSHFileDialog, self).__init__( parent, -1, style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
</code></pre>

<hr>

<p>to answer your other question from the comments</p>

<pre><code>class SSHFileDialog(wx.Dialog): #, hostname = 'DefaultHost', username = 'DefaultUser', password = 'Password'

    def __init__(self, parent,host,username,password):
        self.ssh_thing = SSHClient(host,username,password)
        super(SSHFileDialog, self).__init__(self, parent, -1, style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
</code></pre>

python user-interface inheritance wxpython