Presentation is loading. Please wait.

Presentation is loading. Please wait.

WxPython for Everyone Charles Shapiro Atlanta Linux Enthusiasts May 2009.

Similar presentations


Presentation on theme: "WxPython for Everyone Charles Shapiro Atlanta Linux Enthusiasts May 2009."— Presentation transcript:

1 WxPython for Everyone Charles Shapiro Atlanta Linux Enthusiasts May 2009

2 What Is WxPython? ● A cross-platform GUI development tool – Allows speedy development of GUI applications which will run on most popular platforms – Simple to understand and use – Actively developed with a large inventory of current projects – Open-source, L-GPL compatible license

3 wxWidgets Library ● C++ library designed for cross-platform widget development ● Julian Smart, University of Edinburgh, 1992. ● 22 pre-defined widgets (windows, panels, textboxes,sliders,buttons, et cetera) ● Lower-level API to develop your own custom widgets if necessary ● Other Wrappers: wxLua, wxPerl, WxBasic, D

4 WxPython Wrapper ● Python: Very Stylish – VM means no recompilation for different platforms – Access to Python libraries (e.g. DBI, pygame, et cetera) ● Must use Python 2.4 or better ● GPL-compatible license ● Full documentation

5 The Simplest Possible WxPython Program #!/usr/bin/env python import wx class myApp(wx.App): def OnInit(self): frame=wx.Frame(parent=None, title="Bare") frame.Show() return True app=myApp() app.MainLoop()

6 Demo wxtiny Here

7 A WxPython Program that Does Something

8 Demo example.py Here

9 wx.App() Object

10 wx.Frame Object

11 wxPython Main Line

12 Coding your WxPython GUI in XML ● Create an XRC file containing specs for all your widgets and windows. – Separation of Concerns ● Change your UI without editing your code – Use specialized editing tools to create and maintain most of your UI – XRC files are XML, so an XML parser is available in WxPython for other uses

13 Simple WxPython XRC Reader

14 Demo xrctest.py Here

15 Simple WxPython XRC File

16 Creating XRC files ● WxGlade http://wxglade.sourceforge.nethttp://wxglade.sourceforge.net – generates Python code as well ● XRCed http://xrced.sourceforge.nethttp://xrced.sourceforge.net

17 Demo wxGlade Here

18 Running on Windows ● All the usual fun: file types are by extension, script files won't work right, some tools may not exist. ● Initting an empty listbox in an XRC file (e.g. if you're filling it later from a database) causes an assertion exception in the windows wxwidgets C library. The cure is to put a dummy value in the listbox, remove it, and then fill it.

19 Other WxPython Features ● MDI (Multiple windows inside one, like OO 1.0) ● Validators (Hooks to manage your dialogs) ● Device Contexts (use WxPython for printing or drawing graphics in memory without display) ● Crude HTML display (lacks CSS et cetera)

20 WxPython Resources ● http://python.org (Python) http://python.org ● http://wxpython.org (wiki,listserve,doc) http://wxpython.org ● http://wxwidgets.org (wxwidgets) http://wxwidgets.org ● WxPython In Action (Noel Rappin, Robin Dunn; Mar 2006 Manning Publications, Greenwich CT)


Download ppt "WxPython for Everyone Charles Shapiro Atlanta Linux Enthusiasts May 2009."

Similar presentations


Ads by Google