回答編集履歴
1
コードの追加
test
CHANGED
@@ -1 +1,63 @@
|
|
1
1
|
色々調べた所、tkinterはメインプロセス(メインスレッド)以外でmainloopを読んではいけないらしいので、pyqtを使ったらGUIのmainloopをサブプロセスで起動することができました。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
下記のようなコードで目的を達成できました。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```python
|
10
|
+
|
11
|
+
#!/usr/bin/env python
|
12
|
+
|
13
|
+
# -*- coding: utf-8 -*-
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
from PyQt4.QtCore import *
|
18
|
+
|
19
|
+
from PyQt4.QtGui import *
|
20
|
+
|
21
|
+
import time
|
22
|
+
|
23
|
+
import sys
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
from multiprocessing import Process
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
def app():
|
32
|
+
|
33
|
+
app = QApplication(sys.argv)
|
34
|
+
|
35
|
+
win = QLabel("Hello PyQt4 world")
|
36
|
+
|
37
|
+
win.show()
|
38
|
+
|
39
|
+
app.exec_()
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
#start GUI process
|
44
|
+
|
45
|
+
p = Process(target=app)
|
46
|
+
|
47
|
+
p.start()
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
#Main process
|
52
|
+
|
53
|
+
count=0
|
54
|
+
|
55
|
+
while 1:
|
56
|
+
|
57
|
+
count=count+1
|
58
|
+
|
59
|
+
print count
|
60
|
+
|
61
|
+
time.sleep(1)
|
62
|
+
|
63
|
+
```
|