Hello list,
I have written a wxpython app and made usage of the xrc system. It works
fine with linux and wx-gtk2 (2.6.1, python2.3, debian).
With win32 I run into problems
MyApp loads the XmlResource, which contains a MainFrame derived from
wx.Frame. This gets loaded by xrc.
With win32 I can not access the controls with xrc.XRCCTRL(self, 'id'). I
just get NoneType objects in _get_controls(), but no errors (of course
later on I get errors about missing attributes when accessing this NoneType
objects ;).
I need this app for my studies and my prof wants to have this on win32, of
course asap. So any help is very appreciated
This is the relevant code:
class MainFrame(wx.Frame):
聽聽聽聽def __init__(self):
聽聽聽聽聽聽聽聽p = wx.PreFrame()
聽聽聽聽聽聽聽聽# the Create step is done by XRC
聽聽聽聽聽聽聽聽self.PostCreate(p)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
聽聽聽聽def OnCreate(self, event):
聽聽聽聽聽聽聽聽self.Unbind(wx.EVT_WINDOW_CREATE)
聽聽聽聽聽聽聽聽self._PostInit()
聽聽聽聽聽聽聽聽event.Skip()
聽聽聽聽聽聽聽聽return True
聽聽聽聽def _PostInit(self):
聽聽聽聽聽聽聽聽# Do all init here
聽聽聽聽聽聽聽聽self._do_layout()
聽聽聽聽聽聽聽聽self._set_properties()
聽聽聽聽def _do_layout(self):
聽聽聽聽聽聽聽聽self._get_controls()
聽聽聽聽聽聽聽聽self.Fit()
聽聽聽聽聽聽聽聽self.SetAutoLayout(True)
聽聽聽聽聽聽聽聽self.Center(wx.BOTH)
聽聽聽聽def _set_properties(self):
聽聽聽聽聽聽聽聽self._connect_controls()
聽聽聽聽聽聽聽聽# This failes course btnStop is of Type NoneType:
聽聽聽聽聽聽聽聽self.btnStop.Enable(False)
聽聽聽聽def _get_controls(self):
聽聽聽聽聽聽聽聽"""Get controls from XML resources
聽聽聽聽聽聽聽聽聽聽聽This does not work with win32. I just get None.
聽聽聽聽聽聽聽聽"""
聽聽聽聽聽聽聽聽self.btnStart = xrc.XRCCTRL(self, 'btnStart')
聽聽聽聽聽聽聽聽self.btnStop = xrc.XRCCTRL(self, 'btnStop')
聽聽聽聽聽聽聽聽self.btnReset = xrc.XRCCTRL(self, 'btnReset')
聽聽聽聽聽聽聽聽self.sldT = xrc.XRCCTRL(self, 'sldT')
聽聽聽聽聽聽聽聽self.sldB = xrc.XRCCTRL(self, 'sldB')
聽聽聽聽聽聽聽聽self.lblM = xrc.XRCCTRL(self, 'lblM')
聽聽聽聽聽聽聽聽self.lblMmean = xrc.XRCCTRL(self, 'lblMmean')
聽聽聽聽聽聽聽聽self.gaugM = xrc.XRCCTRL(self, 'gaugM')
聽聽聽聽聽聽聽聽self.canvas = xrc.XRCCTRL(self, 'canvas')
聽聽聽聽def _connect_controls(self):
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_BUTTON, self.OnBtnStart, self.btnStart)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_BUTTON, self.OnBtnStop, self.btnStop)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_BUTTON, self.OnBtnReset, self.btnReset)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_COMMAND_SCROLL_ENDSCROLL, self.OnSldT, self.sldT)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK, self.OnSldT, self.sldT)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, self.OnSldT,self.sldT)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_COMMAND_SCROLL_ENDSCROLL, self.OnSldB, self.sldB)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK, self.OnSldB, self.sldB)
聽聽聽聽聽聽聽聽self.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, self.OnSldB,self.sldB)
I have read the wxpython wiki about xrc, Robin Dunn's email referenced
there, and searched the list archive, but don't know what to do to fix
this.
Thanks for any help,
聽聽Dave J盲ckel