Skip to content

Commit

Permalink
wxGUI/dbmgr: fix removing map table layer and layer related Browse da…
Browse files Browse the repository at this point in the history
…ta and Manage tables page (tab) (#2422)
  • Loading branch information
tmszi committed Oct 3, 2023
1 parent c0bf403 commit 87cff41
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
5 changes: 4 additions & 1 deletion gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def DeletePage(self, layer):
del self.layerPage[layer]

if self.GetSelection() >= 0:
self.selLayer = self.layers[self.GetSelection()]
self.selLayer = self.layers[-1]
else:
self.selLayer = None

Expand Down Expand Up @@ -1365,6 +1365,9 @@ def OnSqlQuerySizeWrap(self, layer):
def OnSqlQuerySize(self, event, layer):
"""Adapts SQL Query Simple tab on current width"""

if layer not in self.layers:
return

sqlNtb = event.GetEventObject()
if not self.sqlBestSize:
self.sqlBestSize = sqlNtb.GetBestSize()
Expand Down
41 changes: 35 additions & 6 deletions gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,35 @@ def BindPageChanged(self):
self.widget.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnRemoveHighlight)

def AddPage(self, *args, **kwargs):
"""Add a new page"""
"""Add a new page
:param str name: use this param if notebooks has ability to
change position and then you must use page name
param arg to correctly delete notebook page.
If you do not use this parameter, make sure that
the notebooks does not have the ability to change
position, because in that case the deletion of
the page based on the position index would not
work correctly.
"""
if "name" in kwargs:
self.notebookPages[kwargs["name"]] = kwargs["page"]
del kwargs["name"]

self.classObject.AddPage(self.widget, *args, **kwargs)

def InsertPage(self, *args, **kwargs):
"""Insert a new page"""
"""Insert a new page
:param str name: use this param if notebooks has ability to
change position and then you must use page name
param arg to correctly delete notebook page.
If you do not use this parameter, make sure that
the notebooks does not have the ability to change
position, because in that case the deletion of
the page based on the position index would not
work correctly.
"""
if "name" in kwargs:
self.notebookPages[kwargs["name"]] = kwargs["page"]
del kwargs["name"]
Expand All @@ -158,8 +178,9 @@ def InsertPage(self, *args, **kwargs):
def DeletePage(self, page):
"""Delete page
:param page: name
:return: True if page was deleted, False if not exists
:param str|int page: page name or page index position
:return bool: True if page was deleted, False if not exists
"""
delPageIndex = self.GetPageIndexByName(page)
if delPageIndex != -1:
Expand Down Expand Up @@ -216,8 +237,12 @@ def RemoveHighlight(self, page):
def GetPageIndexByName(self, page):
"""Get notebook page index
:param page: name
:param str|int page: page name or page index position
:return int: page index
"""
if not self.notebookPages:
return page
if page not in self.notebookPages:
return -1
for pageIndex in range(self.classObject.GetPageCount(self.widget)):
Expand Down Expand Up @@ -260,8 +285,12 @@ def BindPageChanged(self):
def GetPageIndexByName(self, page):
"""Get notebook page index
:param page: name
:param str|int page: page name or page index position
:return int: page index
"""
if not self.notebookPages:
return page
if page not in self.notebookPages:
return -1

Expand Down

0 comments on commit 87cff41

Please sign in to comment.