SlideShare a Scribd company logo
8
Most read
14
Most read
19
Most read
wxPython and wxFormBuilder

      jsliang.tw@gmail.com
            Jenny Liang
a GUI toolkit for Python

wxPython


                           2
Introduction to wxPython
   wxPython is a GUI toolkit for Python.
   • Download: http://wxpython.org/
   • Built upon the wxWidgets C++ toolkit
          – See http://wxWidgets.org/
   • Cross platform
          – Windows, Linux, Unix, OS X
          – Uses native widgets/controls, plus many platform
            independent widgets.

Reference: http://wxpython.org/OSCON2008/wxPython-Advanced-OSCON2008.pdf   3
Architecture
                                                wxPython Library


                                        wxPython Extension Modules


                                                wxWidgets Toolkit


                                                           Platform GUI


                                                Operating System



Reference: http://wxpython.org/OSCON2008/wxPython-Advanced-OSCON2008.pdf   4
Partial Class Hierarchy
                                                                      wx.Object


                                             wx.EvtHandler


                                              wx.Window


                   wx.TopLevelWindow           wx.Panel                    wx.Control


                 wx.Frame        wx.Dialog        wx.ScrolledWindow           wx.StaticText


                         …               …                                    wx.TextCtrl


                                                                                  …


Reference: http://wxpython.org/OSCON2008/wxPython-Advanced-OSCON2008.pdf                      5
Windows or Frames?
    • A wx.Window is the base class from which all
      visual elements are derived.
           – buttons, menus, etc
    • What we normally think of as a program
      window is a wx.Frame.




Reference: http://wiki.wxpython.org/Getting%20Started   6
Getting started with wxPython
http://wiki.wxpython.org/Getting%20Started
• A First Application: "Hello, World“
• Building a simple text editor




                                             7
A First Application: "Hello, World"
    #!/usr/bin/env python
    import wx

    # Create a new app, don't redirect stdout/stderr to a window.
    app = wx.App(False)

     # A Frame is a top-level window.
    frame = wx.Frame(None, wx.ID_ANY, "Hello World")

    frame.Show(True) # Show the frame.
    app.MainLoop()




Reference: http://wiki.wxpython.org/Getting%20Started               8
A Simple Text Editor with Menu
import wx
class MainWindow(wx.Frame):
   def __init__(self, parent, title):
     wx.Frame.__init__(self, parent, title=title, size=(200,100))
     self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
     self.CreateStatusBar() # A Statusbar in the bottom of the window
     filemenu = wx.Menu() # Setting up the menu.
     # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
     filemenu.Append(wx.ID_ABOUT, "&About", " Information about this program")
     filemenu.AppendSeparator()
     filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program")
     # Creating the menubar.
     menuBar = wx.MenuBar()
     menuBar.Append(filemenu, "&File") # Adding the "filemenu" to the MenuBar
     self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content
     self.Show(True)
app = wx.App(False)
frame = MainWindow(None, "Sample editor")
app.MainLoop()

                                                      Reference: http://wiki.wxpython.org/Getting%20Started   9
GUI designer application for wxWidgets toolkit

wxFormBuilder (wxFB)


                                                 10
Introduction to wxFB
• wxFormBuilder is an open source GUI
  designer application for wxWidgets toolkit.
  – a visual development tool
  – File extension: *.fbp
     • can emit C++ (*.h & *.cpp), Python (*.py) and XRC
       (*.xrc) codes
• wxFormBuilder have a rich set of supported
  widgets.
  – http://en.wikipedia.org/wiki/WxFormBuilder
                                                           11
12
13
14
15
Press F8, and gui.py
 will be generated
http://goo.gl/RxGD6




                       16
Event Handlers (1/2)
# file: gui.py (generated by wxFB)
import wx
import wx.xrc

###########################################################################
## Class Sheetaholics_MainFrame
###########################################################################

