Skip to content

Commit 8ff34a2

Browse files
authored
wxGUI/pydit: fix showing recent files submenu (OSGeo#6683)
1 parent fd2bfe5 commit 8ff34a2

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

gui/wxpython/gui_core/pyedit.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def __init__(self, panel, guiparent, giface):
284284
self.tempfile = None # bool, make them strings for better code
285285
self.overwrite = False
286286
self.parameters = None
287+
self.recent_files = None
287288

288289
def _openFile(self, file_path):
289290
"""Try open file and read content
@@ -795,9 +796,15 @@ def _layout(self):
795796

796797
self.Layout()
797798

798-
def SetUpPage(self, *args, **kwargs):
799-
MainPageBase.SetUpPage(self, *args, **kwargs)
800-
self.controller.SetRecentFilesMenu(self.GetMenu()[0])
799+
def OnDockUndock(self, event=None):
800+
MainPageBase.OnDockUndock(self, event)
801+
if not MainPageBase.IsDocked(self):
802+
if self.controller.recent_files is None:
803+
menuBar = self.GetMenu()[0]
804+
# Init recent files submenu
805+
self.controller.SetRecentFilesMenu(
806+
menu=menuBar.GetMenus()[0][0], # Parent File menu
807+
)
801808

802809
# TODO: it would be nice if we can pass the controller to the menu
803810
# might not be possible on the side of menu
@@ -886,6 +893,10 @@ def __init__(
886893
model=MenuTreeModelBuilder(filename).GetModel(separators=True),
887894
class_handler=self.panel,
888895
)
896+
# Init recent files submenu
897+
self.panel.controller.SetRecentFilesMenu(
898+
menu=self.menubar.GetMenus()[0][0], # Parent File menu
899+
)
889900
self.SetMenuBar(self.menubar)
890901

891902
sizer = wx.BoxSizer(wx.VERTICAL)

0 commit comments

Comments
 (0)