From 9763ed3b8be7ae9ec19d10c91510d749de5c9037 Mon Sep 17 00:00:00 2001 From: Tomas Zigo Date: Fri, 14 Jul 2023 21:34:58 +0200 Subject: [PATCH 1/3] wxGUI/psmap: fix close vector map properties dialog after hit OK button --- gui/wxpython/psmap/dialogs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py index ed6d84cb5c8..50776a3853f 100644 --- a/gui/wxpython/psmap/dialogs.py +++ b/gui/wxpython/psmap/dialogs.py @@ -3290,6 +3290,7 @@ def update(self): def OnOK(self, event): self.update() event.Skip() + self.Destroy() class LegendDialog(PsmapDialog): From 744d2cb5a1d8441dc270890901c195a34f3b837a Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Thu, 14 Sep 2023 23:50:38 -0400 Subject: [PATCH 2/3] make VPropertiesDialog behave like standard dialog, don't inherit from PsmapDialog --- gui/wxpython/psmap/dialogs.py | 49 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py index 50776a3853f..10c6d0b0451 100644 --- a/gui/wxpython/psmap/dialogs.py +++ b/gui/wxpython/psmap/dialogs.py @@ -1965,14 +1965,12 @@ def OnProperties(self, event): dlg = VPropertiesDialog( self, id=id, - settings=self.instruction, - env=self.env, vectors=self.vectorList, tmpSettings=self.tmpDialogDict[id], ) - dlg.ShowModal() - - self.parent.FindWindowById(wx.ID_OK).SetFocus() + if dlg.ShowModal() == wx.ID_OK: + dlg.update() + dlg.Destroy() def enableButtons(self, enable=True): """Enable/disable up, down, properties, delete buttons""" @@ -2124,20 +2122,16 @@ def updateDialog(self): pass -class VPropertiesDialog(PsmapDialog): - def __init__(self, parent, id, settings, vectors, tmpSettings, env): - PsmapDialog.__init__( +class VPropertiesDialog(Dialog): + def __init__(self, parent, id, vectors, tmpSettings): + Dialog.__init__( self, parent=parent, - id=id, - title="", - settings=settings, - env=env, - apply=False, ) vectorList = vectors self.vPropertiesDict = tmpSettings + self.spinCtrlSize = (65, -1) # determine map and its type for item in vectorList: @@ -2195,6 +2189,26 @@ def __init__(self, parent, id, settings, vectors, tmpSettings, env): self._layout(notebook) + def _layout(self, panel): + # buttons + btnCancel = Button(self, wx.ID_CANCEL) + btnOK = Button(self, wx.ID_OK) + btnOK.SetDefault() + + # sizers + btnSizer = wx.StdDialogButtonSizer() + btnSizer.AddButton(btnCancel) + btnSizer.AddButton(btnOK) + btnSizer.Realize() + + mainSizer = wx.BoxSizer(wx.VERTICAL) + mainSizer.Add(panel, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) + mainSizer.Add(btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) + + self.SetSizer(mainSizer) + mainSizer.Layout() + mainSizer.Fit(self) + def _DataSelectionPanel(self, notebook): panel = Panel( parent=notebook, id=wx.ID_ANY, size=(-1, -1), style=wx.TAB_TRAVERSAL @@ -2924,9 +2938,7 @@ def _StyleLinePanel(self, notebook): styleText = StaticText(panel, id=wx.ID_ANY, label=_("Choose line style:")) penStyles = ["solid", "dashed", "dotted", "dashdotted"] - self.styleCombo = PenStyleComboBox( - panel, choices=penStyles, validator=TCValidator(flag="ZERO_AND_ONE_ONLY") - ) + self.styleCombo = PenStyleComboBox(panel, choices=penStyles) # self.styleCombo = wx.ComboBox(panel, id = wx.ID_ANY, ## choices = ["solid", "dashed", "dotted", "dashdotted"], # validator = TCValidator(flag = 'ZERO_AND_ONE_ONLY')) @@ -3287,11 +3299,6 @@ def update(self): self.vPropertiesDict["linecap"] = self.linecapChoice.GetStringSelection() - def OnOK(self, event): - self.update() - event.Skip() - self.Destroy() - class LegendDialog(PsmapDialog): def __init__(self, parent, id, settings, page, env): From 96fc1c6e0b9767c582ed466b3461f2fd3c1e5601 Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Fri, 15 Sep 2023 13:12:30 -0400 Subject: [PATCH 3/3] accept suggestion about parent --- gui/wxpython/psmap/dialogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py index 10c6d0b0451..0a05b4562ed 100644 --- a/gui/wxpython/psmap/dialogs.py +++ b/gui/wxpython/psmap/dialogs.py @@ -1963,7 +1963,7 @@ def OnProperties(self, event): id = self.vectorList[pos][2] dlg = VPropertiesDialog( - self, + self.parent, id=id, vectors=self.vectorList, tmpSettings=self.tmpDialogDict[id],