[GRASS-SVN] r48008 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 31 15:28:12 EDT 2011
Author: martinl
Date: 2011-08-31 12:28:12 -0700 (Wed, 31 Aug 2011)
New Revision: 48008
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
Log:
wxGUI/GDALImporter: add widget for defining extension in directory mode
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2011-08-31 18:39:39 UTC (rev 48007)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2011-08-31 19:28:12 UTC (rev 48008)
@@ -1062,7 +1062,7 @@
label=" %s " % _("Settings"))
self.inputBox = wx.StaticBox(parent = self, id=wx.ID_ANY,
- label=" %s " % _("Source name"))
+ label=" %s " % _("Source"))
# source type
sources = list()
@@ -1160,7 +1160,9 @@
self.format = FormatSelect(parent = self,
ogr = ogr)
self.format.Bind(wx.EVT_CHOICE, self.OnSetFormat)
-
+ self.extension = wx.TextCtrl(parent = self, id = wx.ID_ANY)
+ self.extension.Bind(wx.EVT_TEXT, self.OnSetExtension)
+
if ogr:
fType = 'ogr'
else:
@@ -1186,18 +1188,19 @@
self.input[self.dsnType][1].Show()
self.format.SetItems(self.input[self.dsnType][2])
- if not ogr:
- self.format.SetStringSelection('GeoTIFF')
- else:
- self.format.SetStringSelection('ESRI Shapefile')
-
self.dsnText = wx.StaticText(parent = self, id = wx.ID_ANY,
label = self.input[self.dsnType][0],
size = (75, -1))
- self.formatText = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _("Format:"))
+ self.extensionText = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _("Extension:"))
+
self._layout()
+ if not ogr:
+ self.OnSetFormat(event = None, format = 'GeoTIFF')
+ else:
+ self.OnSetFormat(event = None, format = 'ESRI Shapefile')
+
def _layout(self):
"""!Layout"""
mainSizer = wx.BoxSizer(wx.VERTICAL)
@@ -1217,23 +1220,30 @@
inputSizer = wx.StaticBoxSizer(self.inputBox, wx.HORIZONTAL)
- self.dsnSizer = wx.GridBagSizer(vgap=3, hgap=3)
+ self.dsnSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
self.dsnSizer.AddGrowableRow(1)
- self.dsnSizer.AddGrowableCol(1)
+ self.dsnSizer.AddGrowableCol(3)
self.dsnSizer.Add(item=self.dsnText,
flag=wx.ALIGN_CENTER_VERTICAL,
pos = (0, 0))
self.dsnSizer.Add(item=self.input[self.dsnType][1],
flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1))
+ pos = (0, 1), span = (1, 3))
- self.dsnSizer.Add(item=self.formatText,
- flag=wx.ALIGN_CENTER_VERTICAL,
+ self.dsnSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _("Format:")),
+ flag = wx.ALIGN_CENTER_VERTICAL,
pos = (1, 0))
self.dsnSizer.Add(item=self.format,
flag = wx.ALIGN_CENTER_VERTICAL,
pos = (1, 1))
+ self.dsnSizer.Add(item = self.extensionText,
+ flag=wx.ALIGN_CENTER_VERTICAL,
+ pos = (1, 2))
+ self.dsnSizer.Add(item=self.extension,
+ flag = wx.ALIGN_CENTER_VERTICAL,
+ pos = (1, 3))
inputSizer.Add(item=self.dsnSizer, proportion=1,
flag=wx.EXPAND | wx.ALL)
@@ -1360,6 +1370,7 @@
changeCallback=self.OnSetDsn,
fileMask = format)
self.input[self.dsnType][1] = win
+
elif sel == self.sourceMap['dir']: # directory
self.dsnType = 'dir'
elif sel == self.sourceMap['db']: # database
@@ -1385,14 +1396,24 @@
self.OnSetFormat(event = None, format = 'GeoTIFF')
else:
self.OnSetFormat(event = None, format = 'ESRI Shapefile')
- elif sel == self.sourceMap['pro']:
- win = self.input[self.dsnType][1]
- self.dsnSizer.Add(item=self.input[self.dsnType][1],
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1))
- win.SetValue('')
- win.Show()
+ else:
+ if sel == self.sourceMap['pro']:
+ win = self.input[self.dsnType][1]
+ self.dsnSizer.Add(item=self.input[self.dsnType][1],
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos = (0, 1))
+ win.SetValue('')
+ win.Show()
+ if sel == self.sourceMap['dir']:
+ if not self.extension.IsShown():
+ self.extensionText.Show()
+ self.extension.Show()
+ else:
+ if self.extension.IsShown():
+ self.extensionText.Hide()
+ self.extension.Hide()
+
self.dsnSizer.Layout()
def _getDsn(self):
@@ -1429,7 +1450,7 @@
dsn = self._getDsn()
if not dsn:
return
-
+
data = list()
layerId = 1
@@ -1438,10 +1459,7 @@
grassName = utils.GetValidLayerName(baseName.split('.', -1)[0])
data.append((layerId, baseName, grassName))
elif self.dsnType == 'dir':
- try:
- ext = self.format.GetExtension(self.format.GetStringSelection())
- except KeyError:
- ext = ''
+ ext = self.extension.GetValue()
for file in glob.glob(os.path.join(dsn, "%s") % self._getExtPatternGlob(ext)):
baseName = os.path.basename(file)
grassName = utils.GetValidLayerName(baseName.split('.', -1)[0])
@@ -1476,6 +1494,11 @@
else:
self.parent.btn_run.Enable(False)
+ def OnSetExtension(self, event):
+ """!Extension changed"""
+ # reload layers
+ self._reloadLayers()
+
def OnSetFormat(self, event, format = None):
"""!Format changed"""
if self.dsnType not in ['file', 'dir', 'db']:
@@ -1511,8 +1534,10 @@
startDirectory=os.getcwd(),
changeCallback=self.OnSetDsn,
fileMask = format)
+
elif self.dsnType == 'dir':
pass
+
else: # database
if format == 'SQLite' or format == 'Rasterlite':
win = self.input['db-win']['file']
@@ -1536,15 +1561,18 @@
win = self.input['db-win']['text']
else:
win = self.input['db-win']['text']
-
+
self.input[self.dsnType][1] = win
if not win.IsShown():
win.Show()
- self.dsnSizer.Add(item=self.input[self.dsnType][1],
+ self.dsnSizer.Add(item = self.input[self.dsnType][1],
flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1))
+ pos = (0, 1), span = (1, 3))
self.dsnSizer.Layout()
+ # update extension
+ self.extension.SetValue(self.GetFormatExt())
+
# reload layers
self._reloadLayers()
More information about the grass-commit
mailing list