13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

xml resource fileshttp://www.zetcode.com/wxpython/xmlresource/Python IDEHome Edit, Test, Contents and Debug Free 30-day Trialwww.wingware.comDeveloping HL7 Solutions?HL7 Software Development Componentsand COM Services. Free Trial.xml resource files<strong>The</strong> idea behind xml resources is to separate the interface from thecode of an application. Several GUI builders use this concept forcreating interfaces. For example the famous Glade. In our examplewe create a simple frame window with one button. We load resourcesfrom a file, load a panel and bind an event to a button.Figure: myconfig.py#!/usr/bin/python# xml.pyimport wximport wx.xrc as xrcclass Xml(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title)res = xrc.XmlResource('resource.xrc')res.LoadPanel(self, 'MyPanel')self.Bind(wx.EVT_BUTTON, self.OnClose, id=xrc.XRCID('CloseButton'))self.Center()self.Show(True)def OnClose(self, event):self.Close()app = wx.App()Xml(None, -1, 'xml.py')app.MainLoop()This is resource file resource.xrc It is a xml file, where we define ourwidgets and their patterns. In thid file, we use tags like, etc.1 de 2 27/04/2008 1:08

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!