[GRASS-SVN] r49990 - grass/branches/develbranch_6/gui/wxpython/dbmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 30 12:37:38 EST 2011


Author: martinl
Date: 2011-12-30 09:37:38 -0800 (Fri, 30 Dec 2011)
New Revision: 49990

Modified:
   grass/branches/develbranch_6/gui/wxpython/dbmgr/dialogs.py
   grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py
Log:
wxGUI/dbmbr: insert/update records - show also data types
	     (merge r49989 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/dbmgr/dialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/dbmgr/dialogs.py	2011-12-30 17:36:03 UTC (rev 49989)
+++ grass/branches/develbranch_6/gui/wxpython/dbmgr/dialogs.py	2011-12-30 17:37:38 UTC (rev 49990)
@@ -563,7 +563,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]:
@@ -584,10 +585,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()
@@ -597,15 +599,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)
         
@@ -633,9 +638,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)
@@ -648,7 +653,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/branches/develbranch_6/gui/wxpython/dbmgr/manager.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py	2011-12-30 17:36:03 UTC (rev 49989)
+++ grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py	2011-12-30 17:37:38 UTC (rev 49990)
@@ -1350,12 +1350,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,
@@ -1461,16 +1463,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