0

I want to create a WinForms application. However, the application I want to run it with only supports Iron Python scripts.

Is there a way I can create the form in C#, and then call that exe from Iron Python?

I would build the form in Iron Python, but I am more comfortable/more experienced with C#.

Code Update:

I have the following code. I get an "IOException: file does not exist: EtechGenerator.dll". The dll is sitting next to the python file.

Folder:

enter image description here

This is my form class in C#:

public mainForm(int numLayers)
{
    _init = true;
    InitializeComponent();
}

This is my iron python script:

import clr
clr.AddReferenceToFileAndPath('EtechGenerator.dll')
import mainForm

obj = MainForm(3)
obj.Show()
user2970916
  • 1,146
  • 3
  • 15
  • 37

2 Answers2

0

It's worth noting that IronPython and Python are not the same thing. IronPython is built on the .NET framework and so should subscribe to all the usual features of .NET (like cross-compatibility, similar to C# and VB.NET code being able to interact).

I believe that this is the general concept you're looking for: Instantiating custom C# classes from IronPython

i.e. Something like the following:

import clr
clr.AddReference('MyAssemblyWhichContainsForm.dll')
import MyForm
obj = MyForm("form title")
obj.Show()
Community
  • 1
  • 1
Steve Lillis
  • 3,263
  • 5
  • 22
  • 41
0
import os
exe_path = os.path.join(os.path.dirname(__file__), 'EtechGenerator.exe')
os.startfile(exe_path)
user2970916
  • 1,146
  • 3
  • 15
  • 37