Browse Source

Automatically re-adjust buttons width

doc-issue-template
MrS0m30n3 9 years ago
parent
commit
782afa89b0
1 changed files with 24 additions and 1 deletions
  1. 25
      youtube_dl_gui/mainframe.py

25
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

Loading…
Cancel
Save