class Sheetaholics_Main ( wx.Frame ):

  def __init__( self, parent ):
    ... ( codes for layout )

    # Connect Events
    self.btn_dottedlined_genpdf.Bind( wx.EVT_BUTTON, self.btn_dottedlined_genpdfOnButtonClick )

  def __del__( self ):
    pass

  # Virtual event handlers, override them in your derived class
  def btn_dottedlined_genpdfOnButtonClick( self, event ):
    event.Skip()                                                                                  17
Event Handlers (2/2)
# file: main.py
import gui # import gui.py, which was generated by wxFB
import wx

class Sheetaholics_MainFrame( gui.Sheetaholics_MainFrame ): # inherit gui.Sheetaholics_MainFrame
   def __init__( self, parent ):
     gui.Sheetaholics_MainFrame.__init__( self, parent )

  # handler for Sheetaholics_MainFrame event
  def btn_dottedlined_genpdfOnButtonClick( self, event ):
    ... ( event handler contents here )

class SheetaholicsMain(wx.App):
  def OnInit(self):
     self.m_frame = Sheetaholics_MainFrame(None)
     self.m_frame.Show()
     return True

app = SheetaholicsMain(0)
app.MainLoop()

                                                                                                   18
References
• wxWidgets
  • http://wxwidgets.org/
• wxPython
  – http://wxpython.org/
  – http://wiki.wxpython.org/How%20to%20Learn%20wxPyth
    on
  – http://wiki.wxpython.org/Getting%20Started
• wxFormBuilder
  – http://wxformbuilder.org/
  – http://sourceforge.net/apps/mediawiki/wxformbuilder/in
    dex.php?title=Tutorials
  – http://en.wikipedia.org/wiki/WxFormBuilder

                                                         19
Q&A




      20

More Related Content

PPTX
presentasi materi Microsoft powerpoint 2007
DOCX
Ensayo de exel
PPTX
How to Build Custom Module in Odoo 15
PPTX
Tutorial 2
PPTX
los menús de power point
PDF
Manipulando Planilhas Excel com Python
PDF
Introducción InDesign
PPSX
Diseño de Páginas Web - BALSAMIQ MOCKUPS 3
presentasi materi Microsoft powerpoint 2007
Ensayo de exel
How to Build Custom Module in Odoo 15
Tutorial 2
los menús de power point
Manipulando Planilhas Excel com Python
Introducción InDesign
Diseño de Páginas Web - BALSAMIQ MOCKUPS 3

What's hot (20)

PPTX
uso de power point
PPTX
pestaña de referencia
DOCX
BAI TAP TRONG ILLUSTRATOR.docx
PDF
VISUAL BASIC 6.0
PDF
Material de lectura administración de base de datos
PPTX
Structured Business Process Modeling - Lavacon 2014
PPTX
BPMN 2.0 Fundamentals
PPTX
Arreglos en Java
PDF
ANIMASI FRAME BY FRAME DAN ANIMASI TWEENING.pdf
PPTX
Requirements Gathering Best Practice Pack
PPS
Microsoft office introducción
DOCX
Modulo Photoshop Cs 6
PDF
Introducción a Word
PPT
Bpm Implementation Success Criteria And Best Practice
DOC
Giáo trình tự học Adobe Illustrator CS6 bằng tiếng Việt
PPSX
Clase excel 1
PDF
Fundamentals of business process management and BPMN
PPTX
Herramientas en power point
PPTX
Adobe photoshop power point
uso de power point
pestaña de referencia
BAI TAP TRONG ILLUSTRATOR.docx
VISUAL BASIC 6.0
Material de lectura administración de base de datos
Structured Business Process Modeling - Lavacon 2014
BPMN 2.0 Fundamentals
Arreglos en Java
ANIMASI FRAME BY FRAME DAN ANIMASI TWEENING.pdf
Requirements Gathering Best Practice Pack
Microsoft office introducción
Modulo Photoshop Cs 6
Introducción a Word
Bpm Implementation Success Criteria And Best Practice
Giáo trình tự học Adobe Illustrator CS6 bằng tiếng Việt
Clase excel 1
Fundamentals of business process management and BPMN
Herramientas en power point
Adobe photoshop power point
Ad

Viewers also liked (20)

