Skip to content

Commit ba69a2f

Browse files
committed
Fix window glitchiness during initial loading on Mac (cztomczak#371)
1 parent 87123af commit ba69a2f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

examples/wxpython.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,25 @@ def __init__(self):
8181
self.browser_panel.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
8282
self.browser_panel.Bind(wx.EVT_SIZE, self.OnSize)
8383

84-
# On Linux must show before embedding browser, so that handle
85-
# is available (Issue #347).
84+
if MAC:
85+
try:
86+
# noinspection PyUnresolvedReferences
87+
from AppKit import NSApp
88+
# Make the content view for the window have a layer.
89+
# This will make all sub-views have layers. This is
90+
# necessary to ensure correct layer ordering of all
91+
# child views and their layers. This fixes Window
92+
# glitchiness during initial loading on Mac (Issue #371).
93+
NSApp.windows()[0].contentView().setWantsLayer_(True)
94+
except ImportError:
95+
print("[wxpython.py] Warning: PyObjC package is missing, "
96+
"cannot fix Issue #371")
97+
print("[wxpython.py] To install PyObjC type: "
98+
"pip install -U pyobjc")
99+
86100
if LINUX:
101+
# On Linux must show before embedding browser, so that handle
102+
# is available (Issue #347).
87103
self.Show()
88104
# In wxPython 3.0 and wxPython 4.0 on Linux handle is
89105
# still not yet available, so must delay embedding browser

0 commit comments

Comments
 (0)