Show Menu
Cheatography

wx Python Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Python classes

Panel
wx.Python
Frame
wx.Frame
Text
wx.Sta­ticText
Input field
wx.Tex­tCtrl
Vertical box
wx.Box­Siz­er(­wx.V­ER­TICAL)
Horizontal box
wx.Box­Siz­er(­wx.H­OR­IZO­NTAL)

Maak box

    def maakBoxje(self, getal):
        tekstpaneel = wx.StaticText(self, -1, getal)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(tekstpaneel, 1, updown)
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hbox, 1, leftright)
        return vbox

Centreer box

    def centreer(self, paneel):
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(paneel, 1, wx.CENTER)
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hbox, 1, wx.CENTER)
        return vbox

Boxes

Add panel to box
box.Ad­d(­panel, ratio, wx.EXPAND)
Add text to box
box.Ad­d(w­x.S­tat­icT­ext­(self, -1, "­te­xt­"), 1, wx.EXPAND)
Left
wx.ALI­GN_LEFT
Right
wx.ALI­GN_­RIGHT
Top
wx.ALI­GN_TOP
Bottom
wx.ALI­GN_­BOTTOM
Set box
self.S­etS­ize­r(­box)

Buttons

Button
wx.But­ton­(self, id, nameb­utton)
wx.EVT­_BUTTON
self.­nam­ebu­tto­n.G­et­Eve­ntO­bje­ct(­).G­etV­alue()
Toggle Button
wx.Tog­gle­But­ton­(self, id, nameb­utton)
wx.EVT­_TO­GGL­EBUTTON
self.­nam­ebu­tto­n.G­et­Value()
Radiobox Button
wx.Rad­ioBox
-
self.­nam­ebu­tto­n.G­et­Sel­ect­ion()
Spin Button
wx.Spi­nBu­tto­n(self, -1)
wx.EVT­_SPIN
self.e­ven­t.G­etP­osi­tion()

Frame

Hide, Maximize, Minimize button
wx.Fr­ame.__­ini­t__­(self, parent, id, title, size=(­307­,289), style = wx.CLO­SE_­BOX­|wx.SY­STE­M_MENU | wx.CAPTION | wx.CLI­P_C­HILDREN | wx.MIN­IMI­ZE_BOX | wx.MAX­IMI­ZE_­BOX)
Resize NOT
style = wx.DEF­AUL­T_F­RAM­E_STYLE &(­~wx.RE­SIZ­E_B­ORDER)
Position
self.S­etP­osi­tio­n(­length, width)
Put in center
self.C­entre()

StaticText

Font
font = wx.Fon­t(60, wx.DEC­ORA­TIVE, wx.ITALIC, wx.BOLD)
font.M­ak­eBo­ld(­).M­ake­Ita­lic­().M­ak­eUn­der­lin­ed()
font.S­et­Poi­ntS­ize­(p­oin­tsi­ze)
Use font
text.S­etF­ont­(font)

Panels

Background colour
panel.S­et­Bac­kgr­oun­dCo­lou­r(w­x.RED)