Browse Source

Merge pull request #35 from dstftw/optionsframe-centering

[optionsframe] Center on parent frame
doc-issue-template
MrS0m30n3 9 years ago
parent
commit
2f074e800f
3 changed files with 13 additions and 2 deletions
  1. 1
      youtube_dl_gui/__init__.py
  2. 4
      youtube_dl_gui/mainframe.py
  3. 10
      youtube_dl_gui/optionsframe.py

1
youtube_dl_gui/__init__.py

@ -75,6 +75,5 @@ def main():
"""The real main. Creates and calls the main app windows. """ """The real main. Creates and calls the main app windows. """
app = wx.App() app = wx.App()
frame = MainFrame(opt_manager, log_manager) frame = MainFrame(opt_manager, log_manager)
frame.Centre()
frame.Show() frame.Show()
app.MainLoop() app.MainLoop()

4
youtube_dl_gui/mainframe.py

@ -131,6 +131,8 @@ class MainFrame(wx.Frame):
self.update_thread = None self.update_thread = None
self.app_icon = get_icon_file() self.app_icon = get_icon_file()
self.Center()
# Create the app icon # Create the app icon
if self.app_icon is not None: if self.app_icon is not None:
self.app_icon = wx.Icon(self.app_icon, wx.BITMAP_TYPE_PNG) self.app_icon = wx.Icon(self.app_icon, wx.BITMAP_TYPE_PNG)
@ -465,7 +467,7 @@ class MainFrame(wx.Frame):
"""Event handler of the self._options_btn widget. """Event handler of the self._options_btn widget.
This method is used when the options button is pressed to show This method is used when the options button is pressed to show
the optios window.
the options window.
""" """
self._options_frame.load_all_options() self._options_frame.load_all_options()

10
youtube_dl_gui/optionsframe.py

@ -62,6 +62,8 @@ class OptionsFrame(wx.Frame):
if self.app_icon is not None: if self.app_icon is not None:
self.SetIcon(self.app_icon) self.SetIcon(self.app_icon)
self._was_shown = False
# Create GUI # Create GUI
panel = wx.Panel(self) panel = wx.Panel(self)
notebook = wx.Notebook(panel) notebook = wx.Notebook(panel)
@ -123,6 +125,14 @@ class OptionsFrame(wx.Frame):
for tab, _ in self.tabs: for tab, _ in self.tabs:
tab.save_options() tab.save_options()
def Show(self, *args, **kwargs):
# CenterOnParent can't go to main frame's __init__ as main frame may change
# own position and options frame won't be centered on main frame anymore.
if not self._was_shown:
self._was_shown = True
self.CenterOnParent()
return wx.Frame.Show(self, *args, **kwargs)
class TabPanel(wx.Panel): class TabPanel(wx.Panel):

Loading…
Cancel
Save