Python/wxPython/QuickStart: Difference between revisions
Jump to navigation
Jump to search
| Line 19: | Line 19: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Python || XRC | ! Python<br>(main.py) || XRC<br>(layout.xrc) | ||
|- | |- | ||
| | | valign="true" | | ||
<source lang="python"> | <source lang="python"> | ||
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||
| Line 37: | Line 37: | ||
app.MainLoop() | app.MainLoop() | ||
</source> | </source> | ||
| | | valign="true" | | ||
<source lang="xml"> | <source lang="xml"> | ||
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||
Revision as of 08:51, 20 March 2019
Skeleton
wxFrame without XRC
#!/usr/bin/env python3
import wx
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, -1, 'Hello World!')
frame.Show()
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()
wxFrame with XRC
| Python (main.py) |
XRC (layout.xrc) |
|---|---|
#!/usr/bin/env python3
import wx.xrc
class MyApp(wx.App):
def OnInit(self):
res = wx.xrc.XmlResource('layout.xrc')
frame = res.LoadFrame(None, 'mainFrame')
frame.Show()
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()
|
<?xml version="1.0" encoding="utf-8"?>
<resource version="2.9.0.5">
<object name="mainFrame" class="wxFrame">
<title>Hello World!</title>
</object>
</resource>
|