diff options
Diffstat (limited to 'lib/gui/windows.py')
| -rw-r--r-- | lib/gui/windows.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/gui/windows.py b/lib/gui/windows.py new file mode 100644 index 00000000..42c34cc8 --- /dev/null +++ b/lib/gui/windows.py @@ -0,0 +1,41 @@ +import wx + + +class SimpleBox(wx.Panel): + """Draw a box around one window. + + Usage: + + window = SomeWindow(your_window_or_panel, wx.ID_ANY) + box = SimpleBox(your_window_or_panel, window) + some_sizer.Add(box, ...) + + """ + + def __init__(self, parent, window, *args, width=1, radius=2, **kwargs): + super().__init__(parent, wx.ID_ANY, *args, **kwargs) + + window.Reparent(self) + self.window = window + self.sizer = wx.BoxSizer(wx.VERTICAL) + self.sizer.Add(window, 1, wx.EXPAND | wx.ALL, 2) + self.SetSizer(self.sizer) + + self.width = width + self.radius = radius + + self.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background) + + def on_erase_background(self, event): + dc = event.GetDC() + if not dc: + dc = wx.ClientDC(self) + size = self.GetClientSize() + + if wx.SystemSettings().GetAppearance().IsDark(): + dc.SetPen(wx.Pen(wx.Colour(32, 32, 32), width=self.width)) + else: + dc.SetPen(wx.Pen(wx.Colour(128, 128, 128), width=self.width)) + + dc.SetBrush(wx.NullBrush) + dc.DrawRoundedRectangle(0, 0, size.x, size.y, self.radius) |
