[GRASS-SVN] r47914 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 27 18:48:26 EDT 2011


Author: cmbarton
Date: 2011-08-27 15:48:26 -0700 (Sat, 27 Aug 2011)
New Revision: 47914

Modified:
   grass/trunk/gui/wxpython/gui_modules/colorrules.py
Log:
Fix scrollbar in color rules panel

Modified: grass/trunk/gui/wxpython/gui_modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/colorrules.py	2011-08-27 18:08:11 UTC (rev 47913)
+++ grass/trunk/gui/wxpython/gui_modules/colorrules.py	2011-08-27 22:48:26 UTC (rev 47914)
@@ -60,19 +60,17 @@
         self.attributeType = attributeType
         self.properties = properties
         self.parent = parent
+        self.panelWidth = panelWidth
         
-        self.mainPanel = scrolled.ScrolledPanel(parent, id = wx.ID_ANY,
-                                          size = (panelWidth, 300),
-                                          style = wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER)
-        self.mainPanel.SetupScrolling(scroll_x = False)
         self.mainSizer = wx.FlexGridSizer(cols = 3, vgap = 6, hgap = 4)
         # put small border at the top of panel
         for i in range(3):
             self.mainSizer.Add(item = wx.Size(3, 3))
         
-        self.mainPanel.SetSizer(self.mainSizer)
-        self.mainPanel.SetAutoLayout(True)
-        
+        self.mainPanel = scrolled.ScrolledPanel(parent, id = wx.ID_ANY,
+                                          size = (self.panelWidth, 300),
+                                          style = wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER)
+                
         # (un)check all
         self.checkAll = wx.CheckBox(parent, id = wx.ID_ANY, label = _("Check all"))
         self.checkAll.SetValue(True)
@@ -87,12 +85,15 @@
         self.btnAdd.Bind(wx.EVT_BUTTON, self.OnAddRules)
         self.checkAll.Bind(wx.EVT_CHECKBOX, self.OnCheckAll)
         self.clearAll.Bind(wx.EVT_BUTTON, self.OnClearAll)
+
+        self.mainPanel.SetSizer(self.mainSizer)
+        self.mainPanel.SetAutoLayout(True)
+        self.mainPanel.SetupScrolling()    
     
-    
     def Clear(self):
         """!Clear and widgets and delete information"""
         self.ruleslines.clear()
-        self.mainPanel.DestroyChildren()
+        self.mainSizer.Clear(deleteWindows=True)
     
     def OnCheckAll(self, event):
         """!(Un)check all rules"""
@@ -113,10 +114,9 @@
         self.AddRules(nrules)
         
     def AddRules(self, nrules, start = False):
-        """!Add rules
-        
+        """!Add rules 
         @param start set widgets (not append)"""
-        
+       
         snum = len(self.ruleslines.keys())
         if start:
             snum = 0
@@ -157,7 +157,7 @@
                 if not start:
                     self.ruleslines[enable.GetId()] = { 'value' : '',
                                                         self.attributeType: init }
-            
+        
             self.mainSizer.Add(item = enable, proportion = 0,
                               flag = wx.ALIGN_CENTER_VERTICAL)
             self.mainSizer.Add(item = txt_ctrl, proportion = 0,
@@ -167,7 +167,6 @@
         
         self.mainPanel.Layout()
         self.mainPanel.SetupScrolling(scroll_x = False)
-       
     
     def OnRuleEnable(self, event):
         """!Rule enabled/disabled"""
@@ -504,11 +503,7 @@
                       flag = wx.ALIGN_CENTER_VERTICAL)
         bodySizer.Add(item = self.rulesPanel.btnAdd, pos = (row, 1))
         
-
-       
-                
-        return bodySizer
-    
+        return bodySizer    
         
     def InitDisplay(self):
         """!Initialize preview display, set dimensions and region
@@ -530,6 +525,7 @@
         ret = self.CreateColorTable()
         if not ret:
             gcmd.GMessage(parent = self, message = _("No valid color rules given."))
+
         if self.colorTable:
             self.UseAttrColumn(False)
         else:
@@ -633,8 +629,8 @@
         """!Load current color table (using `r(v).colors.out`)
         
         @param mapType map type (raster or vector)"""
-        
         self.rulesPanel.Clear()
+
         if mapType == 'raster':
             cmd = ['r.colors.out',
                    'read=True',
@@ -657,7 +653,7 @@
             self.OnPreview()
             return
         
-        self.ReadColorTable(ctable = ctable)    
+        self.ReadColorTable(ctable = ctable)     
     
     def CreateColorTable(self, tmp = False):
         """!Creates color table
@@ -1105,6 +1101,7 @@
   
     def OnCheckColumn(self, event):
         """!Use color column instead of color table"""
+
         if self.useColumn.GetValue():
             self.properties['loadColumn'] = self.fromColumn.GetStringSelection()
             self.properties['storeColumn'] = self.toColumn.GetStringSelection()
@@ -1122,9 +1119,7 @@
             self.fromColumn.Enable(False)
             self.toColumn.Enable(False)
             self.colorTable = True
-            
             self.LoadTable()
-        
             
     def EnableVectorAttributes(self, enable):
         """!Enable/disable part of dialog connected with db"""
@@ -1157,9 +1152,10 @@
                 self.inmap = None
         
         self.UpdateDialog()
-        
+       
     def UpdateDialog(self):
         """!Update dialog after map selection"""  
+        
         if not self.inmap:
             self.DisableClearAll()
             return
@@ -1191,7 +1187,6 @@
             for prop in ('sourceColumn', 'loadColumn', 'storeColumn'):
                 self.properties[prop] = ''
             self.EnableVectorAttributes(False)
-              
         else: # db connection exist
         # initialize layer selection combobox
             self.EnableVectorAttributes(True)
@@ -1210,10 +1205,11 @@
             # initialize column selection comboboxes 
             
             self.OnLayerSelection(event = None)
+
         if self.version7 and self.attributeType == 'color':
             self.useColumn.SetValue(False)
             self.OnCheckColumn(event = None) 
-        
+                    
         self.LoadTable()
             
         self.btnPreview.Enable(enable)
@@ -1615,10 +1611,8 @@
             for vector maps for thematic mapping in nviz"""
         self.vectorType = vectorType
         VectorColorTable.__init__(self, parent = parent, **kwargs)
-        
-        
-        self.SetTitle(_("Thematic mapping for vector map in 3D view"))
-        
+              
+        self.SetTitle(_("Thematic mapping for vector map in 3D view"))       
                     
     def _initLayer(self):
         """!Set initial layer when opening dialog"""
@@ -1818,4 +1812,4 @@
     def EraseMap(self):
         """!Erase preview"""
         self.Draw(self.pdc, pdctype = 'clear')
-    
+    
\ No newline at end of file



More information about the grass-commit mailing list