Newbie banging head against wall (simple wxDialog problem)

I can't get these three lines to work:

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

app=LoginDlg(0)
app.MainLoop()

···

-------------------------------------------------------------
Traceback (most recent call last):
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 43, in ?
    app=LoginDlg(0)
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 5, in __init__
    wxDialog.__init__(self, parent, -1, "Login")
  File "C:\PYTHON22\lib\site-packages\wxPython\frames.py", line 199, in
__init__
    self.this = apply(framesc.new_wxDialog,_args,_kwargs)
TypeError: Type error in argument 1 of new_wxDialog. Expected _wxWindow_p.

And why do I need a 0 passed into LoginDlg?
I'd like better documentation. Currently, I search the wxPython site looking
for something similar to what I'm trying to do, then I check the wxWindows
site. I'm also using IDLE. There's got to be a better way to learn this!
Please tell me I'm right!

Many thanks for your help!

First of all, you need a wxApp, and second, parent is not a global
variable. Since this is a top level window, just make the
parent=None

···

--- Jason Hihn <jhihn@paytimepayroll.com> wrote:

I can't get these three lines to work:

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

app=LoginDlg(0)
app.MainLoop()

=======
from wxPython.wx import *
class LoginDlg(wxDialog):
    def __init__(self):
        wxDialog.__init__(self, parent=None, -1, "Login")

class MyApp(wxApp):
    def OnInit(self):
        dlg = LoginDlg()
        dlg.Show(1)
        return 1

app = MyApp(0)
app.MainLoop()

=====
Donnal Walter
Arkansas Children's Hospital

I can't get these three lines to work:

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

app=LoginDlg(0)
app.MainLoop()

You need to have a wxApp instance (that's also the one getting the 0 )

Try something like:

from wxPython.wx import *

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

class MyFrame(wxFrame):
    def __init__(self, parent, id, title,
                 pos = wxPyDefaultPosition, size = wxPyDefaultSize,
                 style = wxDEFAULT_FRAME_STYLE ):
        wxFrame.__init__(self, parent, id, title, pos, size, style)

    def login(self):
  _dlg=LoginDlg(self)
  _dlg.CentreOnParent()
  _dlg.ShowModal()

class MyApp(wxApp):
    def OnInit(self):
        frame=MyFrame(None, -1, "Main Application", wxPoint(20,20),
wxSize(280,130) )
        frame.login()
        frame.Show()
        return 1

app=MyApp(0)
app.MainLoop()

Get the difference ?

BTW the 0 means "don't redirect stderr and stdout". So when you call it in a
shell (or cmd) you'll see all the messages in there (like print statements
and tracebacks)
If you put a 1 you'll get a window with the output.
If you put a MyApp(1,filename='log.txt') - ok you guessed that - the output
will be in the file log.txt in the current directory

Hope that helps

  UC

···

On Thursday 23 January 2003 11:17 am, Jason Hihn wrote:

-------------------------------------------------------------
Traceback (most recent call last):
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 43, in ?
    app=LoginDlg(0)
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 5, in __init__
    wxDialog.__init__(self, parent, -1, "Login")
  File "C:\PYTHON22\lib\site-packages\wxPython\frames.py", line 199, in
__init__
    self.this = apply(framesc.new_wxDialog,_args,_kwargs)
TypeError: Type error in argument 1 of new_wxDialog. Expected _wxWindow_p.

And why do I need a 0 passed into LoginDlg?
I'd like better documentation. Currently, I search the wxPython site
looking for something similar to what I'm trying to do, then I check the
wxWindows site. I'm also using IDLE. There's got to be a better way to
learn this! Please tell me I'm right!

Many thanks for your help!

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

--
  UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

Hi,

site. I'm also using IDLE. There's got to be a better way to learn this!

I like the Hapdebugger a lot better than IDLE. It has more of the feel of
Visual C that I am used to. You can get this from sourceforge.

-Rick King
Southfield MI USA

Thanks everyone!

I wasn't completely honest with the code I presented. This dialog is part of
a project, and I wanted to test it separately. So I had a wxApp elsewhere,
but thanks for reminding me that I left that part out.

Next up, is I'm trying to use a sizer to arrange stuff in the wxDialog, but
apparently, it doesn't have SetSizer() even though it's abstracted from
wxWindow...

How am I to arrange controls in dialogs?

···

-----Original Message-----
From: Uwe C. Schroeder [mailto:uwe@oss4u.com]
Sent: Thursday, January 23, 2003 2:51 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Newbie banging head against wall (simple
wxDialog problem)

On Thursday 23 January 2003 11:17 am, Jason Hihn wrote:

I can't get these three lines to work:

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

app=LoginDlg(0)
app.MainLoop()

