SetFont 不断失败,参数不匹配 - Apple OS

SetFont keeps failing with arguments did not match - Apple OS

我正在开发一个应用程序,它是 Mac 的十六进制编辑器,但我确实需要在更新设置为多行的 TextCtrl 时添加单声道 space 字体只读控件。其中有 3 个,一个显示十六进制的偏移量,一个显示实际的原始字节,第三个显示原始文本。我已经通过

设置了文本的前景色
self.mainTextArea.SetDefaultStyle(wx.TextAttr(wx.RED))

它工作得很好,但无论我尝试设置字体多少次,它都会出错:

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'

和另外七个重载参数。我试过将控件设置为 StaticText,并使用 Label 作为要更新的文本,RichTextControl 等等,但无论我如何更改 Ctrl,任何时候设置字体,它都会失败并出现上述错误。

文本控制和修改字体如下:

        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)

是否可以更改 Apple 上的字体 OS 或者我做错了什么?

谢谢!

抱歉YYC_CODE,我很匆忙,只是敲了评论。

提供字体的所有参数,即 SetFont(wx.Font(11, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, font_weight, font_underline, font_name)。你缺少的3个可以来自现有字体,也可以单独声明它们。

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)

我认为只有最后2/3是可选的