SlideShare a Scribd company logo
1 of 20
Download to read offline
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

What's hot

Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.netJaya Kumari
 
Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming francopw
 
Basic exercises for photoshop
Basic exercises for photoshopBasic exercises for photoshop
Basic exercises for photoshopPauline Torion
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 
Java Foundations: Objects and Classes
Java Foundations: Objects and ClassesJava Foundations: Objects and Classes
Java Foundations: Objects and ClassesSvetlin Nakov
 
Python Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingPython Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingRanel Padon
 
An Intro to Atom Editor
An Intro to Atom EditorAn Intro to Atom Editor
An Intro to Atom EditorAteev Chopra
 
Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Ankit Gupta
 

What's hot (20)

Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming
 
Atom IDE
Atom IDEAtom IDE
Atom IDE
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Vb basics
Vb basicsVb basics
Vb basics
 
Meaning Of VB
Meaning Of VBMeaning Of VB
Meaning Of VB
 
Vb.net tutorial
Vb.net tutorialVb.net tutorial
Vb.net tutorial
 
Basic exercises for photoshop
Basic exercises for photoshopBasic exercises for photoshop
Basic exercises for photoshop
 
4. features of .net
4. features of .net4. features of .net
4. features of .net
 
VB.net
VB.netVB.net
VB.net
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Id and class selector
Id and class selectorId and class selector
Id and class selector
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Java Foundations: Objects and Classes
Java Foundations: Objects and ClassesJava Foundations: Objects and Classes
Java Foundations: Objects and Classes
 
Python Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingPython Programming - XIII. GUI Programming
Python Programming - XIII. GUI Programming
 
Java swing
Java swingJava swing
Java swing
 
Visual Studio IDE
Visual Studio IDEVisual Studio IDE
Visual Studio IDE
 
An Intro to Atom Editor
An Intro to Atom EditorAn Intro to Atom Editor
An Intro to Atom Editor
 
Controls events
Controls eventsControls events
Controls events
 
Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)
 

Viewers also liked

Lightning Talk: jsPDF
Lightning Talk: jsPDFLightning Talk: jsPDF
Lightning Talk: jsPDFJenny Liang
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングRansui Iso
 
Портфолио Курмаевой С.И.
Портфолио Курмаевой С.И.Портфолио Курмаевой С.И.
Портфолио Курмаевой С.И.ipevm1979
 
Gender mainstreaming of public campaigns
Gender mainstreaming of public campaignsGender mainstreaming of public campaigns
Gender mainstreaming of public campaignsElise Beyst
 
Art & science part ii
Art & science part iiArt & science part ii
Art & science part iiCormac McGrath
 
Контент и конверсионный трафик. Взаимное влияние
Контент и конверсионный трафик. Взаимное влияниеКонтент и конверсионный трафик. Взаимное влияние
Контент и конверсионный трафик. Взаимное влияниеАнастасия Эебердиева
 
Выпускной
ВыпускнойВыпускной
ВыпускнойAkuJIa
 
школы агинское итоги егэ_гиа_2011
школы агинское итоги егэ_гиа_2011школы агинское итоги егэ_гиа_2011
школы агинское итоги егэ_гиа_2011biolog259
 
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазіїМіський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії08600 Vasilkov
 
MSH Design Brochure (draft / test)
MSH Design Brochure (draft / test)MSH Design Brochure (draft / test)
MSH Design Brochure (draft / test)MSHDinc
 
Technology and Education
Technology and EducationTechnology and Education
Technology and Educationrogersc05
 
