File structure for python project:
Root
ConfigGenerator
__config_generator.py
config.py
__config_generator.py:
import config
CONFIG = config.Config()
def __main():
# there are redundant to the question code
if __name__ == '__main__':
__main()
And now C# project:
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using System;
using System.Windows.Forms;
namespace ProjectName
{
public partial class MainForm : Form
{
private ScriptEngine _engine;
public MainForm()
{
_engine = Python.CreateEngine();
InitializeComponent();
}
private void StartConfigGenerator_Click(object sender, EventArgs e)
{
RunScript(@"Q:\Project\Python\Bots\Root\ConfigGenerator\__config_generator.py");
}
private void RunScript(string path)
{
_engine.ExecuteFile(path);
}
}
}
0 comments:
Post a Comment
Thanks