diff --git a/TODO b/TODO index 2359178..653e86e 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ NEW_LAYOUT ========== * Create new button widget (groups, auto width) -* Create new button with two stages (like toggle) * Settings menu add "Statistics" * Swap some of the Error messages with Info * Add clear list button ? diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index 01d1ef1..55c8d71 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -1190,3 +1190,36 @@ class ExtComboBox(wx.ComboBox): def LoadMultiple(self, items_list): for item in items_list: self.Append(item) + + +class DoubleStageButton(wx.Button): + + def __init__(self, parent, labels, bitmaps, bitmap_pos=wx.TOP, *args, **kwargs): + super(DoubleStageButton, self).__init__(parent, *args, **kwargs) + + assert isinstance(labels, tuple) and isinstance(bitmaps, tuple) + assert len(labels) == 2 + assert len(bitmaps) == 0 or len(bitmaps) == 2 + + self.labels = labels + self.bitmaps = bitmaps + self.bitmap_pos = bitmap_pos + + self._stage = 0 + self._set_layout() + + def _set_layout(self): + self.SetLabel(self.labels[self._stage]) + + if len(self.bitmaps): + self.SetBitmap(self.bitmaps[self._stage], self.bitmap_pos) + + def change_stage(self): + self._stage = 0 if self._stage else 1 + self._set_layout() + + def set_stage(self, new_stage): + assert new_stage == 0 or new_stage == 1 + + self._stage = new_stage + self._set_layout()