[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介
[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介
[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介DNA Data Bank of Japan center
 

Viewers also liked (20)

Lightning Talk: jsPDF
Lightning Talk: jsPDFLightning Talk: jsPDF
Lightning Talk: jsPDF
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミング
 
Портфолио Курмаевой С.И.
Портфолио Курмаевой С.И.Портфолио Курмаевой С.И.
Портфолио Курмаевой С.И.
 
Gender mainstreaming of public campaigns
Gender mainstreaming of public campaignsGender mainstreaming of public campaigns
Gender mainstreaming of public campaigns
 
Art & science part ii
Art & science part iiArt & science part ii
Art & science part ii
 
המעצבים עבודות חוץ
המעצבים עבודות חוץהמעצבים עבודות חוץ
המעצבים עבודות חוץ
 
Spice
SpiceSpice
Spice
 
Контент и конверсионный трафик. Взаимное влияние
Контент и конверсионный трафик. Взаимное влияниеКонтент и конверсионный трафик. Взаимное влияние
Контент и конверсионный трафик. Взаимное влияние
 
Выпускной
ВыпускнойВыпускной
Выпускной
 
школы агинское итоги егэ_гиа_2011
школы агинское итоги егэ_гиа_2011школы агинское итоги егэ_гиа_2011
школы агинское итоги егэ_гиа_2011
 
47 amazing blog designs
47 amazing blog designs47 amazing blog designs
47 amazing blog designs
 
Sath poomch
Sath poomchSath poomch
Sath poomch
 
Lettura
LetturaLettura
Lettura
 
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазіїМіський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
Міський етап Всеукраїнського гуманітарного конкурсу КосмічнІ фантазії
 
Pecha Kucha
Pecha KuchaPecha Kucha
Pecha Kucha
 
Carlos carolinajessica
Carlos carolinajessicaCarlos carolinajessica
Carlos carolinajessica
 
Apexcse
ApexcseApexcse
Apexcse
 
MSH Design Brochure (draft / test)
MSH Design Brochure (draft / test)MSH Design Brochure (draft / test)
MSH Design Brochure (draft / test)
 
Technology and Education
Technology and EducationTechnology and Education
Technology and Education
 
[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介
[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介
[DDBJing29]DDBJ Sequence Read Archive (DRA) の紹介
 

Similar to wxPython and wxFormBuilder

Introducing PanelKit
Introducing PanelKitIntroducing PanelKit
Introducing PanelKitLouis D'hauwe
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201ylefebvre
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84Mahmoud Samir Fayed
 
Introduction to eZ Platform v2 UI Customization
Introduction to eZ Platform v2 UI CustomizationIntroduction to eZ Platform v2 UI Customization
Introduction to eZ Platform v2 UI CustomizationJani Tarvainen
 
BLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docxBLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docxmoirarandell
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Maurizio Pelizzone
 
OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016Stephen Fink
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHPWilliam Lee
 
Lesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupLesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupUniversity of Catania
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with ComposerAdam Englander
 
The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185Mahmoud Samir Fayed
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java binOlve Hansen
 
Relaxing CNDs Hippo GetTogether
Relaxing CNDs Hippo GetTogetherRelaxing CNDs Hippo GetTogether
Relaxing CNDs Hippo GetTogetherFrank Van Lankvelt
 

Similar to wxPython and wxFormBuilder (20)

Getting started with wxWidgets
Getting started with wxWidgets Getting started with wxWidgets
Getting started with wxWidgets
 
GNURAdioDoc-8
GNURAdioDoc-8GNURAdioDoc-8
GNURAdioDoc-8
 
GNURAdioDoc-8
GNURAdioDoc-8GNURAdioDoc-8
GNURAdioDoc-8
 
Introducing PanelKit
Introducing PanelKitIntroducing PanelKit
Introducing PanelKit
 
manual
manualmanual
manual
 
manual
manualmanual
manual
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
 
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.2 book - Part 51 of 84
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
Introduction to eZ Platform v2 UI Customization
Introduction to eZ Platform v2 UI CustomizationIntroduction to eZ Platform v2 UI Customization
Introduction to eZ Platform v2 UI Customization
 
BLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docxBLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docx
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
 
OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHP
 
Lesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupLesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment Setup
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
 
The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
 
Relaxing CNDs Hippo GetTogether
Relaxing CNDs Hippo GetTogetherRelaxing CNDs Hippo GetTogether
Relaxing CNDs Hippo GetTogether
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

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