【Python】Pycharm + wx3 でエラー
PycharmのPython Console使用時に発生したエラー。
おそらくbackednをpyqt4からwxに変更したことも関係あると思われる。
C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2017.1\helpers\pydev\pydev_ipython\inputhookwx.py
def inputhook_wx3(): """Run the wx event loop by processing pending events only. This is like inputhook_wx1, but it keeps processing pending events until stdin is ready. After processing all pending events, a call to time.sleep is inserted. This is needed, otherwise, CPU usage is at 100%. This sleep time should be tuned though for best performance. """ # We need to protect against a user pressing Control-C when IPython is # idle and this is running. We trap KeyboardInterrupt and pass. try: app = wx.GetApp() # @UndefinedVariable if app is not None: assert wx.IsMainThread() # @UndefinedVariable # The import of wx on Linux sets the handler for signal.SIGINT # to 0. This is a bug in wx or gtk. We fix by just setting it # back to the Python default. if not callable(signal.getsignal(signal.SIGINT)): signal.signal(signal.SIGINT, signal.default_int_handler) evtloop = wx.GUIEventLoop() # @UndefinedVariable ea = wx.EventLoopActivator(evtloop) # @UndefinedVariable t = clock() while not stdin_ready(): while evtloop.Pending(): t = clock() evtloop.Dispatch() #app.ProcessIdle() wx.WakeUpIdle()
wx3になって
wx.Thread_IsMain() が wx.IsMainThread に変更されているのに
プログラム内ではwx2のままが原因。
ほかにも
wx.EventLoop() が wx.GUIEventLoop() を使うよう推奨されていたので変更した。