[GRASS-SVN] r49164 - sandbox/lucadelu

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 9 19:04:52 EST 2011


Author: lucadelu
Date: 2011-11-09 16:04:52 -0800 (Wed, 09 Nov 2011)
New Revision: 49164

Modified:
   sandbox/lucadelu/r.li.setup.py
Log:
fix problem about remove widget, remove duplicate code

Modified: sandbox/lucadelu/r.li.setup.py
===================================================================
--- sandbox/lucadelu/r.li.setup.py	2011-11-09 21:10:12 UTC (rev 49163)
+++ sandbox/lucadelu/r.li.setup.py	2011-11-10 00:04:52 UTC (rev 49164)
@@ -40,6 +40,7 @@
 import utils
 from location_wizard import TitledPage as TitledPage
 from grass.script import core as grass
+from grass.script import raster as grast
 
 #@TODO create wizard instead of progressively increasing window
 
@@ -339,7 +340,6 @@
 	self.row_up = ''
 	self.col_len = ''
 	self.row_len = ''
-	wx.FindWindowById(wx.ID_FORWARD).Enable(False)
 
 	#column up/left
 	self.ColUpLeftlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
@@ -395,6 +395,13 @@
 	self.RowLentxt.Bind(wx.EVT_KILL_FOCUS, self.OnRowLeft)
 	self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnEnterPage)
 
+    def OnEnterPage(self, event):
+        """!Insert values into text controls for summary of location
+        creation options
+        """
+        rastinfo = grast.raster_info(self.parent.startpage.rast)
+        print rastinfo
+
     def OnColLeft(self,event):
 	"""!Sets the name of configuration file"""
 	self.col_up = self.ColUpLefttxt.GetValue()
@@ -423,14 +430,6 @@
 		      and not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
 	    wx.FindWindowById(wx.ID_FORWARD).Enable(True)
 
-    def OnEnterPage(self, event=None):
-        if self.row_up == '' and self.row_len == '' and self.col_len == '' \
-						    and self.col_up == '':
-            wx.FindWindowById(wx.ID_FORWARD).Enable(False)
-        else:
-            wx.FindWindowById(wx.ID_FORWARD).Enable(True)
-
-
 class SamplingAreasPage(TitledPage):
     """
     Set name of configuration file, choose raster and optionally vector/sites
@@ -451,11 +450,7 @@
                                      label = _("Sample units"))
         self.radio4 = wx.RadioButton(parent = self, id = wx.ID_ANY,
                                      label = _("Moving window"))
-        if self.parent.startpage.vectorarea:
-	#if rlisetting['vectorarea']:
-	    self.radio5 = wx.RadioButton(parent = self, id = wx.ID_ANY,
-					label = _("Select areas from the "
-						"overlayed vector map"))     
+
         # layout
         self.sizer.AddGrowableCol(1)
         self.sizer.SetVGap(10)
@@ -464,9 +459,6 @@
         self.sizer.Add(item = self.radio3, flag = wx.ALIGN_LEFT, pos = (3, 1))
         self.sizer.Add(item = self.radio4, flag = wx.ALIGN_LEFT, pos = (4, 1))
         
-        if self.parent.startpage.vectorarea:
-        #if rlisetting['vectorarea']:
-	    self.sizer.Add(item = self.radio5, flag = wx.ALIGN_LEFT, pos = (5, 1))
 	    
 	wx.FindWindowById(wx.ID_FORWARD).Enable(False)
 	
@@ -475,11 +467,20 @@
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id = self.radio2.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id = self.radio3.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id = self.radio4.GetId())
-        if self.parent.startpage.vectorarea:
-	    self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id = self.radio5.GetId())
-        #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED,  self.OnEnterPage)
+        self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
 
-
+    def OnEnterPage(self, event):
+        """!Insert values into text controls for summary of location
+        creation options
+        """
+        print "vector area is %s" % self.parent.startpage.vectorarea
+        if self.parent.startpage.vectorarea:
+            self.radio5 = wx.RadioButton(parent = self, id = wx.ID_ANY,
+                                        label = _("Select areas from the "
+                                        "overlayed vector map"))
+            self.sizer.Add(item = self.radio5, flag = wx.ALIGN_LEFT, pos = (5, 1))                                                
+            self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id = self.radio5.GetId())
+            
     def SetVal(self, event):
         """!Choose method"""
         if event.GetId() == self.radio1.GetId():
@@ -496,6 +497,7 @@
     def Region(self):
 	#show this only if radio2 it is selected
 	try:
+            self.sizer.Hide(self.regionBox)
 	    self.sizer.Remove(self.regionBox)
 	    self.sizer.Layout()
 	except AttributeError:
@@ -512,6 +514,7 @@
     def KeyDraw(self):
 	#show this only if radio3 and radio4 it is selected
 	try:
+            self.sizer.Hide(self.regionBox)
 	    self.sizer.Remove(self.regionBox)
 	    self.sizer.Layout()
 	except AttributeError:
@@ -526,6 +529,7 @@
 
     def DrawNothing(self):
 	try:
+            self.sizer.Hide(self.regionBox)
 	    self.sizer.Remove(self.regionBox)
 	    self.sizer.Layout()
 	except AttributeError:
@@ -575,27 +579,6 @@
 	elif event.GetInt() == 4:
 	    print "Centered over sites"
 
-class SampleUnitsKeyPage(TitledPage):
-    """!Set values from keyboard for moving window"""
-    
-    def __init__(self, wizard, parent):
-        TitledPage.__init__(self, wizard, _("Units"))
-
-        self.parent = parent
-        self.sizer.AddGrowableCol(2) 
-	self.typeBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
-				      label= _("Select type of shape"),
-				      choices=[_('Rectangle'), _('Circle')],
-				      majorDimension=wx.RA_SPECIFY_COLS)
-	self.sizer.Add(self.typeBox, flag = wx.ALIGN_LEFT, pos = (1, 1))
-	self.typeBox.Bind(wx.EVT_RADIOBOX, self.OnType)
-    def OnType(self):
-	if event.GetInt() == 0:
-	    print "activate the textctrl for rectangle"
-	elif event.GetInt() == 1:
-	    print "activate the textctrl for circle"
-
-
 class SummaryPage(TitledPage):
     """!Shows summary result of choosing data"""
     



More information about the grass-commit mailing list