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.Add(panel, ratio, wx.EXPAND)
Add text to box
box.Ad­d(w­x.S­tat­icT­ext­(self, -1, "text"), 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­izer(box)

Buttons

Button
wx.But­ton­(self, id, namebutton)
wx.EVT­_BUTTON
self.namebutton.GetEv­ent­Obj­ect­().G­et­Value()
Toggle Button
wx.Tog­gle­But­ton­(self, id, namebutton)
wx.EVT­_TO­GGL­EBUTTON
self.namebutton.GetVa­lue()
Radiobox Button
wx.Rad­ioBox
-
self.namebutton.GetSe­lec­tion()
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.Fra­me._­_i­nit­__(­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­tion(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­ake­Bol­d().Ma­keI­tal­ic(­).M­ake­Und­erl­ined()
font.S­etP­oin­tSize(pointsize)
Use font
text.S­etF­ont­(font)

Panels

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