Pyobjc and wx crash on program termination

Like this question, wxPython + PyObjC causes the application to crash at the end , but there the code has more redundant code.

I have the following two code examples, the last one will work, and the first one works fine.

The only difference in the code is the import order.

This code is working fine.

import time

# note that the line is before this is so the code does work this is the only
# change that seems to matter
# need the following line to be AFTER wx import otherwise runs fine
import objc # or import Foundation or probably any objc library

import wx



# need the following line
app = wx.App(redirect=False)

# sleep shows it is ONLY when the code finally ends not before
time.sleep(3)
# you don't even need the MainLoop call

This code launches segfaults when the program crashes.

import time

import wx
# need this line to be AFTER wx import otherwise runs fine
import objc # or import Foundation or probably any objc library


# need the following line
app = wx.App(redirect=False)

# sleep shows it is ONLY when the code finally ends not before
time.sleep(3)
# you don't even need the MainLoop call

How to replicate

  • Make sure pyobjc is installed and you can import objc
  • Make sure wxPython is installed (it seems that both 2.9 and 3.0 are running).
  • execute python command
+4
source share
1

. - .

, , , ,

objc , wx (, , , , wx ( wx)).

0

Source: https://habr.com/ru/post/1535067/


All Articles