PDF
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
PDF
Lightning Talk: jsPDF
PDF
PyQtではじめるGUIプログラミング
PPTX
Портфолио Курмаевой С.И.
PPTX
Gender mainstreaming of public campaigns
PDF
Art & science part ii
PPTX
המעצבים עבודות חוץ
PDF
Контент и конверсионный трафик. Взаимное влияние
PPTX
Выпускной
PPT
школы агинское итоги егэ_гиа_2011
PDF
47 amazing blog designs
PPTX
Sath poomch
PDF
Lettura
PPTX
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
PPTX
Pecha Kucha
PPT
Carlos carolinajessica
PDF
PDF
MSH Design Brochure (draft / test)
PPT
Technology and Education
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
Lightning Talk: jsPDF
PyQtではじめるGUIプログラミング
Портфолио Курмаевой С.И.
Gender mainstreaming of public campaigns
Art & science part ii
המעצבים עבודות חוץ
Контент и конверсионный трафик. Взаимное влияние
Выпускной
школы агинское итоги егэ_гиа_2011
47 amazing blog designs
Sath poomch
Lettura
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
Pecha Kucha
Carlos carolinajessica
MSH Design Brochure (draft / test)
Technology and Education
Ad

Similar to wxPython and wxFormBuilder (20)

PDF
Getting started with wxWidgets
PDF
PDF
PDF
GNURAdioDoc-8
PDF
GNURAdioDoc-8
PDF
DESKTOP GUI APP DEVELOPMENT USING PYTHON!
PDF
DESKTOP GUI APP DEVELOPMENT USING PYTHON!
PDF
08_Wxwidgets 소개
PPTX
The wxWindows Library Licence
PPTX
About Python Tkinter and creating .a GUI
PDF
A Complete seminar on GUI Development in python
PDF
GUI toolkits comparison for python
PPTX
Chapter - 6.pptx
PPTX
PPTX
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
PPTX
Introduction to GUIs with guizero
PPTX
Python Graphical User Interface and design
PPT
Python is a high-level, general-purpose programming language. Its design phil...
PDF
Python GUI Programming Tkinter and.pdf
PPTX
GUI Programming using Tkinter-converted.pptx
Getting started with wxWidgets
GNURAdioDoc-8
GNURAdioDoc-8
DESKTOP GUI APP DEVELOPMENT USING PYTHON!
DESKTOP GUI APP DEVELOPMENT USING PYTHON!
08_Wxwidgets 소개
The wxWindows Library Licence
About Python Tkinter and creating .a GUI
A Complete seminar on GUI Development in python
GUI toolkits comparison for python
Chapter - 6.pptx
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
Introduction to GUIs with guizero
Python Graphical User Interface and design
Python is a high-level, general-purpose programming language. Its design phil...
Python GUI Programming Tkinter and.pdf
GUI Programming using Tkinter-converted.pptx

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Approach and Philosophy of On baking technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
Building Integrated photovoltaic BIPV_UPV.pdf
Spectroscopy.pptx food analysis technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Approach and Philosophy of On baking technology
20250228 LYD VKU AI Blended-Learning.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
“AI and Expert System Decision Support & Business Intelligence Systems”
Programs and apps: productivity, graphics, security and other tools
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25 Week I
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

