Python/wxPython/QuickStart: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
Line 16: Line 16:
</source>
</source>


== wxDialog ==
== wxFrame with XRC ==
{| class="wikitable"
|-
! Python || XRC
|-
|
<source lang="python">
#!/usr/bin/env python3
import wx.xrc


== wxMDIParentFrame ==
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()
</source>
|
<source lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<resource version="2.9.0.5">
  <object name="mainFrame" class="wxFrame">
    <title>Hello World!</title>
  </object>
</resource>
</source>
|}

Revision as of 08:50, 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 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>