[wxPython-users] xrc and wxStatusBar probs
DASPRiD
mail at dasprids.de
Sun Jun 18 07:03:14 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> Hi, I am trying to instantiate a wxStatus Bar, but not having much luck.
Hi Marc Risney,
> Here is my element in the .xrc file
>
> <object class="sizeritem">
> <object class="wxStatusBar" name="ID_STATUS_BAR">
> <fields>2</fields>
> <widths></widths>
> <style>wxST_SIZEGRIP</style>
> </object>
> <flag>wxEXPAND</flag>
> </object>
> </object>
I don't know much about xrc, but
> and here is my python code
>
>
> class Application(wx.App):
> def OnInit(self):
> self.res = xrc.XmlResource("gui.xrc")
> self.InitFrame()
> self.InitMenu()
> self.InitStatusBar()
> self.InitEverythingElse()
> return True
>
> def InitFrame(self):
> self.frame = self.res.LoadFrame(None, "ID_MAIN_FRAME")
> self.panel = xrc.XRCCTRL(self.frame, "ID_MAIN_PANEL")
>
> def InitMenu(self):
> self.menuBar = self.res.LoadMenuBar("ID_MENU_BAR")
> self.frame.SetMenuBar(self.menuBar)
> self.frame.Bind(wx.EVT_MENU, self.OnOpen, id=xrc.XRCID("ID_OPEN"))
>
> def InitStatusBar(self):
> self.statusBar = wx.StatusBar
> self.statusBar = self.res.LoadObject(self,"ID_STATUS_BAR","wxStatusBar")
Here you gave self as first parameter (with self in the object itself,
its the second one). self is wx.app, but wx.window * is expected, so you
have to write:
self.statusBar =
self.res.LoadObject(self.frame,"ID_STATUS_BAR","wxStatusBar")
> self.frame.SetStatusBar = self.statusBar
> self.statusBar.SetStatusText("test",0)
>
>
> This is the error I get when I try to start my app:
>
> File "D:\projects\CarsonCity\Python\gui\ncats.py", line 79, in main
> app = Application(0)
> File
> "D:\Python\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx\_core.py", li
> e 7700, in __init__
> self._BootstrapApp()
> File
> "D:\Python\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx\_core.py", li
> e 7352, in _BootstrapApp
> return _core_.PyApp__BootstrapApp(*args, **kwargs)
> File "D:\projects\CarsonCity\Python\gui\ncats.py", line 17, in OnInit
> self.InitStatusBar()
> File "D:\projects\CarsonCity\Python\gui\ncats.py", line 34, in
> InitStatusBar
> self.statusBar = self.res.LoadObject(self,"ID_STATUS_BAR","wxStatusBar")
> File
> "D:\Python\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx\xrc.py", line
> 157, in LoadObject
> return _xrc.XmlResource_LoadObject(*args, **kwargs)
> ypeError: argument number 2: a 'wxWindow *' is expected,
> 'PySwigObject(_p_wxPyA
> p)' is received
>
> any suggestions?
>
> Marc
Hope this helps you.
Best regards,
DASPRiD
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFElV0hB/XFUANTDPMRAue7AKDFfe0/cGtRfDN3m1eeZai0h+6CHACdFWxv
N1tlhYs1jny/DZG2X8VnOgE=
=FAhH
-----END PGP SIGNATURE-----
More information about the wxpython-users
mailing list