[GRASS-SVN] r49989 - grass/trunk/gui/wxpython/dbmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 30 12:36:03 EST 2011


Author: martinl
Date: 2011-12-30 09:36:03 -0800 (Fri, 30 Dec 2011)
New Revision: 49989

Modified:
   grass/trunk/gui/wxpython/dbmgr/dialogs.py
   grass/trunk/gui/wxpython/dbmgr/manager.py
Log:
wxGUI/dbmbr: insert/update records - show also data types


Modified: grass/trunk/gui/wxpython/dbmgr/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/dialogs.py	2011-12-30 16:56:54 UTC (rev 49988)
+++ grass/trunk/gui/wxpython/dbmgr/dialogs.py	2011-12-30 17:36:03 UTC (rev 49989)
@@ -567,7 +567,8 @@
         self.usebox = False
         self.cat = None
         winFocus = False
-        for column, value in data:
+        
+        for column, ctype, value in data:
             if self.keyId == cId:
                 self.cat = int(value)
                 if not keyEditable[1]:
@@ -588,10 +589,11 @@
                     winFocus = True
             
             label = wx.StaticText(parent = self.dataPanel, id = wx.ID_ANY,
-                                  label = column + ":")
+                                  label = column)
+            ctype = wx.StaticText(parent = self.dataPanel, id = wx.ID_ANY,
+                                  label = "[%s]:" % ctype)
+            self.widgets.append((label.GetId(), ctype.GetId(), valueWin.GetId()))
             
-            self.widgets.append((label.GetId(), valueWin.GetId()))
-            
             cId += 1
         
         self._layout()
@@ -601,15 +603,18 @@
         sizer = wx.BoxSizer(wx.VERTICAL)
         
         # data area
-        dataSizer = wx.FlexGridSizer (cols = 2, hgap = 3, vgap = 3)
-        dataSizer.AddGrowableCol(1)
+        dataSizer = wx.FlexGridSizer(cols = 3, hgap = 3, vgap = 3)
+        dataSizer.AddGrowableCol(2)
         
-        for labelId, valueId in self.widgets:
+        for labelId, ctypeId, valueId in self.widgets:
             label = self.FindWindowById(labelId)
+            ctype = self.FindWindowById(ctypeId)
             value = self.FindWindowById(valueId)
             
             dataSizer.Add(label, proportion = 0,
                           flag = wx.ALIGN_CENTER_VERTICAL)
+            dataSizer.Add(ctype, proportion = 0,
+                          flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
             dataSizer.Add(value, proportion = 0,
                           flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
         
@@ -637,9 +642,9 @@
         sizer.Add(item = btnSizer, proportion = 0,
                   flag = wx.EXPAND | wx.ALL, border = 5)
         
-        framewidth = self.GetSize()[0]
-        self.SetMinSize((framewidth,250))
-        
+        framewidth = self.GetBestSize()[0] + 25
+        self.SetMinSize((framewidth, 250))
+
         self.SetAutoLayout(True)
         self.SetSizer(sizer)
         sizer.Fit(self)
@@ -652,7 +657,7 @@
         If columns is given (list), return only values of given columns.
         """
         valueList = []
-        for labelId, valueId in self.widgets:
+        for labelId, ctypeId, valueId in self.widgets:
             column = self.FindWindowById(labelId).GetLabel().replace(':', '')
             if columns is None or column in columns:
                 value = str(self.FindWindowById(valueId).GetValue())

Modified: grass/trunk/gui/wxpython/dbmgr/manager.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/manager.py	2011-12-30 16:56:54 UTC (rev 49988)
+++ grass/trunk/gui/wxpython/dbmgr/manager.py	2011-12-30 17:36:03 UTC (rev 49989)
@@ -1352,12 +1352,14 @@
         colIdx = 0
         keyId = -1
         for col in columnName:
+            ctype = self.mapDBInfo.tables[table][col]['type']
             if col == keyColumn: # key 
                 if missingKey is False: 
-                    data.append((col, str(maxCat + 1)))
+                    data.append((col, ctype, str(maxCat + 1)))
                     keyId = colIdx
             else:
-                data.append((col, ''))
+                data.append((col, ctype, ''))
+            
             colIdx += 1
                 
         dlg = ModifyTableRecord(parent = self,
@@ -1463,16 +1465,17 @@
             
         # add other visible columns
         for i in range(len(columnName)):
+            ctype = self.mapDBInfo.tables[table][columnName[i]]['type']
             if columnName[i] == keyColumn: # key 
                 if missingKey is False: 
-                    data.append((columnName[i], str(cat)))
+                    data.append((columnName[i], ctype, str(cat)))
                     keyId = i
             else:
                 if missingKey is True:
                     value = list.GetItem(item, i-1).GetText()
                 else:
                     value = list.GetItem(item, i).GetText()
-                data.append((columnName[i], value))
+                data.append((columnName[i], ctype, value))
 
         dlg = ModifyTableRecord(parent = self, 
                                 title = _("Update existing record"),



More information about the grass-commit mailing list