Skip to content

Commit

Permalink
wxGUI/infobar: attempt to fix #1213 (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa committed Dec 28, 2020
1 parent c3405bb commit 687e432
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions gui/wxpython/gui_core/infobar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@
import wx.lib.infobar as IB


def GetCloseButtonBitmap(win, size, colBg, flags=0):
"""Workaround for missing DrawTitleBarBitmap method
of wx.RendererNative in certain wx versions.
See https://github.com/wxWidgets/Phoenix/issues/1425."""
renderer = wx.RendererNative.Get()
if hasattr(renderer, 'DrawTitleBarBitmap'):
bmp = wx.Bitmap(*size)
dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.SetBackground(wx.Brush(colBg))
dc.Clear()

wx.RendererNative.Get().DrawTitleBarBitmap(win, dc, wx.Rect(size), wx.TITLEBAR_BUTTON_CLOSE, flags)
dc.SelectObject(wx.NullBitmap)
else:
bmp = wx.ArtProvider.GetBitmap(wx.ART_CLOSE, wx.ART_BUTTON)

return bmp


IB.GetCloseButtonBitmap = GetCloseButtonBitmap


class InfoBar(IB.InfoBar):
"""A customized and specialized info bar to used by default"""
def __init__(self, parent):
Expand Down

0 comments on commit 687e432

Please sign in to comment.