当用户点击由 Ironpython 创建的 winform 时如何禁用 OnClick() 事件?

How to disable OnClick() event when user clicks on winform created by Ironpython?

我正在编写 Ironpython 2.7.5 代码来显示 Winform 并从用户那里获取输入。每当我不小心点击表单时,它都会抛出错误 "OnClick() takes exactly 3 arguments (2 given)"。我该如何禁用此事件?

我使用 Notepad++ 编写我的代码,并 运行 在 ANSYS 工具中编写代码。下面是我的代码结构:

def init(context):
    #Something here
def OpenForm1(analysis_obj):
    form = SimpleTextBoxForm()
    Application.Run(form)
class SimpleTextBoxForm(Form):
    def __init__(self):
        self.Text = 'Material Tool V1.0'
        self.Size = Size(Width, Height)
        self.MaximizeBox = False
        self.MinimizeBox = False
        self.FormBorderStyle = FormBorderStyle.FixedDialog
        #Some other controls
    def OnChanged(self, sender, event):         #Triggered on change
        #Some Code
    def OnClick(self, sender, event):           #Triggered on button clicks
        try:
            #Something here
        except:
            #Something here

我想阻止此事件在我点击表单的任何地方触发。但是我做不到。

我明白了。我在点击事件中使用了冲突的名称

def OnClick()

我将其更改为其他名称并且效果很好。 如果有人遇到类似问题,请检查用户定义的方法名称,它可能与内置方法名称相同。