我正在使用Pythonnet在Python上尝试简单的Winform应用程序。但是我无法正确地做这件事。
import clr
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
from System.Windows.Forms import Application, Form, Label
from System.Drawing import Size, Point, Font
text = """some large text"""
class IForm(Form):
def __init__(self):
self.Text = "You know I'm No Good"
font = Font("Serif", 10)
lyrics = Label()
lyrics.Parent = self
lyrics.Text = text
lyrics.Font = font
lyrics.Location = Point(10, 10)
lyrics.Size = Size(290, 290)
self.CenterToScreen()
Application.Run(IForm())
font = font(" serif",10)
TypeError:没有给定参数的构造函数匹配
是否需要任何特殊规定?
尝试 Font("Serif", 10.0)
-浮子被接受,而不是整数。pythonnet中不支持隐式转换。