[GRASS-SVN] r52330 - grass-addons/grass7/gui/wxpython/wx.vnet/vnet

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 6 13:40:20 PDT 2012


Author: turek
Date: 2012-07-06 13:40:19 -0700 (Fri, 06 Jul 2012)
New Revision: 52330

Added:
   grass-addons/grass7/gui/wxpython/wx.vnet/vnet/dialog.py
   grass-addons/grass7/gui/wxpython/wx.vnet/vnet/toolbars.py
   grass-addons/grass7/gui/wxpython/wx.vnet/vnet/widgets.py
Log:
first version of v.net.* dialog

Added: grass-addons/grass7/gui/wxpython/wx.vnet/vnet/dialog.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.vnet/vnet/dialog.py	                        (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.vnet/vnet/dialog.py	2012-07-06 20:40:19 UTC (rev 52330)
@@ -0,0 +1,715 @@
+"""!
+ at package vnet.dialog
+
+ at brief Dialog for vector network analysis front-end
+
+Classes:
+ - dialog::VNETDialog
+ - dialog::SettingsDialog
+ - dialog::AddLayerDialog
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Stepan Turek <stepan.turek seznam.cz> (GSoC 2012)
+ at author Martin Landa <landa.martin gmail.com> (mentor)
+"""
+
+import os
+import wx
+import sys
+import wx.lib.colourselect as csel
+
+from core             import globalvar
+from vnet.toolbars    import MainToolbar, PointListToolbar
+from vnet.widgets     import PointsList
+from gui_core.gselect import Select, LayerSelect, ColumnSelect
+from gui_core.widgets import GNotebook
+from core.settings    import UserSettings
+from grass.script     import core as grass
+from core.gcmd        import RunCommand, GMessage
+
+import wx
+import wx.aui
+import wx.lib.flatnotebook  as FN
+from copy import copy
+class VNETDialog(wx.Dialog):
+    def __init__(self, parent,
+                 id=wx.ID_ANY, title = "Vector network analysis",
+                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
+        """!Dialolog for vector network analasis"""
+
+        wx.Dialog.__init__(self, parent, id, style=style, title = title)
+
+        self.parent  = parent  #mapdisp.frame MapFrame
+        self.mapWin = parent.MapWindow
+        self.inputData = {}
+
+        # registration graphics for drawing
+        self.pointsToDraw = self.mapWin.RegisterGraphicsToDraw(graphicsType = "point", 
+                                                               setStatusFunc = self.SetNodeStatus)
+        self.pointsToDraw.SetPropertyVal("size", 10) # TODO settings
+
+        # getting attribute table columns only whith numbers (costs)
+        self.columnTypes = ['integer', 'double precision'] 
+
+        self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_map.ico'), wx.BITMAP_TYPE_ICO))
+        
+        # toolbars
+        self.toolbars = {}
+        self.toolbars['mainToolbar'] = MainToolbar(parent = self)
+
+        #
+        # Fancy gui
+        #
+        self._mgr = wx.aui.AuiManager(self)
+
+        # Columns in points list
+        self.cols =   [
+                        ['type', ["", "Start point", "End point"], ""]
+                      ]
+
+        self.mainPanel = wx.Panel(parent=self)
+        self.notebook = GNotebook(parent = self.mainPanel,
+                                  style = FN.FNB_FANCY_TABS | FN.FNB_BOTTOM |
+                                          FN.FNB_NO_NAV_BUTTONS | FN.FNB_NO_X_BUTTON)
+
+
+        self._createListPanel()
+        self.notebook.AddPage(page = self.listPanel, 
+                              text=_('Points list'), 
+                              name = 'list')
+
+        self._createSelectsPanel()
+        self.notebook.AddPage(page = self.settingsPanel,
+                              text=_('Data'), 
+                              name = 'data')
+
+        self._addPanes()
+        self._doDialogLayout()
+
+        self._mgr.Update()
+
+        self.handlerRegistered = False
+        self.tmpResultLayer = None 
+
+        #TODO if 'vnet' not in UserSettings.userSettings: 
+
+        # initializes default settings
+
+        initSettings = [
+                        ['resStyle', 'width', 5],
+                        ['resStyle', 'color', (192,0,0)],
+                        ['analasisSettings', 'maxDist', 10000],
+                        ['analasisSettings', 'resultId', 1]
+                      ]
+        for init in initSettings:
+
+            UserSettings.Append(dict = UserSettings.userSettings, 
+                                group ='vnet', 
+                                key = init[0],
+                                subkey =init[1], 
+                                value = init[2])
+
+        # name of temporary map   
+        self.tmp_result = "tmp_map" 
+
+        # set options for drawing the map  
+        self.UpdateCmdList(self.tmp_result)
+
+        # adds 2 points into list
+        for i in range(2):
+            self.list.AddItem(None)
+            self.list.EditCell(i, 1, self.cols[1][1][1 + i]) 
+            self.list.CheckItem(i, True)
+
+        self.Bind(wx.EVT_CLOSE, self.OnCloseDialog)
+
+        dlgSize = (300,450)
+        self.SetMinSize(dlgSize)
+        self.SetInitialSize(dlgSize)
+
+    def  __del__(self):
+        """!Removes temp layer with analasis result, unregisters handlers and graphics"""
+
+
+        self.mapWin.UnregisterGraphicsToDraw(self.pointsToDraw)
+
+        RunCommand('g.remove', vect = self.tmp_result)
+        if self.tmpResultLayer:
+            self.mapWin.UpdateMap(render=True, renderVector=True)
+
+        if self.handlerRegistered:
+            self.mapWin.UnregisterMouseEventHandler(wx.EVT_LEFT_DOWN, 
+                                                  self.OnMapClickHandler)
+
+    def _addPanes(self):
+
+        self._mgr.AddPane(self.toolbars['mainToolbar'],
+                              wx.aui.AuiPaneInfo().
+                              Name("pointlisttools").Caption(_("Point list toolbar")).
+                              ToolbarPane().Top().
+                              Dockable(False).
+                              CloseButton(False).Layer(0))
+
+        self._mgr.AddPane(self.mainPanel,
+                              wx.aui.AuiPaneInfo().
+                              Name("tabs").CaptionVisible(visible = False).
+                              Center().
+                              Dockable(False).
+                              CloseButton(False).Layer(0))
+
+    def _doDialogLayout(self):
+
+        sizer = wx.BoxSizer(wx.VERTICAL)
+
+        sizer.Add(item = self.notebook, proportion = 1,
+                  flag = wx.EXPAND)
+        
+        self.mainPanel.SetSizer(sizer)
+        sizer.Fit(self)
+        
+        self.Layout()
+
+    def _createListPanel(self):
+
+        self.listPanel = wx.Panel(parent=self)
+
+        self.list = NodesList(parent = self.listPanel, dialog = self, cols = self.cols)
+        self.toolbars['pointsList'] = PointListToolbar(parent = self.listPanel, list = self.list)
+
+        listsizer = wx.BoxSizer(wx.VERTICAL)
+
+        listsizer.Add(item = self.toolbars['pointsList'], proportion = 0)
+        listsizer.Add(item = self.list, proportion = 1, flag = wx.EXPAND)
+
+        self.listPanel.SetSizer(listsizer)
+
+    def _createSelectsPanel(self):
+
+        self.settingsPanel = wx.Panel(parent=self)
+
+        self.inputData['input'] = Select(parent = self.settingsPanel, type = 'vector', size = (-1, -1))
+        vectSelTitle = wx.StaticText(parent = self.settingsPanel)
+        vectSelTitle.SetLabel("Choose vector layers for analysis:")
+
+        self.inputData['alayer'] = LayerSelect(parent = self.settingsPanel, size = (-1, -1))
+        aLayerSelTitle = wx.StaticText(parent = self.settingsPanel)
+        aLayerSelTitle.SetLabel("Arc layer number or name:")
+
+        self.inputData['nlayer'] = LayerSelect(parent = self.settingsPanel, size = (-1, -1))
+        nLayerSelTitle = wx.StaticText(parent = self.settingsPanel)
+        nLayerSelTitle.SetLabel("Node layer number or name:")
+
+        self.inputData['afcolumn'] = ColumnSelect(parent = self.settingsPanel, size = (-1, -1))
+        afcolumnSelTitle = wx.StaticText(parent = self.settingsPanel)
+        afcolumnSelTitle.SetLabel("Arc forward/both direction(s) cost column:")
+
+        self.inputData['abcolumn'] = ColumnSelect(parent = self.settingsPanel, size = (-1, -1))
+        abcolumnSelTitle = wx.StaticText(parent = self.settingsPanel)
+        abcolumnSelTitle.SetLabel("Arc backward direction cost column:")
+
+        self.inputData['input'].Bind(wx.EVT_TEXT, self.OnVectSel)
+        self.inputData['alayer'].Bind(wx.EVT_TEXT, self.OnVectSel)
+        self.inputData['nlayer'].Bind(wx.EVT_TEXT, self.OnVectSel)
+
+        mainSizer = wx.BoxSizer(wx.VERTICAL)
+
+        box = wx.StaticBox(self.settingsPanel, -1, "Layer for analysis")
+        bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        mainSizer.Add(item = bsizer, proportion = 0,
+                                 flag = wx.EXPAND  | wx.TOP | wx.LEFT | wx.RIGHT, border = 5) 
+
+        bsizer.Add(item = self._doSelLayout(title = vectSelTitle, sel = self.inputData['input']), proportion = 0,
+                                 flag = wx.EXPAND)
+
+        bsizer.Add(item = self._doSelLayout(title = aLayerSelTitle, sel = self.inputData['alayer']), proportion = 0,
+                                 flag = wx.EXPAND)
+
+        bsizer.Add(item = self._doSelLayout(title = nLayerSelTitle, sel = self.inputData['nlayer']), proportion = 0,
+                                 flag = wx.EXPAND)
+
+        box = wx.StaticBox(self.settingsPanel, -1, "Costs")
+        bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        mainSizer.Add(item = bsizer, proportion = 0,
+                                 flag = wx.EXPAND  | wx.TOP | wx.LEFT | wx.RIGHT, border = 5)       
+
+        bsizer.Add(item = self._doSelLayout(title = afcolumnSelTitle, sel = self.inputData['afcolumn']), proportion = 0,
+                                 flag = wx.EXPAND)
+
+        bsizer.Add(item = self._doSelLayout(title = abcolumnSelTitle, sel = self.inputData['abcolumn']), proportion = 0,
+                                 flag = wx.EXPAND)
+
+
+        self.settingsPanel.SetSizer(mainSizer)
+
+    def _doSelLayout(self, title, sel): 
+
+        selSizer = wx.BoxSizer(orient = wx.VERTICAL)
+
+        selTitleSizer = wx.BoxSizer(wx.HORIZONTAL)
+        selTitleSizer.Add(item = title, proportion = 1,
+                          flag = wx.LEFT | wx.TOP | wx.EXPAND, border = 5)
+
+        selSizer.Add(item = selTitleSizer, proportion = 0,
+                                 flag = wx.EXPAND)
+        selSizer.Add(item = sel, proportion = 0,
+                     flag = wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_CENTER_VERTICAL,
+                     border = 5)
+        return selSizer
+
+
+    def OnVectSel(self, event):
+
+        self.inputData['alayer'].InsertLayers(vector = self.inputData['input'].GetValue())#TODO split
+        self.inputData['nlayer'].InsertLayers(vector = self.inputData['input'].GetValue())
+
+        self.inputData['afcolumn'].InsertColumns(vector = self.inputData['input'].GetValue(), 
+                                                 layer = self.inputData['alayer'].GetValue(), 
+                                                 type = self.columnTypes)
+        self.inputData['abcolumn'].InsertColumns(vector = self.inputData['input'].GetValue(), 
+                                                 layer = self.inputData['alayer'].GetValue(), 
+                                                 type = self.columnTypes)
+
+    def OnCloseDialog(self, event):
+        """!Cancel dialog"""
+
+        self.parent.dialogs['vnet'] = None
+        self.Destroy()
+
+    def SetNodeStatus(self, item, itemIndex):
+        """!Before point is drawed, decides properties of drawing style"""
+        key = self.list.GetItemData(itemIndex)
+        gcp = self.list.itemDataMap[key]
+
+        if not self.list.IsChecked(key):
+                wxPen = "unused"
+                item.hide = False
+        else:
+            wxPen = "default"
+
+        if key == self.list.selected:
+            wxPen = "selected"
+
+        item.SetPropertyVal('label', str(itemIndex + 1))
+        item.SetPropertyVal('penName', wxPen)       
+
+
+    def OnMapClickHandler(self, event):
+        """!Takes coordinates from map window."""
+
+        if event == 'unregistered':
+            ptListToolbar = self.toolbars['pointsList']
+            if ptListToolbar:
+                ptListToolbar.ToggleTool(vars(ptListToolbar)["insertPoint"], False)  # TODO 
+            self.handlerRegistered = False
+            return
+
+        if not self.list.itemDataMap:
+            self.list.AddItem(None)
+
+        e, n = self.mapWin.GetLastEN()
+
+        index = self.list.selected
+        key = self.list.GetItemData(index)
+
+        self.pointsToDraw.GetItem(key).SetCoords([e, n])
+
+        self.mapWin.UpdateMap(render=False, renderVector=False)
+
+    def OnAnalyze(self, event):
+        """!Takes coordinates from map window."""
+
+        if len(self.pointsToDraw.GetAllItems()) < 1:
+            return
+
+        startPtLabel = self.cols[1][1][1]            
+        endPtLabel = self.cols[1][1][2]
+
+        inputCoords = { startPtLabel : None,
+                        endPtLabel : None}
+
+        for i in range(len(self.list.itemDataMap)):
+            key = self.list.GetItemData(i)
+            if self.list.IsChecked(key):
+                for k, v in inputCoords.iteritems():
+                    if k == self.list.itemDataMap[key][1]:       
+                        inputCoords[k] = self.pointsToDraw.GetItem(key).GetCoords        ()
+
+        if None in inputCoords.values():
+            GMessage(parent       = self,
+                     message=_("Pleas choose 'to' and 'from' point."))
+            return            
+
+        resId = int(UserSettings.Get(group='vnet', 
+                                     key='analasisSettings', 
+                                     subkey='resultId'))
+
+        s = str(resId) + " " + str(inputCoords[startPtLabel][0]) + " " + str(inputCoords[startPtLabel][1]) + \
+                         " " + str(inputCoords[endPtLabel][0]) + " " + str(inputCoords[endPtLabel][1])
+
+        coordsTempFile = grass.tempfile()#TODO stdin
+        coordsTempFileOpened = open(coordsTempFile, 'w')
+        coordsTempFileOpened.write(s)
+        coordsTempFileOpened.close()
+
+        params = {}
+        for k, v in self.inputData.iteritems():
+            if not v.GetValue():
+                params[k] = None
+            else:
+                params[k] = v.GetValue()
+ 
+        ret, std, msg = RunCommand('v.net.path',
+                                    input = params['input'],
+                                    output = self.tmp_result,
+                                    overwrite = True,
+                                    alayer = params['alayer'], 
+                                    nlayer = params['nlayer'], 
+                                    afcolumn = params['afcolumn'],
+                                    abcolumn = params['abcolumn'],
+                                    file = coordsTempFile,
+                                    dmax = int(UserSettings.Get(group='vnet', 
+                                                                key='analasisSettings', 
+                                                                subkey='maxDist')),
+                                    read = True,
+                                    getErrorMsg = True)
+
+        grass.try_remove(coordsTempFile)
+
+        if self.tmpResultLayer:
+            self.mapWin.Map.DeleteLayer(layer = self.tmpResultLayer)
+
+        self.tmpResultLayer = self.mapWin.Map.AddLayer(type = "vector",  command = self.cmdlist, 
+                                                       l_active=True,    name = self.tmp_result, 
+                                                       l_hidden = False, l_opacity = 1.0, 
+                                                       l_render = True,  pos = 1)
+
+        self.mapWin.UpdateMap(render=True, renderVector=True)
+
+    def OnInsertPoint(self, event):
+        if self.handlerRegistered == False:
+            self.mapWin.RegisterMouseEventHandler(wx.EVT_LEFT_DOWN, 
+                                                  self.OnMapClickHandler,
+                                                  wx.StockCursor(wx.CURSOR_CROSS))
+            self.handlerRegistered = True
+
+        else:
+            self.mapWin.UnregisterMouseEventHandler(wx.EVT_LEFT_DOWN, 
+                                                  self.OnMapClickHandler)
+            self.handlerRegistered = False
+
+    def OnSaveTmpLayer(self, event):
+
+        dlg = AddLayerDialog(parent = self)
+
+        if dlg.ShowModal() == wx.ID_OK:
+
+            ret, std, msg = RunCommand("g.copy",
+                             overwrite = dlg.overwrite.GetValue(),
+                             vect = [self.tmp_result, dlg.vectSel.GetValue()],
+                             read = True,
+                             getErrorMsg = True)
+
+            self.UpdateCmdList(dlg.vectSel.GetValue())
+            if  self.mapWin.tree.FindItemByData(key = 'name', value =  dlg.vectSel.GetValue()) is None:
+                self.mapWin.tree.AddLayer(ltype = "vector", 
+                                          lname = dlg.vectSel.GetValue(),
+                                          lcmd = self.cmdlist,
+                                          lchecked = True)
+            self.UpdateCmdList(self.tmp_result)
+
+    def OnSettings(self, event):
+        """!Displays vnet settings dialog"""
+        dlg = SettingsDialog(parent=self, id=wx.ID_ANY, title=_('Settings'))
+        
+        if dlg.ShowModal() == wx.ID_OK:
+            pass
+        
+        dlg.Destroy()
+
+    def UpdateCmdList(self, layerName):
+        """!Displays vnet settings dialog"""
+
+        col = UserSettings.Get(group='vnet', key='resStyle', subkey= "color")
+        width = UserSettings.Get(group='vnet', key='resStyle', subkey= "width")
+
+        self.cmdlist = ['d.vect', 'map=%s' % layerName, \
+                        'color=' + str(col[0]) + ':' + str(col[1]) + ':' + str(col[2]), \
+                        'width=' + str(width)]# TODO settings
+
+class NodesList(PointsList):
+    def __init__(self, parent, dialog, cols, id=wx.ID_ANY):
+        """! List with points for analasis
+        """
+
+        self.dialog = dialog # VNETDialog class
+
+        PointsList.__init__(self, parent = parent, cols = cols, id =  id)      
+
+    def AddItem(self, event):
+        """!
+        Appends an point to list
+        """       
+        PointsList.AddItem(self, event)   
+ 
+        self.dialog.pointsToDraw.AddItem(coords = [0,0], 
+                                         label = str(self.selectedkey + 1))
+
+        self.dialog.mapWin.UpdateMap(render=True, renderVector=True)
+
+
+    def DeleteItem(self, event):
+        """!
+        Deletes selected point in list
+        """
+
+        key = self.GetItemData(self.selected)
+        PointsList.DeleteItem(self, event)
+
+        if self.selected != wx.NOT_FOUND:
+            item = self.dialog.pointsToDraw.GetItem(key)
+            self.dialog.pointsToDraw.DeleteItem(item)
+
+    def OnItemSelected(self, event):
+        """
+        Item selected
+        """
+
+        PointsList.OnItemSelected(self, event)
+        self.dialog.mapWin.UpdateMap(render=False, renderVector=False)
+
+        event.Skip()
+
+    def OnCheckItem(self, index, flag):
+        """!Item is checked/unchecked"""
+
+        key = self.GetItemData(index)
+        checkedVal = self.itemDataMap[key][1]
+
+        if checkedVal == "":
+                self.CheckItem(key, False)
+                return
+
+        iItem = 0
+        for item in self.itemDataMap:
+            if item[1] == checkedVal and key != iItem and flag:
+                checkedKey = self.GetItemData(iItem)
+                self.CheckItem(checkedKey, False)
+            iItem += 1
+
+class SettingsDialog(wx.Dialog):
+    def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
+                 style=wx.DEFAULT_DIALOG_STYLE):
+        """!Settings for v.net analasis dialog"""
+        wx.Dialog.__init__(self, parent, id, title, pos, size, style)
+
+        maxValue = 1e8
+        self.parent = parent
+
+        self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
+
+        self.colorLabel = wx.StaticText(parent = self.panel, id = wx.ID_ANY, label = _("Line color:"))
+        col = UserSettings.Get(group ='vnet', key ='resStyle', subkey = "color")        
+        self.colorField = csel.ColourSelect(parent = self.panel, id = wx.ID_ANY,
+                                            colour = wx.Colour(col[0],
+                                                               col[1],
+                                                               col[2], 
+                                                               255))
+
+        self.widthLabel = wx.StaticText(parent = self.panel, id = wx.ID_ANY, label =_("Line width:"))
+        self.widthField = wx.SpinCtrl(parent = self.panel, id = wx.ID_ANY, min = 1, max = 10)
+        width = int(UserSettings.Get(group = 'vnet', key = 'resStyle', subkey = 'width'))
+        self.widthField.SetValue(width)
+
+        self.idLabel = wx.StaticText(parent = self.panel, id = wx.ID_ANY, label =_("Id of line:"))
+        self.resIdFiled = wx.SpinCtrl(parent = self.panel, id = wx.ID_ANY, min = 1, max = maxValue)
+        resId = int(UserSettings.Get(group ='vnet', key ='analasisSettings', subkey = 'resultId'))
+        self.resIdFiled.SetValue(resId)
+
+        self.maxDistlabel = wx.StaticText(parent = self.panel, id = wx.ID_ANY, label = _("Maximum distance \n to the network:"))
+        self.maxDistField = wx.SpinCtrl(parent = self.panel, id = wx.ID_ANY, min = 0, max = maxValue) #TODO
+        maxDist = int(UserSettings.Get(group = 'vnet', key = 'analasisSettings', subkey ='maxDist'))
+        self.maxDistField.SetValue(maxDist)
+
+        # buttons
+        #btnSave = wx.Button(self.panel, wx.ID_SAVE)
+        self.btnApply = wx.Button(self.panel, wx.ID_APPLY)
+        self.btnClose = wx.Button(self.panel, wx.ID_CLOSE)
+        self.btnApply.SetDefault()
+
+        # bindings
+        self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
+        self.btnApply.SetToolTipString(_("Apply changes for the current session"))
+        #btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
+        #btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
+        self.btnClose.Bind(wx.EVT_BUTTON, self.OnClose)
+        self.btnClose.SetToolTipString(_("Close dialog"))
+
+        self._layout()
+        self.SetMinSize(self.GetBestSize())
+
+    def _layout(self):
+        sizer = wx.BoxSizer(wx.VERTICAL)
+
+        styleBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
+                                label =" %s " % _("Analasis outcome line style:"))
+        styleBoxSizer = wx.StaticBoxSizer(styleBox, wx.VERTICAL)
+
+        gridSizer = wx.GridBagSizer(vgap = 1, hgap = 1)
+
+        row = 0
+        gridSizer.Add(item = self.colorLabel, flag = wx.ALIGN_CENTER_VERTICAL, pos =(row, 0))
+        gridSizer.Add(item = self.colorField,
+                      flag = wx.ALIGN_RIGHT | wx.ALL, border = 5,
+                      pos =(row, 1))
+
+        row += 1
+        gridSizer.Add(item =  self.widthLabel, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+        gridSizer.Add(item = self.widthField,
+                      flag = wx.ALIGN_RIGHT | wx.ALL, border = 5,
+                      pos = (row, 1))
+
+        styleBoxSizer.Add(item = gridSizer, flag = wx.EXPAND)
+
+
+        analasisBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
+                                   label = " %s " % _("Analasis settings:"))
+        analasisBoxSizer = wx.StaticBoxSizer(analasisBox, wx.VERTICAL)
+
+        row = 0
+        gridSizer = wx.GridBagSizer(vgap = 1, hgap = 1)
+        gridSizer.Add(item = self.idLabel, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+        gridSizer.Add(item = self.resIdFiled,
+                      flag = wx.ALIGN_RIGHT | wx.ALL, border = 5,
+                      pos = (row, 1))
+
+        row += 1
+        gridSizer.Add(item = self.maxDistlabel, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+        gridSizer.Add(item = self.maxDistField,
+                      flag = wx.ALIGN_RIGHT | wx.ALL, border = 5,
+                      pos = (row, 1))
+
+        analasisBoxSizer.Add(item = gridSizer, flag = wx.EXPAND)
+
+        # sizers
+        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+        btnSizer.Add(self.btnApply, flag = wx.LEFT | wx.RIGHT, border = 5)
+        #btnSizer.Add(btnSave, flag=wx.LEFT | wx.RIGHT, border=5)
+        btnSizer.Add(self.btnClose, flag = wx.LEFT | wx.RIGHT, border = 5)
+
+        sizer.Add(item = styleBoxSizer, flag = wx.EXPAND | wx.ALL, border = 5, proportion = 1)
+        sizer.Add(item = analasisBoxSizer, flag = wx.EXPAND | wx.ALL, border = 5, proportion = 1)
+        sizer.Add(item = btnSizer, flag = wx.EXPAND | wx.ALL, border = 5, proportion = 0)    
+
+        self.panel.SetSizer(sizer)
+        sizer.Fit(self)
+
+    def UpdateSettings(self):
+
+        UserSettings.Set(group ='vnet', key ='resStyle', subkey ='width',
+                         value = self.widthField.GetValue())
+
+        UserSettings.Set(group = 'vnet', key ='resStyle', subkey ='color',
+                         value = self.colorField.GetColour())
+
+        UserSettings.Set(group = 'vnet', key ='analasisSettings', subkey ='resultId',
+                         value = self.resIdFiled.GetValue())
+
+        UserSettings.Set(group ='vnet', key ='analasisSettings', subkey ='maxDist',
+                         value = self.maxDistField.GetValue())
+
+        if self.parent.tmpResultLayer:
+
+            self.parent.UpdateCmdList(self.parent.tmp_result)
+
+            self.parent.tmpResultLayer.SetCmd(self.parent.cmdlist)
+            self.parent.mapWin.UpdateMap(render=True, renderVector=True)#TODO necessary
+     
+
+    #def OnSave(self, event): TODO
+    #   """!Button 'Save' pressed"""
+    #    self.UpdateSettings()
+    #    fileSettings = {}
+    #    UserSettings.ReadSettingsFile(settings=fileSettings)
+    #    fileSettings['vnet'] = UserSettings.Get(group='vnet')
+    #    file = UserSettings.SaveToFile(fileSettings)
+    #    self.parent.parent.goutput.WriteLog(_('Vnet fron end settings saved to file \'%s\'.') % file) TODO
+    #    self.Close()
+
+    def OnApply(self, event):
+        """!Button 'Apply' pressed"""
+        self.UpdateSettings()
+        #self.Close()
+
+    def OnClose(self, event):
+        """!Button 'Cancel' pressed"""
+        self.Close()
+
+class AddLayerDialog(wx.Dialog):
+    """!Adds layer with analysis result into layer tree"""
+   
+    def __init__(self, parent,id=wx.ID_ANY,
+                 title =_("Add analasis result into layer tree"), style=wx.DEFAULT_DIALOG_STYLE):
+        """!Dialog for editing item cells in list"""
+
+        wx.Dialog.__init__(self, parent, id, title = _(title), style = style)
+
+        self.panel = wx.Panel(parent = self)
+       
+        # text fields and it's captions
+        self.vectSel = Select(parent = self.panel, type = 'vector', size = (-1, -1))
+        self.vectSellabel = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
+                                          label = _("Layer name:")) 
+
+        self.overwrite = wx.CheckBox(parent = self.panel, id=wx.ID_ANY,
+                                     label = _("Overwrite existing layer"))
+
+        # buttons
+        self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)
+        self.btnOk = wx.Button(self.panel, wx.ID_OK)
+        self.btnOk.SetDefault()
+
+        self._layout()
+
+    def _layout(self):
+
+        sizer = wx.BoxSizer(wx.VERTICAL)
+
+        box = wx.StaticBox (parent = self.panel, id = wx.ID_ANY,
+                            label = "Added layer")
+
+        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        # source coordinates
+        gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+
+        row = 0
+        gridSizer.Add(item = self.vectSellabel, 
+                      flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos = (row, 0))
+
+        gridSizer.Add(item = self.vectSel, 
+                      pos = (row, 1))
+
+        boxSizer.Add(item = gridSizer, proportion = 1,
+                     flag = wx.EXPAND | wx.ALL, border = 5)
+
+        sizer.Add(item = boxSizer, proportion = 1,
+                  flag = wx.EXPAND | wx.ALL, border = 5)
+
+        row +=1 
+        gridSizer.Add(item = self.overwrite, pos =(row, 0))
+
+        btnSizer = wx.StdDialogButtonSizer()
+        btnSizer.AddButton(self.btnCancel)
+        btnSizer.AddButton(self.btnOk)
+        btnSizer.Realize()
+
+        sizer.Add(item = btnSizer, proportion = 0,
+                  flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+
+        self.panel.SetSizer(sizer)
+        sizer.Fit(self)
\ No newline at end of file


Property changes on: grass-addons/grass7/gui/wxpython/wx.vnet/vnet/dialog.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/gui/wxpython/wx.vnet/vnet/toolbars.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.vnet/vnet/toolbars.py	                        (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.vnet/vnet/toolbars.py	2012-07-06 20:40:19 UTC (rev 52330)
@@ -0,0 +1,100 @@
+"""!
+ at package vnet.toolbars
+
+ at brief Vector network analysis dialog - toolbars
+
+Classes:
+ - toolbars::PointListToolbar
+ - toolbars::MainToolbar
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Stepan Turek <stepan.turek seznam.cz> (GSoC 2012)
+ at author Martin Landa <landa.martin gmail.com> (mentor)
+"""
+
+import wx
+
+from icon              import MetaIcon
+from gui_core.toolbars import BaseToolbar, BaseIcons
+
+class PointListToolbar(BaseToolbar):
+    """!Toolbar for managing list of points
+
+    @param parent reference to VNETDialog
+    """
+    def __init__(self, parent, list):
+        BaseToolbar.__init__(self, parent)
+        self.list = list
+        self.InitToolbar(self._toolbarData())
+        
+        # realize the toolbar
+        self.Realize()
+
+
+    def _toolbarData(self):
+
+        icons = {
+            'insertPoint'  : MetaIcon(img = 'pointer',
+                                    label = _('Insert point with mouse')),
+            'pointAdd'     : MetaIcon(img = 'point-create',
+                                    label = _('Add new point')),
+            'pointDelete'  : MetaIcon(img = 'gcp-delete',
+                                    label = _('Delete selected point'))
+            }
+
+        return  self._getToolbarData((('insertPoint', icons['insertPoint'],
+                                      self.list.dialog.OnInsertPoint,
+                                      wx.ITEM_CHECK),
+                                     ('pointAdd', icons["pointAdd"],
+                                        self.list.AddItem),
+                                     ('pointDelete', icons["pointDelete"],
+                                        self.list.DeleteItem)))
+                                    
+
+class MainToolbar(BaseToolbar):
+    """!Main toolbar
+    """
+    def __init__(self, parent):
+        BaseToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self._toolbarData())
+
+        choices = [ _('Shortest path'), ]
+        self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
+                                 choices = choices,
+                                 style = wx.CB_READONLY, size = (110, -1))
+        self.combo.SetSelection(0)
+        
+        self.comboid = self.AddControl(self.combo)
+        #self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
+                
+        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
+        self.combo.Hide()
+        self.combo.Show()
+
+        # realize the toolbar
+        self.Realize()
+
+
+    def _toolbarData(self):
+
+        icons = {
+                 'run' : MetaIcon(img = 'execute',
+                                  label = _('Execute analysis')),
+                 'saveTempLayer'   : MetaIcon(img = 'map-export',
+                                             label = _('Add temporary result of analasis into layer tree')),
+                  'settings'  : BaseIcons['settings'].SetLabel( _('Vector network analasis settings'))
+                }
+
+        return self._getToolbarData((
+                                     ("run", icons['run'],
+                                      self.parent.OnAnalyze),
+                                     ("saveTempLayer", icons['saveTempLayer'],
+                                      self.parent.OnSaveTmpLayer),
+                                     ('settings', icons["settings"],
+                                      self.parent.OnSettings),                                    
+                                     ("quit", BaseIcons['quit'],
+                                      self.parent.OnCloseDialog)
+                                    ))
\ No newline at end of file