wxPython and wxFormBuilder

  • 1. wxPython and wxFormBuilder jsliang.tw@gmail.com Jenny Liang
  • 2. a GUI toolkit for Python wxPython 2
  • 3. Introduction to wxPython wxPython is a GUI toolkit for Python. • Download: http://wxpython.org/ • Built upon the wxWidgets C++ toolkit – See http://wxWidgets.org/ • Cross platform – Windows, Linux, Unix, OS X – Uses native widgets/controls, plus many platform independent widgets. Reference: http://wxpython.org/OSCON2008/wxPython-Advanced-OSCON2008.pdf 3
  • 4. Architecture wxPython Library wxPython Extension Modules wxWidgets Toolkit Platform GUI Operating System Reference: http://wxpython.org/OSCON2008/wxPython-Advanced-OSCON2008.pdf 4
  • 5. Partial Class Hierarchy wx.Object wx.EvtHandler wx.Window wx.TopLevelWindow wx.Panel wx.Control wx.Frame wx.Dialog wx.ScrolledWindow wx.StaticText … … wx.TextCtrl … Reference: http://wxpython.org/OSCON2008/wxPython-Advanced-OSCON2008.pdf 5
  • 6. Windows or Frames? • A wx.Window is the base class from which all visual elements are derived. – buttons, menus, etc • What we normally think of as a program window is a wx.Frame. Reference: http://wiki.wxpython.org/Getting%20Started 6
  • 7. Getting started with wxPython http://wiki.wxpython.org/Getting%20Started • A First Application: "Hello, World“ • Building a simple text editor 7
  • 8. A First Application: "Hello, World" #!/usr/bin/env python import wx # Create a new app, don't redirect stdout/stderr to a window. app = wx.App(False) # A Frame is a top-level window. frame = wx.Frame(None, wx.ID_ANY, "Hello World") frame.Show(True) # Show the frame. app.MainLoop() Reference: http://wiki.wxpython.org/Getting%20Started 8
  • 9. A Simple Text Editor with Menu import wx class MainWindow(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=(200,100)) self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.CreateStatusBar() # A Statusbar in the bottom of the window filemenu = wx.Menu() # Setting up the menu. # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets. filemenu.Append(wx.ID_ABOUT, "&About", " Information about this program") filemenu.AppendSeparator() filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program") # Creating the menubar. menuBar = wx.MenuBar() menuBar.Append(filemenu, "&File") # Adding the "filemenu" to the MenuBar self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content self.Show(True) app = wx.App(False) frame = MainWindow(None, "Sample editor") app.MainLoop() Reference: http://wiki.wxpython.org/Getting%20Started 9
  • 10. GUI designer application for wxWidgets toolkit wxFormBuilder (wxFB) 10
  • 11. Introduction to wxFB • wxFormBuilder is an open source GUI designer application for wxWidgets toolkit. – a visual development tool – File extension: *.fbp • can emit C++ (*.h & *.cpp), Python (*.py) and XRC (*.xrc) codes • wxFormBuilder have a rich set of supported widgets. – http://en.wikipedia.org/wiki/WxFormBuilder 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. Press F8, and gui.py will be generated http://goo.gl/RxGD6 16
  • 17. Event Handlers (1/2) # file: gui.py (generated by wxFB) import wx import wx.xrc ########################################################################### ## Class Sheetaholics_MainFrame ########################################################################### class Sheetaholics_Main ( wx.Frame ): def __init__( self, parent ): ... ( codes for layout ) # Connect Events self.btn_dottedlined_genpdf.Bind( wx.EVT_BUTTON, self.btn_dottedlined_genpdfOnButtonClick ) def __del__( self ): pass # Virtual event handlers, override them in your derived class def btn_dottedlined_genpdfOnButtonClick( self, event ): event.Skip() 17
  • 18. Event Handlers (2/2) # file: main.py import gui # import gui.py, which was generated by wxFB import wx class Sheetaholics_MainFrame( gui.Sheetaholics_MainFrame ): # inherit gui.Sheetaholics_MainFrame def __init__( self, parent ): gui.Sheetaholics_MainFrame.__init__( self, parent ) # handler for Sheetaholics_MainFrame event def btn_dottedlined_genpdfOnButtonClick( self, event ): ... ( event handler contents here ) class SheetaholicsMain(wx.App): def OnInit(self): self.m_frame = Sheetaholics_MainFrame(None) self.m_frame.Show() return True app = SheetaholicsMain(0) app.MainLoop() 18
  • 19. References • wxWidgets • http://wxwidgets.org/ • wxPython – http://wxpython.org/ – http://wiki.wxpython.org/How%20to%20Learn%20wxPyth on – http://wiki.wxpython.org/Getting%20Started • wxFormBuilder – http://wxformbuilder.org/ – http://sourceforge.net/apps/mediawiki/wxformbuilder/in dex.php?title=Tutorials – http://en.wikipedia.org/wiki/WxFormBuilder 19
  • 20. Q&A 20