Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI/dbmgr: fix removing map table layer and layer related Browse data and Manage tables page (tab) #2422

Merged
merged 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,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 @@ -1361,6 +1361,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 @@ -132,15 +132,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 @@ -157,8 +177,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 @@ -215,8 +236,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 @@ -259,8 +284,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
Loading