Parcourir la source

wxGUI: reuse preferences dialog

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38159 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa il y a 16 ans
Parent
commit
d0a9394309
2 fichiers modifiés avec 12 ajouts et 3 suppressions
  1. 5 0
      gui/wxpython/gui_modules/preferences.py
  2. 7 3
      gui/wxpython/wxgui.py

+ 5 - 0
gui/wxpython/gui_modules/preferences.py

@@ -865,6 +865,8 @@ class PreferencesDialog(wx.Dialog):
         btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
         btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
 
+        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+
         # sizers
         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
         btnSizer.Add(item=btnDefault, proportion=1,
@@ -1675,6 +1677,9 @@ class PreferencesDialog(wx.Dialog):
         if self.__UpdateSettings():
             self.Close()
 
+    def OnCloseWindow(self, event):
+        self.Hide()
+        
     def OnCancel(self, event):
         """!Button 'Cancel' pressed"""
         self.Close()

+ 7 - 3
gui/wxpython/wxgui.py

@@ -124,6 +124,7 @@ class GMFrame(wx.Frame):
         self.georectifying = None         # reference to GCP class or None
         # list of open dialogs
         self.dialogs        = dict()
+        self.dialogs['preferences'] = None
         self.dialogs['atm'] = list()
         
         # creating widgets
@@ -892,9 +893,12 @@ class GMFrame(wx.Frame):
 
     def OnPreferences(self, event):
         """!General GUI preferences/settings"""
-        dlg = preferences.PreferencesDialog(parent=self)
-        dlg.CenterOnScreen()
-        dlg.ShowModal()
+        if not self.dialogs['preferences']:
+            dlg = preferences.PreferencesDialog(parent=self)
+            self.dialogs['preferences'] = dlg
+            self.dialogs['preferences'].CenterOnScreen()
+
+        self.dialogs['preferences'].ShowModal()
         
     def DispHistogram(self, event):
         """