diff --git a/youtube_dl_gui/__init__.py b/youtube_dl_gui/__init__.py index b1b62b1..a6d22d9 100644 --- a/youtube_dl_gui/__init__.py +++ b/youtube_dl_gui/__init__.py @@ -75,6 +75,5 @@ def main(): """The real main. Creates and calls the main app windows. """ app = wx.App() frame = MainFrame(opt_manager, log_manager) - frame.Centre() frame.Show() app.MainLoop() diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index 38ac6ce..d3d44d7 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -131,6 +131,8 @@ class MainFrame(wx.Frame): self.update_thread = None self.app_icon = get_icon_file() + self.Center() + # Create the app icon if self.app_icon is not None: 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. This method is used when the options button is pressed to show - the optios window. + the options window. """ self._options_frame.load_all_options() diff --git a/youtube_dl_gui/optionsframe.py b/youtube_dl_gui/optionsframe.py index b027c80..99408fd 100644 --- a/youtube_dl_gui/optionsframe.py +++ b/youtube_dl_gui/optionsframe.py @@ -62,6 +62,8 @@ class OptionsFrame(wx.Frame): if self.app_icon is not None: self.SetIcon(self.app_icon) + self._was_shown = False + # Create GUI panel = wx.Panel(self) notebook = wx.Notebook(panel) @@ -123,6 +125,14 @@ class OptionsFrame(wx.Frame): for tab, _ in self.tabs: 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):