Skip to content

Commit 7c3ffb5

Browse files
committed
Fix wxpython.py example running wxPython 4.0 on Mac (cztomczak#350).
Fix searching for Python.h include file when building with system Python 3 on Mac.
1 parent b359129 commit 7c3ffb5

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

examples/wxpython.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,31 @@ class CefApp(wx.App):
191191
def __init__(self, redirect):
192192
self.timer = None
193193
self.timer_id = 1
194+
self.is_initialized = False
194195
super(CefApp, self).__init__(redirect=redirect)
195196

197+
def OnPreInit(self):
198+
super(CefApp, self).OnPreInit()
199+
# On Mac with wxPython 4.0 the OnInit() event never gets
200+
# called. Doing wx window creation in OnPreInit() seems to
201+
# resolve the problem (Issue #350).
202+
if MAC and wx.version().startswith("4."):
203+
print("[wxpython.py] OnPreInit: initialize here"
204+
" (wxPython 4.0 fix)")
205+
self.initialize()
206+
196207
def OnInit(self):
208+
self.initialize()
209+
return True
210+
211+
def initialize(self):
212+
if self.is_initialized:
213+
return
197214
self.create_timer()
198215
frame = MainFrame()
199216
self.SetTopWindow(frame)
200217
frame.Show()
201-
return True
218+
self.initialized = True
202219

203220
def create_timer(self):
204221
# See also "Making a render loop":

src/compile_time_constants.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file was generated by setup.py
2-
DEF UNAME_SYSNAME = "Windows"
2+
DEF UNAME_SYSNAME = "Darwin"
33
DEF PY_MAJOR_VERSION = 3

tools/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ def get_python_include_path():
242242
try_dirs = ["{base_dir}/include",
243243
"{base_dir}/../include/python{ver}",
244244
"{base_dir}/../include/python{ver}*",
245+
("{base_dir}/../Frameworks/Python.framework/Versions/{ver}"
246+
"/include/python{ver}*"),
245247
"/usr/include/python{ver}"]
246248
ver_tuple = sys.version_info[:2]
247249
ver = "{major}.{minor}".format(major=ver_tuple[0], minor=ver_tuple[1])

0 commit comments

Comments
 (0)