[GRASS-SVN] r57348 - grass/trunk/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 1 11:47:15 PDT 2013
Author: annakrat
Date: 2013-08-01 11:47:14 -0700 (Thu, 01 Aug 2013)
New Revision: 57348
Modified:
grass/trunk/gui/wxpython/gui_core/dialogs.py
grass/trunk/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: further fixes for import dialog
Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-08-01 16:45:11 UTC (rev 57347)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-08-01 18:47:14 UTC (rev 57348)
@@ -1591,7 +1591,6 @@
self.btn_run = wx.Button(parent = self.panel, id = wx.ID_OK, label = _("&Import"))
self.btn_run.SetToolTipString(_("Import selected layers"))
self.btn_run.SetDefault()
- self.btn_run.Enable(False)
self.btn_run.Bind(wx.EVT_BUTTON, self.OnRun)
def doLayout(self):
@@ -1741,6 +1740,7 @@
self.dsnInput = GdalSelect(parent = self, panel = self.panel,
ogr = ogr, link = link)
+ self.dsnInput.reloadDataRequired.connect(lambda data: self.list.LoadData(data))
if link:
self.add.SetLabel(_("Add linked layers into layer tree"))
@@ -1872,7 +1872,6 @@
self.btnOk = wx.Button(parent = self.panel, id = wx.ID_OK)
self.btnOk.SetToolTipString(_("Set external format and close dialog"))
self.btnOk.SetDefault()
- self.btnOk.Enable(False)
self.dsnInput = GdalSelect(parent = self, panel = self.panel,
ogr = ogr,
@@ -1922,6 +1921,9 @@
dsn = self.dsnInput.GetDsn()
frmt = self.dsnInput.GetFormat()
options = self.dsnInput.GetOptions()
+ if not dsn:
+ GMessage(_("No data source selected."), parent=self)
+ return
RunCommand('v.external.out',
parent = self,
@@ -1956,6 +1958,9 @@
def OnRun(self, event):
"""!Import/Link data (each layes as separate vector map)"""
data = self.list.GetLayers()
+ if not data:
+ GMessage(_("No layers selected."), parent=self)
+ return
# hide dialog
self.Hide()
@@ -1979,7 +1984,7 @@
# run in Layer Manager
self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
- self.OnCancel()
+ self.Close()
def OnSetDsn(self, event):
"""!Input DXF file defined, update list of layer widget"""
@@ -1996,7 +2001,6 @@
input = path)
if not ret:
self.list.LoadData()
- self.btn_run.Enable(False)
return
for line in ret.splitlines():
@@ -2006,11 +2010,8 @@
data.append((layerId, layerName.strip(), grassName.strip()))
self.list.LoadData(data)
- if len(data) > 0:
- self.btn_run.Enable(True)
- else:
- self.btn_run.Enable(False)
-
+
+
class LayersList(GListCtrl, listmix.TextEditMixin):
"""!List of layers to be imported (dxf, shp...)"""
def __init__(self, parent, columns, log = None):
Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py 2013-08-01 16:45:11 UTC (rev 57347)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py 2013-08-01 18:47:14 UTC (rev 57348)
@@ -63,6 +63,7 @@
from core.settings import UserSettings
from core.debug import Debug
+from grass.pydispatch.signal import Signal
class Select(wx.combo.ComboCtrl):
def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
@@ -1185,6 +1186,8 @@
wx.Panel.__init__(self, parent=panel)
+ self.reloadDataRequired = Signal('GdalSelect.reloadDataRequired')
+
if self.ogr:
settingsFile = os.path.join(GetSettingsPath(), 'wxOGR')
else:
@@ -1405,8 +1408,9 @@
self.dbWidgets['format'].SetStringSelection(format)
self.dbWidgets['options'].SetValue(options)
name = self._getCurrentDbWidgetName()
- if name == 'choice' and dsn in self.dbWidgets[name].GetItems():
- self.dbWidgets[name].SetStringSelection(dsn)
+ if name == 'choice':
+ if dsn in self.dbWidgets[name].GetItems():
+ self.dbWidgets[name].SetStringSelection(dsn)
else:
self.dbWidgets[name].SetValue(dsn)
@@ -1604,9 +1608,8 @@
db = self.dbWidgets['format'].GetStringSelection()
self.SetDatabase(db)
- if hasattr(self.parent, 'list'):
- self.parent.list.DeleteAllItems()
- self._reloadLayers()
+ self.reloadDataRequired.emit(data=None)
+ self._reloadLayers()
def OnSettingsChanged(self, data):
"""!User changed setting"""
@@ -1744,8 +1747,6 @@
dbNames.append(dbname)
self.dbWidgets['choice'].SetItems(db)
self.dbWidgets['choice'].SetSelection(0)
- if self.dest and self.dbWidgets['choice'].GetStringSelection():
- self.parent.btnOk.Enable(True)
else:
sizer.Show(self.dbWidgets['text'])
sizer.Show(self.dbWidgets['choice'], False)
@@ -1774,10 +1775,7 @@
flags = 't',
dsn = dsn)
if not ret:
- if hasattr(self.parent, 'list'):
- self.parent.list.LoadData()
- if hasattr(self, "btn_run"):
- self.btn_run.Enable(False)
+ self.reloadDataRequired.emit(data=None)
return
layerId = 1
@@ -1811,11 +1809,7 @@
# wx.PostEvent(self.parent, evt)
if self.parent.GetName() == 'MultiImportDialog':
- self.parent.list.LoadData(data)
- if len(data) > 0:
- self.parent.btn_run.Enable(True)
- else:
- self.parent.btn_run.Enable(False)
+ self.reloadDataRequired.emit(data=data)
def ExtensionChanged(self, event):
if not self.dest:
@@ -1833,18 +1827,15 @@
def GetFormat(self):
"""!Get format as string"""
- if self._sourceType == 'file':
- format = self.fileWidgets['browse'].GetValue()
- elif self._sourceType == 'dir':
- format = self.dirWidgets['browse'].GetValue()
+ if self._sourceType == 'dir':
+ format = self.dirWidgets['format'].GetStringSelection()
elif self._sourceType == 'pro':
- format = self.protocolWidgets['text'].GetValue()
+ format = self.protocolWidgets['format'].GetStringSelection()
elif self._sourceType in ('db', 'db-pg'):
- wname = self._getCurrentDbWidgetName()
- if wname =='choice':
- format = self.dbWidgets[wname].GetStringSelection()
- else:
- format = self.dbWidgets[wname].GetValue()
+ format = self.dbWidgets['format'].GetStringSelection()
+ else:
+ format = ''
+
return format.replace(' ', '_')
def GetFormatExt(self):
More information about the grass-commit
mailing list