wxWizard and XRC crash

Hey all,

I seem to have a problem using wxWizard in an XRC definition.

I've attached a small code snippet which causes a crash when you click Next. If someone could point me in the right direction, maybe to some examples of wxWizard and XRC, that would be great.

Cheers,
Jonathan

wizard_test.py (550 Bytes)

Jonathan Viney wrote:

Hey all,

I seem to have a problem using wxWizard in an XRC definition.

I've attached a small code snippet which causes a crash when you click Next. If someone could point me in the right direction, maybe to some examples of wxWizard and XRC, that would be great.

You need to use RunWizard for wizards, not Show. Also you need to explicitly import wx.wizard so the OOR system will know about the classes and so resource.LoadObject will return an object of wxWizard type instead of wxDialog.

Here is a working copy of your example:

import wx, wx.xrc
import wx.wizard

print wx.VERSION

definition = r'''<?xml version="1.0" ?>
<resource>
     <object class="wxWizard" name="Wizard">
         <title>Test</title>

         <object class="wxWizardPageSimple" name="Page1">
             <object class="wxStaticText" name="label1">
                 <label>This is a static text label for Page 1.</label>
                 <pos>10,10</pos>
             </object>
         </object>

         <object class="wxWizardPageSimple" name="Page2">
             <object class="wxStaticText" name="label1">
                 <label>Page 2</label>
                 <pos>10,10</pos>
             </object>
         </object>
     </object>
</resource>
'''

app = wx.App(0)

# Load the XRC resource
resource = wx.xrc.EmptyXmlResource()
resource.LoadFromString(definition)

wizard = resource.LoadObject(None, 'Wizard', 'wxWizard')
page1 = wx.xrc.XRCCTRL(wizard, 'Page1')
wizard.RunWizard(page1)
wizard.Destroy()

app.MainLoop()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn <robin@alldunn.com> writes:

Here is a working copy of your example:

Robin,

Your code works, but here I have two problems:

import wx, wx.xrc
import wx.wizard

print wx.VERSION

definition = r'''<?xml version="1.0" ?>
<resource>
    <object class="wxWizard" name="Wizard">
        <title>Test</title>

        <object class="wxWizardPageSimple" name="Page1">
            <object class="wxStaticText" name="label1">
                <label>This is a static text label for Page 1.</label>
                <pos>10,10</pos>
            </object>
        </object>

        <object class="wxWizardPageSimple" name="Page2">
            <object class="wxStaticText" name="label1">
                <label>Page 2</label>
                <pos>10,10</pos>
            </object>
        </object>
    </object>
</resource>
'''

app = wx.App(0)

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in __init__
    _wxStart(self.OnInit)
AttributeError: wxApp instance has no attribute 'OnInit'

# Load the XRC resource
resource = wx.xrc.EmptyXmlResource()
resource.LoadFromString(definition)

wizard = resource.LoadObject(None, 'Wizard', 'wxWizard')
page1 = wx.xrc.XRCCTRL(wizard, 'Page1')
wizard.RunWizard(page1)
wizard.Destroy()

app.MainLoop()

And, due to the above problem:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'app' is not defined

But the screen is shown. It is a problematic working copy :slight_smile:

I'm with wxPython 2.4.2.4 here.

Be seeing you,

···

--
Godoy. <godoy@ieee.org>

Jorge Godoy wrote:

app = wx.App(0)

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in __init__
    _wxStart(self.OnInit)
AttributeError: wxApp instance has no attribute 'OnInit'

Oops, that should be wx.PySimpleApp

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!