質問編集履歴

1

wsPythonに関する部分以外のコードも掲載しました

2022/10/05 20:53

投稿

plata10
plata10

スコア0

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,11 @@
16
16
 
17
17
  ### 該当のソースコード
18
18
 
19
- ```Python
19
+ ```Python(run.py)
20
+ import eel
21
+ import wx
22
+
23
+
20
24
  @eel.expose
21
25
  def get_file_path(wildcard="*"):
22
26
  app = wx.App()
@@ -30,6 +34,34 @@
30
34
  dialog.Destroy()
31
35
 
32
36
  return path
37
+
38
+
39
+ eel.init("static")
40
+ eel.start("main.html")
41
+ ```
42
+
43
+ ```JS(static/js/main.js)
44
+ async function getFilePath() {
45
+ let path = await eel.get_file_path()();
46
+ document.getElementById("file-path").innerHTML = path;
47
+ }
48
+ ```
49
+
50
+ ```HTML(static/main.html)
51
+ <html>
52
+ <head>
53
+ <meta charset="UTF-8">
54
+ <title>Pythonアプリ</title>
55
+ </head>
56
+ <body>
57
+ <section>
58
+ <button onclick="getFilePath()">ファイルを開く</button>
59
+ <p id="file-path"></p>
60
+ </section>
61
+ <script type="text/javascript" src="/eel.js"></script>
62
+ <script type="text/javascript" src="./js/main.js"></script>
63
+ </body>
64
+ </html>
33
65
  ```
34
66
 
35
67
  ### 試したこと
@@ -44,5 +76,6 @@
44
76
  ・Windows 10
45
77
  ・Python 3.10.7
46
78
  ・wxPython 4.2.0
79
+ ・Eel 0.14.0
47
80
 
48
81
  以上、よろしくお願いいたします。