2011-03-05 15 views

risposta

37

use object.SetFont. Per esempio (da wxpython in Action):

text = wx.StaticText(panel, -1, 'my text', (20, 100)) 
font = wx.Font(18, wx.DECORATIVE, wx.ITALIC, wx.NORMAL) 
text.SetFont(font) 

wx.Font ha la seguente firma:

wx.Font(pointSize, family, style, weight, underline=False, faceName="", encoding=wx.FONTENCODING_DEFAULT) 

famiglia può essere:

wx.DECORATIVE, wx.DEFAULT, wx .MODERN, wx.ROMAN, wx.SCRIPT o wx.SWISS.

stile può essere:

wx.NORMAL, wx.SLANT o wx.ITALIC.

peso può essere:

wx.NORMAL, wx.LIGHT, o wx.BOLD

+2

Se qualcun altro è curioso, il metodo 'SetFont' proviene da [il' finestra 'class] (http://wxpython.org/docs/api/wx.Window-class.html). – bdesham

+0

Come posso impostare il carattere per una sola sezione del testo? Dovrei usare due diversi comandi 'StaticText'? – fatuhoku

+1

@fatuhoku Un 'wx.StaticText' può avere più righe di testo, ma non può gestire più caratteri. Per più tipi di carattere o stili è possibile utilizzare, ad esempio, un 'wx.html.HTMLWindow' – joaquin