From 0212a42bf54b441f570996f75e8a7375f9b68d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Wed, 8 Apr 2015 00:13:19 +0600 Subject: [PATCH] [optionsframe] Center on parent on first show only --- youtube_dl_gui/optionsframe.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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):