-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpython_shell_example.dart
More file actions
39 lines (32 loc) · 969 Bytes
/
python_shell_example.dart
File metadata and controls
39 lines (32 loc) · 969 Bytes
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
import "package:python_shell/python_shell.dart";
void main() async {
// 현재 스타일
// var shell = PythonShell(shellConfig: PythonShellConfig(
// pythonRequires: [ "PySide6" ],
// defaultWorkingDirectory: "example"
// ));
// await shell.initialize();
// await shell.runString("""
// import os, PySide6
// print("in python: ", os.getcwd())
// print("in python: ", PySide6)
// """, useInstance: true, instanceName: "testInstance1", listener: ShellListener(
// completeCallback: () {
// print(shell.resolved);
// // shell.clear();
// }
// ));
var shell = PythonShell(PythonShellConfig());
await shell.initialize();
var instance = ShellManager.getInstance("default");
instance.installRequires(["PySide6"]);
await instance.runString(
"""
import os, PySide6
print("in python: ", os.getcwd())
print("in python: ", PySide6)
""",
echo: true,
);
print("finished");
}