You are on page 1of 6

wxPython

Justin @ JinRui Garden

http://www.leigao.org/blog/archives/434

1 wxPython wxFormBuilder
wxPython BOA

BOA BOA
wxFormBuilder UI GTK Glade
wxFormBuilder wxPython Python C++
XRC wxWidget
wxFormBuilder
wx.App() wxFormBuilder UI FramePanelDialog
MenuBar ToolBar UI wx.App()

wxFormBuilder
1
2 Sizer
3
4
5
wxFormBuilder

2 wxFormBuilder
wxPython UI wxFormBuilder
wxFormBuilder
1wxFormBuilder 2
34

Ubuntu 10.04 LTSwxFormBuilder 3.2.3-beta


1

2 WXFORMBUILDER

wxFormBuilder Ubuntu wxFormBuilder Launchpad


https://launchpad.net/~wxformbuilder/+archive/release
Linux
wxFormBuilder
http://sourceforge.net/apps/wordpress/wxformbuilder/downloads/
1
Base64 2 Base64
UI

UI UI
wxPython Sizer sizer wxFormBuilder
2

2 WXFORMBUILDER

wxFormBuilder

FramePanelDialog
FormsFrame
wxFormBuilder wysiwyg IDE Frame
Frame
name Frame

OK Frame Sizer Sizer wxFormBuilder Sizer

gSizer1 wxGridSizerwxGridSizer

gSizer
2X1 SizergSizer2 gSizer3 gSizer1
gSizer1 2X1 Sizer fgSizer1 Sizer Sizer
wxFlexGridSizer bSizer1
SizerwxBoxSizer Sizer

F8 UI
F8 Frame
wx.App py
py Frame
import wx
import Base64CodecMainFrame
# F8
app = wx.App( )
main_frm = Base64CodecMainFrame . Base64CodecFrame(None)
Frame
main_frm .Show( )

app . MainLoop ( )
Frame Frame 4
Button
Encode String
3

WXFORMBUILDER UI

Result UI
UI Button
Events
OnButtonClick

UI F8

EncodeString

def EncodeString ( s el f , event ) :


try :
import base64
except :
s e l f . m_textCtrl2 . SetValue ( "ERROR: Could NOT load module ``base64 ' ' " )
return
_ i s t r = s e l f . m_textCtrl1 . GetValue ( )
_ostr = None
try :
_ostr = base64 . encodestring ( _ i s t r )
except :
s e l f . m_textCtrl2 . SetValue ( "ERROR: Could NOT decode string : %s " % _ i s t r )
return
s e l f . m_textCtrl2 . SetValue ( _ostr . s t r i p ( ) )
event . Skip ( )
return

wxPython Demo

3 wxFormBuilder UI
wxFormBuilder wxFormBuilder

wxFormBuilder
GUI wxFormBuilder
wxFormBuilder
4

3 WXFORMBUILDER UI

wxFormBuilder UI UI UI

UML FindDialogFindDialogBase FindDialog

FindDialogBase wxFormBuilder FindDialog

1
2Quit
3

FindDialog

class FindDialog ( FindDialogBase ) :


'''
Implement the Find Dialog ;

'''

def _ _ i n i t _ _ ( s e l f , parent , filename = HIST_FILENAME) :


FindDialogBase . _ _ i n i t _ _ ( s e l f , parent )
# The history filenane ;
s e l f . HistFilename = filename
# The find history ;
s e l f . FindHistory = [ ]
# Disable the **Find** Button ;
s e l f . m_btnFind . Enable ( False )
# I n i t i a l i z e the find history ;
s e l f . __InitFindHistory ( )
# I n i t i a l i z e the String Combo Li s t ;
s e l f . __InitFindComboBox ( )
# Set window focus ;
s e l f . m_cmbString . SetFocus ( )
5

WXFORMBUILDER UI

FindDialog
UI

1
2
3
4 UI