From 782afa89b07aac14ad8d397607207ad4f11dae41 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Wed, 25 Mar 2015 17:02:09 +0200 Subject: [PATCH] Automatically re-adjust buttons width --- youtube_dl_gui/mainframe.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index 6bb13fe..29ede0f 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -68,7 +68,7 @@ class MainFrame(wx.Frame): """ - BUTTONS_SIZE = (90, 30) + BUTTONS_SIZE = (-1, 30) BUTTONS_SPACE = (80, -1) SIZE_20 = 20 SIZE_10 = 10 @@ -152,6 +152,8 @@ class MainFrame(wx.Frame): self._status_bar = self._create_statictext(self.WELCOME_MSG) + self._set_buttons_width() + # Bind extra events self.Bind(wx.EVT_CLOSE, self._on_close) @@ -176,6 +178,27 @@ class MainFrame(wx.Frame): """ Publisher.subscribe(handler, topic) + def _set_buttons_width(self): + """Re-adjust buttons size on runtime so that all buttons + look the same. """ + widths = [ + self._download_btn.GetSize()[0], + self._update_btn.GetSize()[0], + self._options_btn.GetSize()[0], + ] + + max_width = -1 + + for item in widths: + if item > max_width: + max_width = item + + self._download_btn.SetMinSize((max_width, self.BUTTONS_SIZE[1])) + self._update_btn.SetMinSize((max_width, self.BUTTONS_SIZE[1])) + self._options_btn.SetMinSize((max_width, self.BUTTONS_SIZE[1])) + + self._panel.Layout() + def _create_statictext(self, label): statictext = wx.StaticText(self._panel, label=label) return statictext