I am developing an app which is a Hex editor for Mac's, but I really need to add a mono-space font when updating the TextCtrl's, which are set as multi line read only controls. There are 3 of them, one shows the offset in Hex, one shows the actual raw bytes, and the third would show the raw text. I have set the foreground colour of the text via
self.mainTextArea.SetDefaultStyle(wx.TextAttr(wx.RED))
and it works perfectly, but no matter how many times I try to set the font, it errors with:
self.mainTextArea.SetFont(wx.Font(11, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL))
TypeError: Font(): arguments did not match any overloaded call:
overload 1: too many arguments
overload 2: argument 1 has unexpected type 'tuple'
and seven more overloaded arguments. I've tried setting the control to StaticText, and using the Label as the text to be updated, RichTextControl, etc, etc, but no matter how I change the Ctrl, any time I set the font, it fails with the error above.
The text control and modifying the font is as follows:
self.mainTextArea = wx.TextCtrl(panel,2, size=(630,650),style=wx.TE_READONLY|wx.VSCROLL|wx.HSCROLL|wx.TE_MULTILINE|
wx.TE_RICH2)
self.mainTextArea.SetFont(wx.Font(11, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL))
self.mainTextArea.SetBackgroundColour((0,0,0))
self.mainTextArea.SetDefaultStyle(wx.TextAttr(wx.RED))
vBoxMT.Add(self.mainTextArea, wx.EXPAND)
Is it possible to change the font on an Apple OS or what am I doing wrong?
Thanks!
Sorry YYC_CODE, I was in a hurry and just banged in a comment.
Supply all of the arguments for font i.e. SetFont(wx.Font(11, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, font_weight, font_underline, font_name). The 3 you are missing can come from the existing font or you can declare them separately.
A font is an object which determines the appearance of text, primarily when drawing text to a window or device context. A font is determined by the following parameters (not all of them have to be specified, of course):
Point size This is the standard way of referring to text size.
Family Supported families are: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS, wx.MODERN. wx.MODERN is a fixed pitch font; the others are either fixed or variable pitch.
Style The value can be wx.NORMAL, wx.SLANT or wx.ITALIC.
Weight The value can be wx.NORMAL, wx.LIGHT or wx.BOLD.
Underlining The value can be True or False.
Face name An optional string specifying the actual typeface to be used. If None, a default typeface will chosen based on the family.
Encoding The font encoding (see wx.FONTENCODING_XXX constants and the Font Encodings for more details)
I think only the last 2/3 are optional