Property changes on: grass-addons/grass7/gui/wxpython/wx.vnet/vnet/toolbars.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass-addons/grass7/gui/wxpython/wx.vnet/vnet/widgets.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.vnet/vnet/widgets.py	                        (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.vnet/vnet/widgets.py	2012-07-06 20:40:19 UTC (rev 52330)
@@ -0,0 +1,437 @@
+"""!
+ at package vnet.widgets
+
+ at brief Base class for list of points. 
+
+Classes:
+ - widgets::PointsList
+ - widgets::EditItem
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Stepan Turek <stepan.turek seznam.cz> (GSoC 2012)
+ at author Martin Landa <landa.martin gmail.com> (mentor)
+"""
+
+import os
+import wx
+from copy import copy, deepcopy
+
+import wx
+from wx.lib.mixins.listctrl import CheckListCtrlMixin, ColumnSorterMixin, ListCtrlAutoWidthMixin
+
+from core import globalvar
+
+
+class PointsList(wx.ListCtrl,
+                 CheckListCtrlMixin,
+                 ListCtrlAutoWidthMixin,
+                 ColumnSorterMixin):
+
+    def __init__(self, parent, cols, id=wx.ID_ANY,
+                 pos=wx.DefaultPosition, size=wx.DefaultSize,
+                 style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_HRULES |
+                 wx.LC_SINGLE_SEL):
+        """!Creates list for points. 
+
+        PointsList class was extracted from GCPList class in GCP manager. 
+
+        Important parameters:
+        @param cols is list containing list items. which represents columns.
+                This columns will be added in order as they are in list. 
+                Class will add as first column "use" with number of point and checkbox.
+                Structure of list item must be this:
+               -1. item: column name 
+               -2. item: If column is editable by user, it must contain convert function to convert
+                         inserted string to it's type for sorting. Use None for non editable 
+                         columns.
+               -3. item: Default value for column cell. Value should be given in it's  type 
+                         in order to sorting would work properly.
+  
+        Example of cols parameter:
+                 column name, convert function, default val
+        @code
+         cols =   [
+             wx.ListCtrl, float, 0.0],
+                   ['source N', float, 0.0],
+                   ['target E', float, 0.0],
+                   ['target N', float, 0.0],
+                   ['Forward error', None, 0],
+                   ['Backward error', None, 0]
+                   ['type', ["", "Start point", "End point"], ""] # Select from 3 choices ("Start point", "End point"), 
+                                                                  # choice "" is default.
+                  ]
+        @endcode
+
+        List self.itemDataMap stores data for sorting comparison, it can be used 
+        for getting present data in list. If you do not know what you are doing,
+        do not modify it. 
+ 
+        """
+
+        wx.ListCtrl.__init__(self, parent, id, pos, size, style)
+
+        # Mixin settings
+        CheckListCtrlMixin.__init__(self)
+        ListCtrlAutoWidthMixin.__init__(self)
+        # TextEditMixin.__init__(self)
+
+        # inserts first column with points numbers and checkoboxes
+        cols.insert(0, ['use', False, '0', 0])
+
+        # initialization of dict whith data
+        self.cols_data = {}
+        self.cols_data["colsNames"] = []
+        self.cols_data["colsEditable"] = []        
+        self.cols_data["itemDefaultVals"] = []
+
+        for col in cols:
+            self.cols_data["colsNames"].append(col[0])
+            self.cols_data["colsEditable"].append(col[1])
+            self.cols_data["itemDefaultVals"].append(col[2])
+
+        # tracks whether list items are checked or not
+        self.CheckList = [] 
+
+        self._CreateCols()
+
+        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
+        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
+        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
+
+        self.selected = wx.NOT_FOUND
+        self.selectedkey = -1
+
+
+        # CheckListCtrlMixin must set an ImageList first
+        self.il = self.GetImageList(wx.IMAGE_LIST_SMALL)
+
+        # images for column sorting
+        SmallUpArrow = wx.BitmapFromImage(self.getSmallUpArrowImage())            
+        SmallDnArrow = wx.BitmapFromImage(self.getSmallDnArrowImage())            
+        self.sm_dn = self.il.Add(SmallDnArrow)
+        self.sm_up = self.il.Add(SmallUpArrow)
+
+        # initialize column sorter
+        self.itemDataMap = []
+        ncols = self.GetColumnCount()
+        ColumnSorterMixin.__init__(self, ncols)
+
+        # init to ascending sort on first click
+        self._colSortFlag = [1] * ncols
+
+        self.ResizeColumns()
+        self.SetColumnWidth(0, 50)
+
+    def _CreateCols(self):
+        """! Creates columns in list"""
+        if 0:
+            # normal, simple columns
+            idx_col = 0
+            for col in self.cols_data["colsNames"]:
+                self.InsertColumn(idx_col, _(col))
+                idx_col += 1
+        else:
+            # the hard way: we want images on the column header
+            info = wx.ListItem()
+            info.SetMask(wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT)
+            info.SetImage(-1)
+            info.m_format = wx.LIST_FORMAT_LEFT
+
+            idx_col = 0
+            for lbl in self.cols_data["colsNames"]:
+                info.SetText(_(lbl)) 
+                self.InsertColumnInfo(idx_col, info)
+                idx_col += 1
+
+
+    def AddItem(self, event):
+        """! Appends an item to list whith default values"""
+
+        itemData = copy(self.cols_data["itemDefaultVals"])
+
+        self.selectedkey = self.GetItemCount()
+
+        itemData[0] = self.selectedkey + 1
+        self.itemDataMap.append(copy(itemData))
+
+        self.Append(map(str, itemData))             
+
+        self.selected = self.GetItemCount() - 1
+        self.SetItemData(self.selected, self.selectedkey)
+
+        self.SetItemState(self.selected,
+                          wx.LIST_STATE_SELECTED,
+                          wx.LIST_STATE_SELECTED)
+
+        self.ResizeColumns()
+
+        return self.selected
+
+    def EditCell(self, item, col, cellData):
+        """! Changes value in list"""
+        
+        self.itemDataMap[self.GetItemData(item)][col] = cellData
+        self.SetStringItem(item, col, str(cellData))
+
+
+    def DeleteItem(self, event = None):
+        """! Deletes selected item in list"""
+        if self.selected == wx.NOT_FOUND:
+            return
+
+        key = self.GetItemData(self.selected)
+        wx.ListCtrl.DeleteItem(self, self.selected)
+
+        del self.itemDataMap[key]
+
+        # update key and point number
+        for newkey in range(key, len(self.itemDataMap)):
+            index = self.FindItemData(-1, newkey + 1)
+            self.itemDataMap[newkey][0] = newkey
+            self.SetStringItem(index, 0, str(newkey + 1))
+            self.SetItemData(index, newkey)
+
+        # update selected
+        if self.GetItemCount() > 0:
+            if self.selected < self.GetItemCount():
+                self.selectedkey = self.GetItemData(self.selected)
+            else:
+                self.selected = self.GetItemCount() - 1
+                self.selectedkey = self.GetItemData(self.selected)
+                
+            self.SetItemState(self.selected,
+                              wx.LIST_STATE_SELECTED,
+                              wx.LIST_STATE_SELECTED)
+        else:
+            self.selected = wx.NOT_FOUND
+            self.selectedkey = -1
+
+
+    def ClearItem(self, event):
+        """"! Clears all values in selected item of points list and unchecks it."""
+        if self.selected == wx.NOT_FOUN:
+            return
+        index = self.selected
+        i = 0
+        for value in self.self.cols_data["itemDefaultVals"]:
+            if i == 0:
+                i  += 1
+                continue
+            self.EditCell(index, i, value)
+            i  += 1
+        self.CheckItem(index, False)
+
+    def ResizeColumns(self, minWidth = [90, 120]):
+        """! Resize columns"""
+        for i in range(self.GetColumnCount()):
+            self.SetColumnWidth(i, wx.LIST_AUTOSIZE)
+            # first column is checkbox, don't set to minWidth
+            if i > 0 and self.GetColumnWidth(i) < minWidth[i > 4]:
+                self.SetColumnWidth(i, minWidth[i > 4])
+
+        self.SendSizeEvent()
+
+    def GetSelected(self):
+        """!Get index of selected item."""
+        return self.selected
+
+    # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
+    def GetSortImages(self):
+        return (self.sm_dn, self.sm_up)
+
+    # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
+    def GetListCtrl(self):
+        return self
+
+
+    def OnItemActivated(self, event):
+        """! When item is double clicked, open editor to update coordinate values. """
+        data = []
+
+        index = event.GetIndex()
+        key = self.GetItemData(index)       
+        changed = False
+
+        for i in range(self.GetColumnCount()):
+            if  self.cols_data["colsEditable"][i]:
+                data.append([i, #culumn number
+                             self.GetItem(index, i).GetText(), #cell value 
+                             self.cols_data["colsEditable"][i]]) #convert function for type check
+
+        dlg = self.CreateEditDialog(data = data, pointNo = key)
+
+        if dlg.ShowModal() == wx.ID_OK:
+            editedData = dlg.GetValues() # string
+            
+            if len(editedData) == 0:
+                GError(parent = self,
+                       message=_("Invalid value inserted. Operation canceled."))
+            else:
+                i = 0
+                for editedCell in editedData:
+                    if editedCell[1] != data[i][1]:
+                        self.SetStringItem(index, editedCell[0], str(editedCell[1]))
+                        self.itemDataMap[key][editedCell[0]] = editedCell[1]
+                        changed = True
+                    i += 1 
+
+        return changed
+        
+    def CreateEditDialog(self, data, pointNo):
+        """!
+        It is possible to define in child derived class
+        and adapt created dialog (e. g. it's title...) 
+        """
+
+        return  EditItem(parent=self, id=wx.ID_ANY, data = data, pointNo=pointNo)
+
+    def OnColClick(self, event):
+        """!ListCtrl forgets selected item..."""
+        self.selected = self.FindItemData(-1, self.selectedkey)
+        self.SetItemState(self.selected,
+                          wx.LIST_STATE_SELECTED,
+                          wx.LIST_STATE_SELECTED)
+        event.Skip()
+
+    def OnItemSelected(self, event):
+
+        if self.selected != event.GetIndex():
+            self.selected = event.GetIndex()
+            self.selectedkey = self.GetItemData(self.selected)
+
+        event.Skip()
+
+    def getSmallUpArrowImage(self):
+
+        stream = open(os.path.join(globalvar.ETCIMGDIR, 'small_up_arrow.png'), 'rb')
+        try:
+            img = wx.ImageFromStream(stream)
+        finally:
+            stream.close()
+        return img
+
+    def getSmallDnArrowImage(self):
+
+        stream = open(os.path.join(globalvar.ETCIMGDIR, 'small_down_arrow.png'), 'rb')
+        try:
+            img = wx.ImageFromStream(stream)
+        finally:
+            stream.close()
+        return img
+
+class EditItem(wx.Dialog):
+    
+    def __init__(self, parent, data, pointNo, itemCap = "Point No." ,id=wx.ID_ANY,
+                 title =_("Edit point"), style=wx.DEFAULT_DIALOG_STYLE):
+        """!Dialog for editing item cells in list"""
+
+        wx.Dialog.__init__(self, parent, id, title=_(title), style=style)
+
+        panel = wx.Panel(parent=self)
+        sizer = wx.BoxSizer(wx.VERTICAL)
+
+        box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
+                            label=" %s %s " % (_(itemCap), str(pointNo + 1)))
+        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        # source coordinates
+        gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
+       
+        self.fields = [] 
+        self.data = deepcopy(data)
+
+
+        col = 0
+        row = 0
+        iField = 0
+        for cell in self.data:
+
+            # Select
+            if type(cell[2]).__name__ == "list":
+                self.fields.append(wx.ComboBox(parent = panel, id = wx.ID_ANY,
+                                               choices = cell[2],
+                                               style = wx.CB_READONLY, 
+                                               size = (110, -1)))
+            # Text field
+            else:
+                if cell[2] == float:
+                    validator = FloatValidator()
+                elif cell[2] == int:
+                    validator = IntegerValidator()
+                else:
+                    validator = None
+
+                if validator:
+                    self.fields.append(wx.TextCtrl(parent=panel, id=wx.ID_ANY, 
+                                                   validator = validator, size=(150, -1)))
+                else:
+                    self.fields.append(wx.TextCtrl(parent=panel, id=wx.ID_ANY, 
+                                                   size=(150, -1)))
+                    self.fields[iField].SetValue(str(cell[1]))
+
+            label = wx.StaticText(parent = panel, id=wx.ID_ANY,
+                                  label = _(parent.GetColumn(cell[0]).GetText()) + ":") # name of column)
+
+            gridSizer.Add(item=label,
+                          flag=wx.ALIGN_CENTER_VERTICAL,
+                          pos=(row, col))
+
+            col += 1
+
+            gridSizer.Add(item=self.fields[iField],
+                          pos=(row, col))
+
+
+            if col%3 == 0:
+                col = 0
+                row += 1
+            else:
+                col += 1
+
+            iField += 1
+
+        boxSizer.Add(item=gridSizer, proportion=1,
+                  flag=wx.EXPAND | wx.ALL, border=5)
+
+        sizer.Add(item=boxSizer, proportion=1,
+                  flag=wx.EXPAND | wx.ALL, border=5)
+
+        #
+        # buttons
+        #
+        self.btnCancel = wx.Button(panel, wx.ID_CANCEL)
+        self.btnOk = wx.Button(panel, wx.ID_OK)
+        self.btnOk.SetDefault()
+
+        btnSizer = wx.StdDialogButtonSizer()
+        btnSizer.AddButton(self.btnCancel)
+        btnSizer.AddButton(self.btnOk)
+        btnSizer.Realize()
+
+        sizer.Add(item=btnSizer, proportion=0,
+                  flag=wx.ALIGN_RIGHT | wx.ALL, border=5)
+
+        panel.SetSizer(sizer)
+        sizer.Fit(self)
+
+    def GetValues(self):
+        """!Return list of values (as strings).
+        """
+
+        iField = 0
+        self.data
+        for cell in self.data:
+            value = self.fields[iField].GetValue()
+            
+            if type(cell[2]).__name__ == "list":
+                    cell[1] = value
+            else:
+                try:
+                    cell[1] = cell[2](value)
+                except ValueError:
+                    return []
+            iField += 1
+
+        return self.data
\ No newline at end of file



More information about the grass-commit mailing list