J'ai un problème avec le constructeur personnalisé d'un formulaire (créé en C#) qui étend XtraForm de la bibliothèque DevExpress.v17.1. Il dispose de deux constructeurs:Constructeur de formulaire personnalisé avec pythonnet
protected BaseForm()
{
InitializeComponent();
}
et
protected BaseForm(IClient client)
{
InitializeComponent();
... many code
}
Où iClient est l'interface. Ce formulaire comporte de nombreuses dépendances et toutes sont compilées dans la bibliothèque. Quand je transmets ce formulaire et essayer de créer l'instance par code:
class TestApp(BaseForm):
def __init__(self):
self.Text = "Hello World From Python"
self.components = System.ComponentModel.Container()
self.AutoScaleBaseSize = Size(5, 13)
self.ClientSize = Size(392, 117)
h = WinForms.SystemInformation.CaptionHeight
self.MinimumSize = Size(392, (117 + h))
# Create the button
self.button = WinForms.Button()
self.button.Location = Point(160, 64)
self.button.Size = Size(150, 20)
self.button.TabIndex = 2
self.button.Text = "Click Me!"
# Register the event handler
self.button.Click += self.button_Click
# Create the text box
self.textbox = WinForms.TextBox()
self.textbox.Text = "Hello World"
self.textbox.TabIndex = 1
self.textbox.Size = Size(126, 40)
self.textbox.Location = Point(160, 24)
# Add the controls to the form
self.AcceptButton = self.button
self.Controls.Add(self.button)
self.Controls.Add(self.textbox)
def button_Click(self, sender, args):
"""Button click event handler"""
print ("Click")
WinForms.MessageBox.Show("Please do not press this button again.")
def run(self):
WinForms.Application.Run(self)
def Dispose(self):
self.components.Dispose()
WinForms.Form.Dispose(self)
exécuter du code init:
def main():
form = TestApp()
form.run()
form.Dispose()
if __name__ == '__main__':
main()
J'ai une erreur:
Traceback (most recent call last):
File "C:/Users/v.khvorostianyi/PycharmProjects/CSharp/Test.py", line 141, in <module>
main()
File "C:/Users/v.khvorostianyi/PycharmProjects/CSharp/Test.py", line 85, in main
form = TestApp()
TypeError: no constructor matches given arguments
Python = 3.6.2 , pythonnet = 2.3.0
.NET = 4.6.1
Pro Besoin d'un test automatisé, cette forme nécessaire pour le processus de travail. Pourquoi j'ai une telle erreur?
En classe python TestApp (BaseForm) Meen que TestApp étendre BaseForm. Merci d'essayer d'aider. –