[GRASS-SVN] r41800 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Apr 11 11:49:09 EDT 2010
Author: martinl
Date: 2010-04-11 11:49:08 -0400 (Sun, 11 Apr 2010)
New Revision: 41800
Modified:
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: cosmetics in splitter
Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2010-04-11 13:23:27 UTC (rev 41799)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2010-04-11 15:49:08 UTC (rev 41800)
@@ -944,7 +944,7 @@
if self.inputType == 'dxf':
self.inputTitle = _("Input DXF file")
else:
- self.inputTitle = _("Input directory")
+ self.inputTitle = _("Source name")
self.inputBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
label=" %s " % self.inputTitle)
@@ -964,22 +964,88 @@
changeCallback=self.OnSetInput,
fileMask="*.dxf")
else:
- self.inputText = wx.StaticText(self.panel, id=wx.ID_ANY, label=_("Choose directory:"))
- self.input = filebrowse.DirBrowseButton(parent=self.panel, id=wx.ID_ANY,
- size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
- dialogTitle=_('Choose input directory'),
- buttonText=_('Browse'),
- startDirectory=os.getcwd(),
- changeCallback=self.OnSetInput)
- self.formatText = wx.StaticText(self.panel, id=wx.ID_ANY, label=_("Select file extension:"))
- self.format = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY, size=(100, -1),
- value="")
+ self.typeRadio = wx.RadioBox(parent = self.panel, id = wx.ID_ANY,
+ label = _('Source type'),
+ style = wx.RA_SPECIFY_COLS,
+ choices = [_("File"),
+ _("Directory"),
+ _("Database"),
+ _("Protocol")])
+ self.typeRadio.SetSelection(0)
+ self.Bind(wx.EVT_RADIOBOX, self.OnChangeType)
+
+ # input widgets
+ inputFile = filebrowse.FileBrowseButton(parent=self.panel, id=wx.ID_ANY,
+ size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
+ dialogTitle=_('Choose input directory'),
+ buttonText=_('Browse'),
+ startDirectory=os.getcwd(),
+ changeCallback=self.OnSetInput)
+
+ inputDir = filebrowse.DirBrowseButton(parent=self.panel, id=wx.ID_ANY,
+ size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
+ dialogTitle=_('Choose input directory'),
+ buttonText=_('Browse'),
+ startDirectory=os.getcwd(),
+ changeCallback=self.OnSetInput)
+ inputDir.Hide()
+
+ inputDb = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY)
+ inputDb.Hide()
+
+ inputPro = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY)
+ inputPro.Hide()
+
+ # format widget
+ self.formatText = wx.StaticText(self.panel, id=wx.ID_ANY, label=_("Format:"))
+ self.format = wx.Choice(parent = self.panel, id = wx.ID_ANY, size=(200, -1))
+ self.format.Bind(wx.EVT_TEXT, self.OnSetInput)
+
+ if self.inputType == 'gdal':
+ ret = gcmd.RunCommand('r.in.gdal',
+ quiet = True, read = True,
+ flags = 'f')
+ else: # ogr
+ ret = gcmd.RunCommand('v.in.ogr',
+ quiet = True, read = True,
+ flags = 'f')
+
+ self.input = { 'file' : [_("File:"),
+ inputFile,
+ list()],
+ 'dir' : [_("Directory:"),
+ inputDir,
+ list()],
+ 'db' : [_("Database:"),
+ inputDb,
+ list()],
+ 'pro' : [_("Protocol:"),
+ inputPro,
+ list()] }
+
+ if ret:
+ for line in ret.splitlines():
+ format = line.strip().rsplit(' ', 1)[0]
+ if format in ('PostgreSQL', 'SQLite',
+ 'ODBC', 'ESRI Personal GeoDatabase'):
+ self.input['db'][2].append(format)
+ elif format in ('GeoJSON'):
+ self.input['pro'][2].append(format)
+ else:
+ self.input['file'][2].append(format)
+ self.input['dir'][2].append(format)
+
+ self.inputType = 'file'
+
+ self.inputText = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
+ label = self.input[self.inputType][0],
+ size = (75, -1))
+ self.format.SetItems(self.input[self.inputType][2])
+
if self.inputType == 'gdal':
- self.format.SetValue('tif')
- else: # ogr
- self.format.SetValue('shp')
-
- self.format.Bind(wx.EVT_TEXT, self.OnSetInput)
+ self.format.SetStringSelection('GTIFF')
+ else:
+ self.format.SetStringSelection('ESRI Shapefile')
#
# list of layers
@@ -1037,7 +1103,11 @@
gridSizer.Add(item=self.inputText,
flag=wx.ALIGN_CENTER_VERTICAL)
gridSizer.AddGrowableCol(1)
- gridSizer.Add(item=self.input,
+ self.inputTypeSizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.inputTypeSizer.Add(item=self.input[self.inputType][1], proportion = 1,
+ flag = wx.ALIGN_CENTER_VERTICAL)
+
+ gridSizer.Add(item=self.inputTypeSizer,
flag=wx.EXPAND | wx.ALL)
if self.inputType != 'dxf':
@@ -1047,7 +1117,9 @@
inputSizer.Add(item=gridSizer, proportion=1,
flag=wx.EXPAND | wx.ALL)
-
+
+ dialogSizer.Add(item=self.typeRadio, proportion=0,
+ flag=wx.ALL | wx.EXPAND, border=5)
dialogSizer.Add(item=inputSizer, proportion=0,
flag=wx.ALL | wx.EXPAND, border=5)
@@ -1099,6 +1171,46 @@
width = self.GetSize()[0]
self.list.SetColumnWidth(col=1, width=width/2 - 50)
+ def OnChangeType(self, event):
+ """!Datasource type changed"""
+ sel = event.GetSelection()
+ win = self.input[self.inputType][1]
+ self.inputTypeSizer.Remove(win)
+ win.Hide()
+
+ if sel == 0: # file
+ self.inputType = 'file'
+ format = self.input[self.inputType][2][0]
+ if format == 'ESRI Shapefile':
+ format += ' (*.shp)|*.shp'
+ else:
+ format += ' (*.*)|*.*'
+ win = filebrowse.FileBrowseButton(parent=self.panel, id=wx.ID_ANY,
+ size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
+ dialogTitle=_('Choose file'),
+ buttonText=_('Browse'),
+ startDirectory=os.getcwd(),
+ changeCallback=self.OnSetInput,
+ fileMask = format)
+ self.input[self.inputType][1] = win
+ elif sel == 1: # directory
+ self.inputType = 'dir'
+ elif sel == 2: # database
+ self.inputType = 'db'
+ elif sel == 3: # protocol
+ self.inputType = 'pro'
+
+ win = self.input[self.inputType][1]
+ self.inputTypeSizer.Add(item = win, proportion = 1,
+ flag = wx.ALIGN_CENTER_VERTICAL)
+ win.Show()
+
+ self.inputText.SetLabel(self.input[self.inputType][0])
+ self.format.SetItems(self.input[self.inputType][2])
+ self.format.SetSelection(0)
+
+ self.inputTypeSizer.Layout()
+
def OnCancel(self, event=None):
"""!Close dialog"""
self.Close()
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2010-04-11 13:23:27 UTC (rev 41799)
+++ grass/trunk/gui/wxpython/wxgui.py 2010-04-11 15:49:08 UTC (rev 41800)
@@ -992,26 +992,26 @@
def OnImportGdalLayers(self, event):
"""!Convert multiple GDAL layers to GRASS raster map layers"""
dlg = gdialogs.MultiImportDialog(parent=self, type='gdal',
- title=_("Import GDAL layers"))
+ title=_("Import raster data"))
dlg.ShowModal()
def OnLinkGdalLayers(self, event):
"""!Link multiple GDAL layers to GRASS raster map layers"""
dlg = gdialogs.MultiImportDialog(parent=self, type='gdal',
- title=_("Link GDAL layers"),
+ title=_("Link raster data"),
link = True)
dlg.ShowModal()
def OnImportOgrLayers(self, event):
"""!Convert multiple OGR layers to GRASS vector map layers"""
dlg = gdialogs.MultiImportDialog(parent=self, type='ogr',
- title=_("Import OGR layers"))
+ title=_("Import vector data"))
dlg.ShowModal()
def OnLinkOgrLayers(self, event):
"""!Links multiple OGR layers to GRASS vector map layers"""
dlg = gdialogs.MultiImportDialog(parent=self, type='ogr',
- title=_("Link OGR layers"),
+ title=_("Link vector data"),
link = True)
dlg.ShowModal()
More information about the grass-commit
mailing list