Post by Werner F. BruhinCan you expand on this, i.e. give an example
Well . . Boa doesn't do resource files. XRC is a type of resource
file, similar in scope as to what resource file in MFC are used for.
XRC however is in XML so it is just plain better : )
There is a reason resource files are used in many other programming
IDEs, languages, development environments etc. Resource files allow
the logic of you code to be loosly coupled (to use a CS term) with
the layout of your app.
THis is also the same idea behind having a seperate CSS file instead
of embedding all the layout in the HTML file. Latex, same idea.
Seperate content from layout.
So, if I create my dialog in XRC then to get at it I do something like
the following:
#-------------------------------------------------------------------------------->
class addMachineDialog(wx.Dialog):
def __init__(self, parent, db):
#-------------------------------------------
#
# Dialog Initialization
#
self.db = db
self.parent = parent
self.res = wxXmlResource("addMachineDialog.xrc")
self.dialog = self.res.LoadDialog(self.parent, "addMachineDlg")
self.dialog.SetReturnCode(-999)
self.PostCreate(self.dialog)
self.machineNameTXT = XRCCTRL(self, "machineNameTXT")
self.panelTXT = XRCCTRL(self, "panelTXT")
self.cancelBTN = XRCCTRL(self, "cancelBTN")
self.addBTN = XRCCTRL(self, "addBTN")
self.findBTN = XRCCTRL(self, "findBTN")
self.cancelBTN.Bind(wx.EVT_BUTTON, self._cancel)
self.addBTN.Bind(wx.EVT_BUTTON, self._add)
self.findBTN.Bind(wx.EVT_BUTTON, self._find)
def PostCreate(self, pre):
self.this = pre.this
self.thisown = pre.thisown
pre.thisown = 0
if hasattr(self, '_setOORInfo'):
self._setOORInfo(self)
if hasattr(self, '_setCallbackInfo'):
self._setCallbackInfo(self, self.__class__)
#<---------------------------------------------------------------------------------
The above will load my xrc file, grab the relevant controls and make
all the controls members of the addMachineDialog class. There are
other ways to do this, but I like simplicity.
Now, if I want to change the layout, I edit it in wxGlade or XRCed (a
matter of preference really, both are equally good.) and generate the
XRC file. If I need to change the logic of my code, I change it
without fear of messing up what a form designer might do. It's not
that you can't do the exact same thing with Boa, it's just that you
end up with much cleaner, more modular, testable and maintainable
code. I've done this both ways, I have a fairly large python app
written using Boa and one using wxGlade. I'm afraid to touch the Boa
app, The wxGlade is actually a bigger app but is much more
maintainable.
Try and see what works for you,
Matt