You need to have a wxApp instance (that's also the one getting the 0 )

Try something like:

from wxPython.wx import *

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

class MyFrame(wxFrame):
    def __init__(self, parent, id, title,
                 pos = wxPyDefaultPosition, size = wxPyDefaultSize,
                 style = wxDEFAULT_FRAME_STYLE ):
        wxFrame.__init__(self, parent, id, title, pos, size, style)

    def login(self):
  _dlg=LoginDlg(self)
  _dlg.CentreOnParent()
  _dlg.ShowModal()

class MyApp(wxApp):
    def OnInit(self):
        frame=MyFrame(None, -1, "Main Application", wxPoint(20,20),
wxSize(280,130) )
        frame.login()
        frame.Show()
        return 1

app=MyApp(0)
app.MainLoop()

Get the difference ?

BTW the 0 means "don't redirect stderr and stdout". So when you call it in a
shell (or cmd) you'll see all the messages in there (like print statements
and tracebacks)
If you put a 1 you'll get a window with the output.
If you put a MyApp(1,filename='log.txt') - ok you guessed that - the output
will be in the file log.txt in the current directory

Hope that helps

  UC

-------------------------------------------------------------
Traceback (most recent call last):
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 43, in ?
    app=LoginDlg(0)
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 5, in __init__
    wxDialog.__init__(self, parent, -1, "Login")
  File "C:\PYTHON22\lib\site-packages\wxPython\frames.py", line 199, in
__init__
    self.this = apply(framesc.new_wxDialog,_args,_kwargs)
TypeError: Type error in argument 1 of new_wxDialog. Expected _wxWindow_p.

And why do I need a 0 passed into LoginDlg?
I'd like better documentation. Currently, I search the wxPython site
looking for something similar to what I'm trying to do, then I check the
wxWindows site. I'm also using IDLE. There's got to be a better way to
learn this! Please tell me I'm right!

Many thanks for your help!

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

--
  UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

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

Never mind. stupid C++ habit syntax got to me!
I needed "self."

···

-----Original Message-----
From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
Sent: Thursday, January 23, 2003 4:48 PM
To: uwe@oss4u.com; wxPython-users@lists.wxwindows.org
Subject: RE: [wxPython-users] Newbie banging head against wall (simple
wxDialog problem)

Thanks everyone!

I wasn't completely honest with the code I presented. This dialog is part of
a project, and I wanted to test it separately. So I had a wxApp elsewhere,
but thanks for reminding me that I left that part out.

Next up, is I'm trying to use a sizer to arrange stuff in the wxDialog, but
apparently, it doesn't have SetSizer() even though it's abstracted from
wxWindow...

How am I to arrange controls in dialogs?

-----Original Message-----
From: Uwe C. Schroeder [mailto:uwe@oss4u.com]
Sent: Thursday, January 23, 2003 2:51 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Newbie banging head against wall (simple
wxDialog problem)

On Thursday 23 January 2003 11:17 am, Jason Hihn wrote:

I can't get these three lines to work:

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

app=LoginDlg(0)
app.MainLoop()

You need to have a wxApp instance (that's also the one getting the 0 )

Try something like:

from wxPython.wx import *

class LoginDlg(wxDialog):
    def __init__(self, parent):
        wxDialog.__init__(self, parent, -1, "Login")

class MyFrame(wxFrame):
    def __init__(self, parent, id, title,
                 pos = wxPyDefaultPosition, size = wxPyDefaultSize,
                 style = wxDEFAULT_FRAME_STYLE ):
        wxFrame.__init__(self, parent, id, title, pos, size, style)

    def login(self):
  _dlg=LoginDlg(self)
  _dlg.CentreOnParent()
  _dlg.ShowModal()

class MyApp(wxApp):
    def OnInit(self):
        frame=MyFrame(None, -1, "Main Application", wxPoint(20,20),
wxSize(280,130) )
        frame.login()
        frame.Show()
        return 1

app=MyApp(0)
app.MainLoop()

Get the difference ?

BTW the 0 means "don't redirect stderr and stdout". So when you call it in a
shell (or cmd) you'll see all the messages in there (like print statements
and tracebacks)
If you put a 1 you'll get a window with the output.
If you put a MyApp(1,filename='log.txt') - ok you guessed that - the output
will be in the file log.txt in the current directory

Hope that helps

  UC

-------------------------------------------------------------
Traceback (most recent call last):
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 43, in ?
    app=LoginDlg(0)
  File "C:\WINDOWS\Desktop\PyPEPS\LoginDlg.py", line 5, in __init__
    wxDialog.__init__(self, parent, -1, "Login")
  File "C:\PYTHON22\lib\site-packages\wxPython\frames.py", line 199, in
__init__
    self.this = apply(framesc.new_wxDialog,_args,_kwargs)
TypeError: Type error in argument 1 of new_wxDialog. Expected _wxWindow_p.

And why do I need a 0 passed into LoginDlg?
I'd like better documentation. Currently, I search the wxPython site
looking for something similar to what I'm trying to do, then I check the
wxWindows site. I'm also using IDLE. There's got to be a better way to
learn this! Please tell me I'm right!

Many thanks for your help!

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

--
  UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

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

self.Layout() at the end of the intialiser.

HTH,
Mike

Jason Hihn wrote:

Thanks everyone!

I wasn't completely honest with the code I presented. This dialog is part of
a project, and I wanted to test it separately. So I had a wxApp elsewhere,
but thanks for reminding me that I left that part out.

Next up, is I'm trying to use a sizer to arrange stuff in the wxDialog, but
apparently, it doesn't have SetSizer() even though it's abstracted from
wxWindow...

How am I to arrange controls in dialogs?

...