I've tried several of the above mentioned builders,
with the same result.
I've also looked at wxFormBuilder,
but I found it far too difficult and
fully unreadable (how can you create actions/bindings on components you don't see ?).
So I might be very very naive,
but why all so complex ??
Complex? Not at all! Let me show you an 'hello world!' example. Below
is the content of two files: HelloWorld.py hand-written be me, and
HelloWorld.xrc emitted by wxFormBuilder. I gave each control a care
about a name in wxFormBuilder, and use that to e.g. bind events and
load resources.
HelloWorld.py:
import wx
from wx import xrc
import sys
class MainFrame(object):
def __init__(self, xml):
self.xml = xml
self.frame = xml.LoadFrame(None,'MainFrame')
self.frame.Bind(wx.EVT_MENU, self.on_menu_exit,
id=xrc.XRCID('menuExit'))
self.frame.Bind(wx.EVT_BUTTON, self.on_say_hello,
id=xrc.XRCID('btnSayHello'))
self.frame.Show()
def on_say_hello(self, evt):
dlg = self.xml.LoadDialog(self.frame, 'HelloDialog')
dlg.ShowModal()
dlg.Destroy()
def on_menu_exit(self, evt):
self.frame.Destroy()
sys.exit(0)
class HelloWordApp(wx.App):
def OnInit(self):
xml = xrc.XmlResource('HelloWorld.xrc')
self.MainFrame = MainFrame(xml)
return True
if __name__ == '__main__':
app = HelloWordApp(0)
app.MainLoop()
HelloWorld.xrc:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="
http://www.wxwindows.org/wxxrc" version="2.3.0.1">
<object class="wxFrame" name="MainFrame">
<style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
<size>289,171</size>
<title></title>
<object class="wxMenuBar" name="m_menubar2">
<label></label>
<object class="wxMenu" name="fileMenu">
<label>File</label>
<object class="wxMenuItem" name="menuExit">
<label>Exit </label>
<help></help>
</object>
</object>
</object>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="spacer">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<size>0,0</size>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL</
flag>
<border>5</border>
<object class="wxButton" name="btnSayHello">
<label>Say hello</label>
<default>0</default>
</object>
</object>
<object class="spacer">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<size>0,0</size>
</object>
</object>
</object>
<object class="wxDialog" name="HelloDialog">
<style>wxDEFAULT_DIALOG_STYLE</style>
<size>190,144</size>
<title></title>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="spacer">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<size>0,0</size>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER|wxALL</flag>
<border>5</border>
<object class="wxStaticText" name="m_staticText11">
<font>
<size>14</size>
<family>swiss</family>
<style>normal</style>
<weight>normal</weight>
<underlined>0</underlined>
<face>Times New Roman</face>
</font>
<label>Hello World!</label>
</object>
</object>
<object class="spacer">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<size>0,0</size>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND | wxALL</flag>
<border>5</border>
<object class="wxStaticLine" name="m_staticline4">
<style>wxLI_HORIZONTAL</style>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxStdDialogButtonSizer">
<object class="button">
<flag>wxALIGN_CENTER_HORIZONTAL|wxALL</flag>
<border>5</border>
<object class="wxButton" name="wxID_OK">
<label>&OK</label>
</object>
</object>
</object>
</object>
</object>
</object>
</resource>