wx.FontPickerCtrl¶
This control allows the user to select a font.
The generic implementation is a button which brings up a wx.FontDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the font-chooser dialog. It is only available if USE_FONTPICKERCTRL
is set to 1 (the default).
Window Styles¶
This class supports the following styles:
wx.FNTP_DEFAULT_STYLE
: The default style:wx.FNTP_FONTDESC_AS_LABEL
|wx.FNTP_USEFONT_FOR_LABEL
.wx.FNTP_USE_TEXTCTRL
: Creates a text control to the left of the picker button which is completely managed by the wx.FontPickerCtrl and which can be used by the user to specify a font (see SetSelectedFont). The text control is automatically synchronized with button’s value. Use functions defined in wx.PickerBase to modify the text control.wx.FNTP_FONTDESC_AS_LABEL
: Keeps the label of the button updated with the fontface name and the font size. E.g. choosing “Times New Roman bold, italic withsize 10” from the fontdialog, will update the label (overwriting any previous label) with the “Times New Roman, 10” text.
wx.FNTP_USEFONT_FOR_LABEL
: Uses the currently selected font to draw the label of the button.
Events Emitted by this Class¶
Handlers bound for the following event types will receive a wx.FontPickerEvent parameter.
EVT_FONTPICKER_CHANGED: The user changed the font selected in the control either using the button or using text control (see
wx.FNTP_USE_TEXTCTRL
; note that in this case the event is fired only if the user’s input is valid, i.e. recognizable).
See also
Class Hierarchy¶
Control Appearance¶
Methods Summary¶
Creates this widget with given parameters. |
|
Returns the maximum point size value allowed for the user-chosen font. |
|
Returns the minimum point size value allowed for the user-chosen font. |
|
Returns the currently selected colour. |
|
Returns the currently selected font. |
|
Sets the maximum point size value allowed for the user-chosen font. |
|
Sets the minimum point size value allowed for the user-chosen font. |
|
Sets the font colour. |
|
Sets the currently selected font. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.FontPickerCtrl(PickerBase)¶
Possible constructors:
FontPickerCtrl() -> None FontPickerCtrl(parent, id=ID_ANY, font=NullFont, pos=DefaultPosition, size=DefaultSize, style=FNTP_DEFAULT_STYLE, validator=DefaultValidator, name=FontPickerCtrlNameStr) -> None
This control allows the user to select a font.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
- Return type:
None
__init__ (self, parent, id=ID_ANY, font=NullFont, pos=DefaultPosition, size=DefaultSize, style=FNTP_DEFAULT_STYLE, validator=DefaultValidator, name=FontPickerCtrlNameStr)
Initializes the object and calls
Create
with all the parameters.- Parameters:
parent (wx.Window)
id (wx.WindowID)
font (wx.Font)
pos (wx.Point)
size (wx.Size)
style (long)
validator (wx.Validator)
name (string)
- Return type:
None
- Create(self, parent, id=ID_ANY, font=NullFont, pos=DefaultPosition, size=DefaultSize, style=FNTP_DEFAULT_STYLE, validator=DefaultValidator, name=FontPickerCtrlNameStr)¶
Creates this widget with given parameters.
- Parameters:
parent (wx.Window) – Parent window, must not be not
None
.id (wx.WindowID) – The identifier for the control.
font (wx.Font) – The initial font shown in the control. If
wx.NullFont
is given, the default font is used.pos (wx.Point) – Initial position.
size (wx.Size) – Initial size.
style (long) – The window style, see
FNTP_
flags.validator (wx.Validator) – Validator which can be used for additional data checks.
name (string) – Control name.
- Return type:
bool
- Returns:
True
if the control was successfully created orFalse
if creation failed.
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
- GetMaxPointSize(self)¶
Returns the maximum point size value allowed for the user-chosen font.
- Return type:
int
- GetMinPointSize(self)¶
Returns the minimum point size value allowed for the user-chosen font.
- Return type:
int
Added in version 4.1/wxWidgets-3.1.1.
- GetSelectedColour(self)¶
Returns the currently selected colour.
Note that the colour of the font can only be set by the user under Windows currently, elsewhere this method simply returns the colour previously set by
SetSelectedColour
or black if it hadn’t been called.- Return type:
Added in version 4.1/wxWidgets-3.1.0.
- GetSelectedFont(self)¶
Returns the currently selected font.
Note that this function is completely different from
wx.Window.GetFont
.- Return type:
- SetMaxPointSize(self, max)¶
Sets the maximum point size value allowed for the user-chosen font.
The default value is 100. Note that big fonts can require a lot of memory and
CPU
time both for creation and for rendering; thus, specially because the user has the option to specify the fontsize through a text control (seewx.FNTP_USE_TEXTCTRL
), it’s a good idea to put a limit to the maximum font size when huge fonts do not make much sense.- Parameters:
max (int)
- Return type:
None
- SetMinPointSize(self, min)¶
Sets the minimum point size value allowed for the user-chosen font.
The default value is 0.
- Parameters:
min (int)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.1.
- SetSelectedColour(self, colour)¶
Sets the font colour.
The font colour is actually only used under Windows currently, but this function is available under all platforms for consistency.
- Parameters:
colour (wx.Colour)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.0.
- SetSelectedFont(self, font)¶
Sets the currently selected font.
Note that this function is completely different from
wx.Window.SetFont
.- Parameters:
font (wx.Font)
- Return type:
None
Properties¶
- MaxPointSize¶
See
GetMaxPointSize
andSetMaxPointSize
- MinPointSize¶
See
GetMinPointSize
andSetMinPointSize
- SelectedColour¶
See
GetSelectedColour
andSetSelectedColour
- SelectedFont¶
See
GetSelectedFont
andSetSelectedFont