Skip to content

Commit

Permalink
Fix wxpython.py example on Linux for wxPython 3.0/4.0 (#349)
Browse files Browse the repository at this point in the history
wx.IconFromBitmap is not available on Linux.
  • Loading branch information
cztomczak committed Apr 18, 2017
1 parent e74777a commit b359129
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/wxpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,23 @@ def __init__(self):
# is available (Issue #347).
if LINUX:
self.Show()
self.embed_browser()
# In wxPython 3.0 and wxPython 4.0 handle is still
# not yet available, must delay embedding browser
# (Issue #349).
if wx.version().startswith("3.") or wx.version().startswith("4."):
wx.CallLater(20, self.embed_browser)
else:
# This works fine in wxPython 2.8
self.embed_browser()
else:
self.embed_browser()
self.Show()

def setup_icon(self):
icon_file = os.path.join(os.path.abspath(os.path.dirname(__file__)),
"resources", "wxpython.png")
if os.path.exists(icon_file):
# wx.IconFromBitmap is not available on Linux in wxPython 3.0/4.0
if os.path.exists(icon_file) and hasattr(wx, "IconFromBitmap"):
icon = wx.IconFromBitmap(wx.Bitmap(icon_file, wx.BITMAP_TYPE_PNG))
self.SetIcon(icon)

Expand Down Expand Up @@ -132,7 +140,7 @@ def OnSize(self, _):
0, 0, 0)
elif LINUX:
(x, y) = (0, 0)
(width, height) = self.browser_panel.GetSizeTuple()
(width, height) = self.browser_panel.GetSize().Get()
self.browser.SetBounds(x, y, width, height)
self.browser.NotifyMoveOrResizeStarted()

Expand Down

0 comments on commit b359129

Please sign in to comment.