Change font : StaticText « wxPython « Python Tutorial






Change font
import wx

class StaticTextFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Static Text Example', size=(400, 300))
        panel = wx.Panel(self, -1)
        wx.StaticText(panel, -1, "This is an example of static text", (100, 10))
        str = "You can also change the font."
        text = wx.StaticText(panel, -1, str, (20, 100))
        font = wx.Font(18, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)
        text.SetFont(font)

app = wx.PySimpleApp()
frame = StaticTextFrame()
frame.Show()
app.MainLoop()








19.40.StaticText
19.40.1.StaticText background colorStaticText background color
19.40.2.Center a textCenter a text
19.40.3.Align text to rightAlign text to right
19.40.4.Change fontChange font
19.40.5.Multiline textMultiline text
19.40.6.Multiline text with right alignmentMultiline text with right alignment