Tkinterで作ったGUI表示プログラムのマルチスレッド化を目指していますが、例外が発生して実行できません。
import sys import tkinter import concurrent.futures import logging def ShowWindow(): root = tkinter.Tk() root.mainloop() #/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #main #/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: f1 = executor.submit(ShowWindow)
2022-03-01 15:04:18.616 Python[3926:78677] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!' *** First throw call stack: ( 0 CoreFoundation 0x00007ff802a4ef0b __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8027afb9d objc_exception_throw + 48 2 CoreFoundation 0x00007ff802a778ca -[NSException raise] + 9 3 AppKit 0x00007ff805429171 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 321 4 AppKit 0x00007ff805414ee6 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1287 5 AppKit 0x00007ff8054149d9 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42 6 libtk8.6.dylib 0x000000010c8207fd TkMacOSXMakeRealWindowExist + 705 7 libtk8.6.dylib 0x000000010c82040e TkWmMapWindow + 63 8 libtk8.6.dylib 0x000000010c78650b Tk_MapWindow + 158 9 libtk8.6.dylib 0x000000010c78eed3 MapFrame + 59 10 libtcl8.6.dylib 0x000000010c56d38a TclServiceIdle + 75 11 libtcl8.6.dylib 0x000000010c551c5b Tcl_DoOneEvent + 337 12 libtk8.6.dylib 0x000000010c813263 TkpInit + 762 13 libtk8.6.dylib 0x000000010c78774d Initialize + 2402 14 _tkinter.cpython-37m-darwin.so 0x000000010c329dc4 Tcl_AppInit + 84 15 _tkinter.cpython-37m-darwin.so 0x000000010c324dee Tkapp_New + 606 16 _tkinter.cpython-37m-darwin.so 0x000000010c324945 _tkinter_create + 373 17 python3.7 0x000000010bbed1c6 _PyMethodDef_RawFastCallKeywords + 646 18 python3.7 0x000000010bbec599 _PyCFunction_FastCallKeywords + 41 19 python3.7 0x000000010bcbc456 call_function + 470 20 python3.7 0x000000010bcb90e1 _PyEval_EvalFrameDefault + 27745 21 python3.7 0x000000010bcbd16f _PyEval_EvalCodeWithName + 2639 22 python3.7 0x000000010bbec047 _PyFunction_FastCallDict + 455 23 python3.7 0x000000010bbed503 _PyObject_Call_Prepend + 131 24 python3.7 0x000000010bc3ec2f slot_tp_init + 175 25 python3.7 0x000000010bc3a504 type_call + 292 26 python3.7 0x000000010bbec3af _PyObject_FastCallKeywords + 575 27 python3.7 0x000000010bcbc4c2 call_function + 578 28 python3.7 0x000000010bcb90e1 _PyEval_EvalFrameDefault + 27745 29 python3.7 0x000000010bbeca7d function_code_fastcall + 237 30 python3.7 0x000000010bcb93f0 _PyEval_EvalFrameDefault + 28528 31 python3.7 0x000000010bbeca7d function_code_fastcall + 237 32 python3.7 0x000000010bcbc4e3 call_function + 611 33 python3.7 0x000000010bcb90c7 _PyEval_EvalFrameDefault + 27719 34 python3.7 0x000000010bbeca7d function_code_fastcall + 237 35 python3.7 0x000000010bcb93f0 _PyEval_EvalFrameDefault + 28528 36 python3.7 0x000000010bbeca7d function_code_fastcall + 237 37 python3.7 0x000000010bcbc4e3 call_function + 611 38 python3.7 0x000000010bcb90c7 _PyEval_EvalFrameDefault + 27719 39 python3.7 0x000000010bbeca7d function_code_fastcall + 237 40 python3.7 0x000000010bcbc4e3 call_function + 611 41 python3.7 0x000000010bcb90c7 _PyEval_EvalFrameDefault + 27719 42 python3.7 0x000000010bbeca7d function_code_fastcall + 237 43 python3.7 0x000000010bbed503 _PyObject_Call_Prepend + 131 44 python3.7 0x000000010bbec6b8 PyObject_Call + 136 45 python3.7 0x000000010bd46af7 t_bootstrap + 71 46 libsystem_pthread.dylib 0x00007ff80290c4f4 _pthread_start + 125 47 libsystem_pthread.dylib 0x00007ff80290800f thread_start + 15 ) libc++abi: terminating with uncaught exception of type NSException [ファイルパス]: line 4: 3926 Abort trap: 6 Python [ファイルパス]
tkinterのプログラムはメイン以外で実行してはいけない仕様なのでしょうか??
原因と解決方法を教えてほしいです。よろしくお願いします
回答1件
あなたの回答
tips
プレビュー