Skip to content

Commit

Permalink
wxGUI/psmap: fix close vector map properties dialog after hit OK butt…
Browse files Browse the repository at this point in the history
…on (#3085)

* make VPropertiesDialog behave like standard dialog, don't inherit from PsmapDialog

* accept suggestion about parent to prevent hiding the dialog on wxMAC

---------

Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
  • Loading branch information
tmszi and petrasovaa committed Sep 16, 2023
1 parent c5ab23c commit fd59e94
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions gui/wxpython/psmap/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,16 +1963,14 @@ def OnProperties(self, event):
id = self.vectorList[pos][2]

dlg = VPropertiesDialog(
self,
self.parent,
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"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -3287,10 +3299,6 @@ def update(self):

self.vPropertiesDict["linecap"] = self.linecapChoice.GetStringSelection()

def OnOK(self, event):
self.update()
event.Skip()


class LegendDialog(PsmapDialog):
def __init__(self, parent, id, settings, page, env):
Expand Down

0 comments on commit fd59e94

Please sign in to comment.