Silly little wx.Dialog type error. any ideas?

Hello, I have been staring at this section for too long and i cant work out why it keep throwing type errors. It's an example of some code from a larger app where i want to create a simple dialog and add some text to it.

I create my own dialog class here so that i can overide its init method with my own and add some wx.widget text to it.
But when i try to create the text it throws an error and tells me that it expects argument 1 to be of type. 'wxWindow *'

Anyway, here is the code. (All the code)

#### Code Start ####################

import wx
app = wx.PySimpleApp()

class newdialog(wx.Dialog):
    def __init__(self):
        label = wx.StaticText(self, -1, "New Project") #gives TypeError
        print 'foo'

ND = newdialog()
#ND.Show(True) #gives type error

## code End #################

and this is the exact error message i get when i try to run the code:

···

----------------------------------------------------------------
Traceback (most recent call last):
  File "X:/Programing/Inhouse/Pipeline/GUI/TreeView/misc/SimpleDialog.py", line 11, in <module>
    ND = newdialog()
  File "X:/Programing/Inhouse/Pipeline/GUI/TreeView/misc/SimpleDialog.py", line 8, in __init__
    label = wx.StaticText(self, -1, "New Project")
  File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 1135, in __init__
    _controls_.StaticText_swiginit(self,_controls_.new_StaticText(*args, **kwargs))
TypeError: in method 'new_StaticText', expected argument 1 of type 'wxWindow *'
---------------------------------------------------------------------------

Thanks for any insights guys! If this works in this small example i hope to use it in my larger wx app.

Mark

You forgot to call the parent's constructor first. Use
      wx.Dialog(self, None, -1)
in __init__ before the StaticText constructor

Phil

···

At 05:20 PM 2/6/2007, you wrote:

Hello, I have been staring at this section for too long and i cant work out why it keep throwing type errors. It's an example of some code from a larger app where i want to create a simple dialog and add some text to it.

I create my own dialog class here so that i can overide its init method with my own and add some wx.widget text to it.
But when i try to create the text it throws an error and tells me that it expects argument 1 to be of type. 'wxWindow *'

Anyway, here is the code. (All the code)

#### Code Start ####################

import wx
app = wx.PySimpleApp()

class newdialog(wx.Dialog):
   def __init__(self):
       label = wx.StaticText(self, -1, "New Project") #gives TypeError
       print 'foo'

ND = newdialog()
#ND.Show(True) #gives type error

## code End #################

and this is the exact error message i get when i try to run the code:
----------------------------------------------------------------
Traceback (most recent call last):
File "X:/Programing/Inhouse/Pipeline/GUI/TreeView/misc/SimpleDialog.py", line 11, in <module>
   ND = newdialog()
File "X:/Programing/Inhouse/Pipeline/GUI/TreeView/misc/SimpleDialog.py", line 8, in __init__
   label = wx.StaticText(self, -1, "New Project")
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 1135, in __init__
   _controls_.StaticText_swiginit(self,_controls_.new_StaticText(*args, **kwargs))
TypeError: in method 'new_StaticText', expected argument 1 of type 'wxWindow *'
---------------------------------------------------------------------------

Thanks for any insights guys! If this works in this small example i hope to use it in my larger wx app.

Mark

Ah.. I was looking at an example dialog that did not use a constructor like you suggested but instead used the following.

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)
        self.PostCreate(pre)

if i had have used this my code would also have worked.. both your suggestion and this one worked fine.

Thanks for your help.

Mark

Phil Mayes wrote:

···

At 05:20 PM 2/6/2007, you wrote:

Hello, I have been staring at this section for too long and i cant work out why it keep throwing type errors. It's an example of some code from a larger app where i want to create a simple dialog and add some text to it.

I create my own dialog class here so that i can overide its init method with my own and add some wx.widget text to it.
But when i try to create the text it throws an error and tells me that it expects argument 1 to be of type. 'wxWindow *'

Anyway, here is the code. (All the code)

#### Code Start ####################

import wx
app = wx.PySimpleApp()

class newdialog(wx.Dialog):
   def __init__(self):
       label = wx.StaticText(self, -1, "New Project") #gives TypeError
       print 'foo'

ND = newdialog()
#ND.Show(True) #gives type error

## code End #################

and this is the exact error message i get when i try to run the code:
----------------------------------------------------------------
Traceback (most recent call last):
File "X:/Programing/Inhouse/Pipeline/GUI/TreeView/misc/SimpleDialog.py", line 11, in <module>
   ND = newdialog()
File "X:/Programing/Inhouse/Pipeline/GUI/TreeView/misc/SimpleDialog.py", line 8, in __init__
   label = wx.StaticText(self, -1, "New Project")
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 1135, in __init__
   _controls_.StaticText_swiginit(self,_controls_.new_StaticText(*args, **kwargs))
TypeError: in method 'new_StaticText', expected argument 1 of type 'wxWindow *'
---------------------------------------------------------------------------

Thanks for any insights guys! If this works in this small example i hope to use it in my larger wx app.

Mark

You forgot to call the parent's constructor first. Use
     wx.Dialog(self, None, -1)
in __init__ before the StaticText constructor

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org