소스 검색

wxGUI: continue replacing events (moduleSelected), disable currently unused wxGdalSelect event

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55388 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 년 전
부모
커밋
6ec82e1793
5개의 변경된 파일26개의 추가작업 그리고 27개의 파일을 삭제
  1. 3 4
      gui/wxpython/gmodeler/dialogs.py
  2. 3 4
      gui/wxpython/gui_core/goutput.py
  3. 11 11
      gui/wxpython/gui_core/gselect.py
  4. 7 6
      gui/wxpython/gui_core/widgets.py
  5. 2 2
      gui/wxpython/modules/extensions.py

+ 3 - 4
gui/wxpython/gmodeler/dialogs.py

@@ -32,7 +32,7 @@ import wx.lib.mixins.listctrl as listmix
 from core                 import globalvar
 from core                 import utils
 from core.modulesdata     import ModulesData
-from gui_core.widgets     import SearchModuleWidget, EVT_MODULE_SELECTED, SimpleValidator
+from gui_core.widgets     import SearchModuleWidget, SimpleValidator
 from core.gcmd            import GError, EncodeString
 from gui_core.dialogs     import SimpleDialog, MapLayersDialogForModeler
 from gui_core.prompt      import GPromptSTC, EVT_GPROMPT_RUN_CMD
@@ -165,9 +165,8 @@ class ModelSearchDialog(wx.Dialog):
         self.search = SearchModuleWidget(parent = self.panel,
                                          modulesData = modulesData,
                                          showTip = True)
-        self.search.Bind(EVT_MODULE_SELECTED,
-                             lambda event:
-                                 self.cmd_prompt.SetTextAndFocus(event.name + ' '))
+        self.search.moduleSelected.connect(lambda name:
+                                           self.cmd_prompt.SetTextAndFocus(name + ' '))
         wx.CallAfter(self.cmd_prompt.SetFocus)
         
         self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)

+ 3 - 4
gui/wxpython/gui_core/goutput.py

@@ -37,7 +37,7 @@ from core.gconsole   import GConsole, \
     EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
 from gui_core.prompt import GPromptSTC, EVT_GPROMPT_RUN_CMD
 from core.settings   import UserSettings
-from gui_core.widgets import SearchModuleWidget, EVT_MODULE_SELECTED
+from gui_core.widgets import SearchModuleWidget
 from core.modulesdata import ModulesData
 
 
@@ -141,9 +141,8 @@ class GConsoleWindow(wx.SplitterWindow):
             self.MakeSearchPaneContent(self.searchPane.GetPane(), modulesData)
             self.searchPane.Collapse(True)
             self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnSearchPaneChanged, self.searchPane) 
-            self.search.Bind(EVT_MODULE_SELECTED,
-                             lambda event:
-                                 self.cmdPrompt.SetTextAndFocus(event.name + ' '))
+            self.search.moduleSelected.connect(lambda name:
+                                               self.cmdPrompt.SetTextAndFocus(name + ' '))
         else:
             self.search = None
 

+ 11 - 11
gui/wxpython/gui_core/gselect.py

@@ -46,8 +46,6 @@ import wx.combo
 import wx.lib.buttons          as  buttons
 import wx.lib.filebrowsebutton as filebrowse
 
-from wx.lib.newevent import NewEvent
-
 from core import globalvar
 
 import grass.script as grass
@@ -62,8 +60,6 @@ from core.utils    import GetSettingsPath, GetValidLayerName, ListSortLower
 from core.settings import UserSettings
 from core.debug    import Debug
 
-wxGdalSelect, EVT_GDALSELECT = NewEvent()
-
 class Select(wx.combo.ComboCtrl):
     def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
                  type = None, multiple = False, nmaps = 1,
@@ -1149,7 +1145,10 @@ class FormatSelect(wx.Choice):
             }
         
         return formatToExt.get(name, '')
-        
+
+# unused code since r47938
+# wxGdalSelect, EVT_GDALSELECT = NewEvent()
+
 class GdalSelect(wx.Panel):
     def __init__(self, parent, panel, ogr = False, link = False, dest = False, 
                  default = 'file', exclude = [], envHandler = None):
@@ -1643,12 +1642,13 @@ class GdalSelect(wx.Panel):
                     grassName = GetValidLayerName(baseName.split('.', -1)[0])
                     data.append((layerId, baseName, grassName))
                     layerId += 1
-        if self.ogr:
-            dsn += '@OGR'
-        
-        evt = wxGdalSelect(dsn = dsn)
-        evt.SetId(self.input[self.dsnType][1].GetId())
-        wx.PostEvent(self.parent, evt)
+# unused code since r47938
+#        if self.ogr:
+#            dsn += '@OGR'
+#        
+#        evt = wxGdalSelect(dsn = dsn)
+#        evt.SetId(self.input[self.dsnType][1].GetId())
+#        wx.PostEvent(self.parent, evt)
         
         if self.parent.GetName() == 'MultiImportDialog':
             self.parent.list.LoadData(data)

+ 7 - 6
gui/wxpython/gui_core/widgets.py

@@ -845,16 +845,18 @@ class GListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCt
         event.Skip()
 
 
-gModuleSelected, EVT_MODULE_SELECTED = NewEvent()
-
-
 class SearchModuleWidget(wx.Panel):
-    """!Search module widget (used in SearchModuleWindow)"""
+    """!Search module widget (used in SearchModuleWindow)
+        
+    Signal moduleSelected - attribute 'name' is module name
+    """
     def __init__(self, parent, modulesData, id = wx.ID_ANY,
                  showChoice = True, showTip = False, **kwargs):
         self.showTip = showTip
         self.showChoice = showChoice
         self.modulesData = modulesData
+        
+        self.moduleSelected = Signal('SearchModuleWidget.moduleSelected')
 
         wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
 
@@ -960,8 +962,7 @@ class SearchModuleWidget(wx.Panel):
         """!Module selected from choice, update command prompt"""
         cmd  = event.GetString().split(' ', 1)[0]
 
-        moduleEvent = gModuleSelected(name = cmd)
-        wx.PostEvent(self, moduleEvent)
+        self.moduleSelected.emit(name = cmd)
 
         desc = self.modulesData.GetCommandDesc(cmd)
         if self.showTip:

+ 2 - 2
gui/wxpython/modules/extensions.py

@@ -34,7 +34,7 @@ from core             import globalvar
 from core.gcmd        import GError, RunCommand
 from core.utils       import SetAddOnPath
 from gui_core.forms   import GUI
-from gui_core.widgets import ItemTree, GListCtrl, SearchModuleWidget, EVT_MODULE_SELECTED
+from gui_core.widgets import ItemTree, GListCtrl, SearchModuleWidget
 
 
 class ExtensionModulesData(object):
@@ -148,7 +148,7 @@ class InstallExtensionWindow(wx.Frame):
         self.search = SearchModuleWidget(parent = self.panel, modulesData = self.modulesData,
                                          showChoice = False)
         self.search.SetSelection(0)
-        self.search.Bind(EVT_MODULE_SELECTED, self.OnShowItem)
+        self.search.moduleSelected.connect(lambda name: self.OnShowItem(None))
         # show text in statusbar when notification appears
         self.search.showNotification.connect(lambda message: self.SetStatusText(message))