forked from yagweb/pythonnetLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
77 lines (66 loc) · 2.77 KB
/
Copy pathProgram.cs
File metadata and controls
77 lines (66 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Python.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program
{
// Config the embedded CPython
static void PythonInitialize()
{
// Set the PATH env variable for OS pythonXX.dll searching
// or put the pythonXX.dll into the current working directory or a directory in PATH
// Attension, PythonHome cannot be used for dll search!
//string python = @"C:\Python\WinPython-64bit-2.7.10.3\python-2.7.10.amd64";
//string python = @"C:\Python\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64";
//string python = "C:\\Anaconda3";
string python = "C:\\Anaconda3.5";
Environment.SetEnvironmentVariable("PATH", python, EnvironmentVariableTarget.Process);
// it will be used to set the PythonPath with defaut values
PythonEngine.PythonHome = python;
//Console.WriteLine(PythonEngine.PythonPath);
// Sometimes, we don't want to embed a completed CPython,
// and we only want to distrute our app with miminum files
// then, we can set the Python Module search Path by hand
//PythonEngine.PythonPath = String.Join(";", new List<string>() {
// $"{python}\\DLLs",
// $"{python}\\Lib",
// $"{python}\\Lib\\site_packages",
//});
//PythonEngine.ProgramName = "RuePyNet";
PythonEngine.Initialize();
PythonEngine.BeginAllowThreads(); //need be removed into the future
//redirect python print to .NET Console
PySysIO.ToConsoleOut();
}
//[MTAThread]
//[STAThread]
static int Main(string[] args)
{
PythonInitialize();
//new TestSysIO().ToConsoleOut();
//new TestSysIO().ToNullTextWriter();
//new TestSysIO().ToTextWriter();
//TestPyQt.PyQt4PurePython(); //passed
//TestPyQt.PyQt5PurePython(); //failed
// Py3.6 + Qt5Agg, crashed down!
// Py3.6 + TkAgg backend, passed
// Py3.5 + TkAgg backend, passed
// Py3.5 + Qt4Agg backend, passed
//TestMatplotlib.SetUp("TkAgg");
//TestMatplotlib.SetUp("Qt4Agg");
//TestMatplotlib.SetUp("Qt5Agg"); //program crashed!
//TestMatplotlib.Plot();
//TestMatplotlib.PlotInWindow();
// API is not stable.
//new TestPyConverter().TestList();
//new TestPyConverter().TestDict();
//new TestPyConverter().TestObject();
//new TestPyConverter().TestHybird();
REPLinWPF.Main();
return 0;
}
}
}