[GRASS-SVN] r51680 - sandbox/lucadelu

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 23 12:17:17 EDT 2012


Author: lucadelu
Date: 2012-05-23 09:17:17 -0700 (Wed, 23 May 2012)
New Revision: 51680

Modified:
   sandbox/lucadelu/r.li.setup.py
Log:
improvement

Modified: sandbox/lucadelu/r.li.setup.py
===================================================================
--- sandbox/lucadelu/r.li.setup.py	2012-05-23 15:45:07 UTC (rev 51679)
+++ sandbox/lucadelu/r.li.setup.py	2012-05-23 16:17:17 UTC (rev 51680)
@@ -146,14 +146,14 @@
     def OnHelp(self, event):
         """!Launches r.mapcalc help"""
         gcmd.RunCommand('g.manual', parent = self, entry = self.cmd)
-        
+
     def OnRemove(self, event):
         """!Remove configuration file from path and update the list"""
         confile = self.listfiles[self.listfileBox.GetSelections()[0]]
         self.listfileBox.Delete(self.listfileBox.GetSelections()[0])
         grass.try_remove(os.path.join(self.rlipath,confile))
         return
-        
+
     def OnNew(self, event):
         """!Remove configuration file from path and update the list"""
         RLIWizard(self)
@@ -174,11 +174,12 @@
                  caption = _('Rename configuration file'))
         if dlg.ShowModal() == wx.ID_OK:
             res = dlg.GetValue()
-            os.rename(os.path.join(self.rlipath,confile),os.path.join(self.rlipath,res))
+            newname = "%s%s%s" % (self.rlipath, os.sep, res)
+            os.rename(os.path.join(self.rlipath,confile), newname)
             self.listfiles = self.ListFiles()
             self.listfileBox.Clear()
             self.listfileBox.Set(self.listfiles)        
-                 
+
 class RLIWizard(object):
     """
     Start wizard here and finish wizard here
@@ -193,7 +194,8 @@
         self.keyboardpage = KeybordPage(self.wizard, self)
         self.samplingareapage = SamplingAreasPage(self.wizard, self)
         self.summarypage = SummaryPage(self.wizard, self)
-        self.samplingunitskey = SampleUnitsKeyPage(self.wizard, self)
+        self.samplingunits = SampleUnitsKeyPage(self.wizard, self)
+        self.moving = MovingWindows(self.wizard, self)
 
         #order of pages
         self.startpage.SetNext(self.samplingareapage)
@@ -201,25 +203,29 @@
         self.keyboardpage.SetNext(self.samplingareapage)
         self.samplingareapage.SetPrev(self.startpage)
         self.samplingareapage.SetNext(self.summarypage)
-        self.samplingunitskey.SetPrev(self.samplingareapage)
-        self.samplingunitskey.SetNext(self.summarypage)
+        self.samplingunits.SetPrev(self.samplingareapage)
+        self.samplingunits.SetNext(self.summarypage)
+        self.moving.SetPrev(self.samplingareapage)
+        self.moving.SetNext(self.summarypage)
         self.summarypage.SetPrev(self.samplingareapage)
-        
+
         #layout 
         self.startpage.DoLayout()
         self.keyboardpage.DoLayout()
         self.samplingareapage.DoLayout()
         self.summarypage.DoLayout()
-        self.samplingunitskey.DoLayout()
-        
+        self.samplingunits.DoLayout()
+        self.moving.DoLayout()
+
         self.wizard.FitToPage(self.startpage)
         #run_wizard
         if self.wizard.RunWizard(self.startpage):
+            print self.startpage.conf_name, self.startpage.newconftxt.GetValue()
             dlg = wx.MessageDialog(parent = self.parent,
                                 message = _("Do you want to create r.li configuration file <%s>?") % self.startpage.conf_name,
                                 caption = _("Create new r.li configuration file?"),
                                 style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
-            
+
             if dlg.ShowModal() == wx.ID_NO:
                 self._cleanup()
                 dlg.Destroy()                
@@ -227,7 +233,7 @@
                 self._write_confile()
                 self._cleanup()
                 dlg.Destroy()
-                
+
         else:
             self.wizard.Destroy()
             gcmd.GMessage(parent = self.parent,
@@ -245,13 +251,11 @@
     def _temp_region(self):
         # save current settings:
         grass.use_temp_region()
-
         # Temporarily aligning region resolution to $RASTER resolution
         # keep boundary settings
         grass.run_command('g.region', rast = self.startpage.rast) 
         self.gregion = grass.region()
 
-            
     def _write_region(self,fil):
         """Write the region"""
         self.rasterinfo = grast.raster_info(self.startpage.rast)        
@@ -286,7 +290,6 @@
             elif self.startpage.region == 'key':
                 fil.write("SAMPLEAREA %f|%f|%f|%f\n" % (x,y,rl,cl))
 
-
     def _cleanup(self):
         """Clean all the variables to save into configuration file"""
         self.startpage.conf_name = ''
@@ -298,21 +301,25 @@
         self.keyboardpage.row_len = ''
         self.keyboardpage.row_up = ''
         self.samplingareapage.samplingtype = 'whole'
-        self.samplingunitskey.sizew = ''
-        self.samplingunitskey.sizeh = ''
+        self.samplingunits.sizew = ''
+        self.samplingunits.sizeh = ''
 
-
-
 class FirstPage(TitledPage):
     """
     Set name of configuration file, choose raster and optionally vector/sites
     """
-    
+
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Select maps and define name"))
 
+        self.region = 'whole'
+        self.rast = ''
+        self.conf_name = ''
+        self.vect = ''        
+        wx.FindWindowById(wx.ID_FORWARD).Enable(False)        
+
         self.parent = parent
-        
+
         self.sizer.AddGrowableCol(2)
         #name of output configuration file
         self.newconflabel = wx.StaticText(parent = self, id = wx.ID_ANY,
@@ -320,7 +327,7 @@
 
         self.newconftxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
         wx.CallAfter(self.newconftxt.SetFocus)
-        
+
         self.sizer.Add(item = self.newconflabel, border=5, pos=(1, 1),
                         flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
         self.sizer.Add(item = self.newconftxt, border=5, pos=(1, 2),
@@ -336,7 +343,7 @@
                         flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
         #vector
         self.vectsellabel = wx.StaticText(parent = self, id = wx.ID_ANY,
-                        label = _('Raster map to use to select areas'))
+                        label = _('Vector map to use to select areas'))
         self.vectselect = gselect.Select(parent = self, id = wx.ID_ANY, size = (250, -1),
                                             type = 'vector', multiple = False)
         self.sizer.Add(item = self.vectsellabel, border=5, pos=(3, 1),
@@ -358,7 +365,7 @@
         self.vectselect.Bind(wx.EVT_TEXT, self.OnVector)
         self.mapselect.Bind(wx.EVT_TEXT, self.OnRast)
         
-        self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+        #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
         self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
 
         wx.FindWindowById(wx.ID_FORWARD).Enable(False)
@@ -376,42 +383,49 @@
 	    #to remove when I know how to connect or create a monitor
 	    gcmd.GMessage(parent = self,
                               message = _("Function not supported yet"))
-        #event.Veto()
         return
-	    #wx.FindWindowById(wx.ID_FORWARD).Enable(False)
-        if self.conf_name != '' and self.rast != '' and not self.region == 'draw' \
+        if self.conf_name != '' and self.rast != '' and self.region != 'draw' \
                             and not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
             wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+        else:
+            wx.FindWindowById(wx.ID_FORWARD).Enable(False)
 
     def OnName(self,event):
 	"""!Sets the name of configuration file"""
 	self.conf_name = self.newconftxt.GetValue()
+	print self.conf_name
 	if self.conf_name in self.parent.parent.listfiles:
             gcmd.GMessage(parent = self,
-                          message = _("The configuration file %s already " % self.conf_name \
-                          + "exists, please change name"))
+                          message = _("The configuration file %s " % self.conf_name \
+                          + "already exists, please change name"))
             self.newconftxt.SetValue('')
-	if self.region != '' or self.rast != '' or self.conf_name != '' and not \
+	if self.region != 'draw' and self.rast != '' and self.conf_name != '' and not \
 				wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
-	    wx.FindWindowById(wx.ID_FORWARD).Enable(True)	
+	    wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+	else:
+            wx.FindWindowById(wx.ID_FORWARD).Enable(False)
 
     def OnRast(self, event):
         """!Sets raster map"""
         self.rast = event.GetString()
-	if self.region != '' or self.conf_name != '' or self.rast != '' and not \
+	if self.region != 'draw' and self.conf_name != '' and self.rast != '' and not \
 				wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
 	    wx.FindWindowById(wx.ID_FORWARD).Enable(True)
-	    
+        else:
+            wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+
     def OnVector(self, event):
         """!Sets vector map"""
         self.vect = event.GetString()
-	if self.region != '' or self.conf_name != '' or self.rast != '' and not \
+	if self.region != 'draw' and self.conf_name != '' and self.rast != '' and not \
 				wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
 	    wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+        else:
+            wx.FindWindowById(wx.ID_FORWARD).Enable(False)
 
     def OnExitPage(self, event=None):
         """!Function during exiting"""
-        if self.region == '' or self.conf_name == '' or self.rast == '':
+        if self.region == 'draw' or self.conf_name == '' or self.rast == '':
             wx.FindWindowById(wx.ID_FORWARD).Enable(False)
         else:
             wx.FindWindowById(wx.ID_FORWARD).Enable(True)
@@ -428,19 +442,11 @@
                 event.Veto()
                 return
 
-    def OnEnterPage(self, event=None):
-        """!Function during entry"""
-        self.region = 'whole'
-        self.rast = ''
-        self.conf_name = ''
-        self.vect = ''        
-        wx.FindWindowById(wx.ID_FORWARD).Enable(False)
-
 class KeybordPage(TitledPage):
     """
     Set name of configuration file, choose raster and optionally vector/sites
     """
-    
+
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Insert sampling frame parameter"))
 
@@ -448,7 +454,9 @@
         self.sizer.AddGrowableCol(2)
         self.col_len = ''
         self.row_len = ''
-
+        self.col_up = '0'
+        self.row_up = '0'
+             
         #column up/left
         self.ColUpLeftlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
                         label = _('Column of upper left corner'))
@@ -497,10 +505,13 @@
         self.sizer.Add(item = self.ColLentxt, border=5, pos=(4, 2),
                         flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)                       
 
+        self.ColUpLefttxt.SetValue(self.col_up)
+        self.RowUpLefttxt.SetValue(self.row_up)                        
+                        
         self.ColUpLefttxt.Bind(wx.EVT_KILL_FOCUS, self.OnColLeft)
         self.RowUpLefttxt.Bind(wx.EVT_KILL_FOCUS, self.OnRowLeft)
         self.ColLentxt.Bind(wx.EVT_KILL_FOCUS, self.OnColLen)
-        self.RowLentxt.Bind(wx.EVT_KILL_FOCUS, self.OnRowLeft)
+        self.RowLentxt.Bind(wx.EVT_KILL_FOCUS, self.OnRowLen)
         self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
         self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
 
@@ -519,7 +530,7 @@
         self.col_len = self.ColLentxt.GetValue()
         checkValue(self.col_len)
 
-    def OnRowLeft(self,event):
+    def OnRowLen(self,event):
         """!Sets the name of configuration file"""
         self.row_len = self.RowLentxt.GetValue()
         checkValue(self.row_len)
@@ -527,15 +538,11 @@
     def OnEnterPage(self, event):
         """!Sets the default values, for the entire map
         """
-        self.col_up = '0'
-        self.row_up = '0'
         if self.col_len == '' and self.row_len == '':
             rastinfo = grast.raster_info(self.parent.startpage.rast)
             self.col_len = rastinfo['cols']
             self.row_len = rastinfo['rows']
-        
-        self.ColUpLefttxt.SetValue(self.col_up)
-        self.RowUpLefttxt.SetValue(self.row_up)
+
         self.ColLentxt.SetValue(self.col_len)
         self.RowLentxt.SetValue(self.row_len)
 
@@ -544,7 +551,6 @@
         if self.row_len == '' or self.col_len == '' or self.row_up == '' or self.col_up == '':
             wx.FindWindowById(wx.ID_FORWARD).Enable(False)
         else:
-            print self.row_len, self.col_len, self.row_up, self.col_up
             wx.FindWindowById(wx.ID_FORWARD).Enable(True)
 
 class SamplingAreasPage(TitledPage):
@@ -612,11 +618,11 @@
 	    self.Region()
         elif event.GetId() == self.radio3.GetId():
 	    self.samplingtype = 'units'
-	    self.SetNext(self.parent.samplingunitskey)
+	    self.SetNext(self.parent.samplingunits)
 	    self.KeyDraw()
         elif event.GetId() == self.radio4.GetId():
 	    self.samplingtype = 'moving'
-	    self.SetNext(self.parent.samplingunitskey)
+	    self.SetNext(self.parent.moving)
 	    self.KeyDraw()
         elif event.GetId() == self.radio5.GetId():
 	    self.samplingtype = 'vector'
@@ -665,7 +671,7 @@
         """Function called by KeyDraw to find what method is choosed"""
         if event.GetInt() == 0:
             self.regionbox = 'keybord'
-            self.SetNext(self.parent.samplingunitskey)
+            self.SetNext(self.parent.samplingunits)
 
         elif event.GetInt() == 1:
             self.regionbox = 'drawmouse'
@@ -694,7 +700,7 @@
         TitledPage.__init__(self, wizard, _("Units"))
 
         self.parent = parent
-        self.sizer.AddGrowableCol(2)
+        self.sizer.AddGrowableCol(1)
         self.sizew = ''
         self.sizeh = ''
         # type of shape
@@ -705,62 +711,149 @@
 
 	self.sizer.Add(self.typeBox, flag = wx.ALIGN_LEFT, pos = (1, 1))
 
+        self.distributionBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
+                    label= _("Select method of sampling unit distribution"),
+                    choices=[_('Random non overlapping'),
+                    _('Systematic contiguos'), _('Stratified random'),
+                    _('Systematic non contiguos'), _('Centered over sites')],
+                    majorDimension=wx.RA_SPECIFY_COLS)
+        self.sizer.Add(item = self.distributionBox, pos=(2, 1),
+                    flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+        self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                label = _('Width size (in cells)? '))
+        self.widthTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+        
+        self.sizer.Add(item = self.widthLabel, border=5, pos=(3, 1),
+                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+        self.sizer.Add(item = self.widthTxt, border=5, pos=(3, 2),
+                    flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+                    
+        self.heightLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                label = _('Height size (in cells)? '))
+        self.heightTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+        
+        self.sizer.Add(item = self.heightLabel, border=5, pos=(4, 1),
+                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+        self.sizer.Add(item = self.heightTxt, border=5, pos=(4, 2),
+                    flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)                    
+                    
 	self.typeBox.Bind(wx.EVT_RADIOBOX, self.OnType)
-        self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
-
-    def OnEnterPage(self, event):
+        #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+      
+    def OnType(self,event):
         try:
             self.sizer.Hide(self.widthLabel)
             self.sizer.Hide(self.widthTxt)
+            self.sizer.Hide(self.heightLabel)
+            self.sizer.Hide(self.heightTxt)
             self.sizer.Remove(self.widthLabel)
             self.sizer.Remove(self.widthTxt)
-            self.sizer.Layout()
-        except:
-            print "except width"
-            pass
-        try:
-            self.sizer.Hide(self.heightLabel)
-            self.sizer.Hide(self.heightTxt)
             self.sizer.Remove(self.heightLabel)
             self.sizer.Remove(self.heightTxt)
             self.sizer.Layout()
         except:
             pass
-        try:
-            self.sizer.Hide(self.distributionBox)
-            self.sizer.Remove(self.distributionBox)
-            self.sizer.Layout()
-        except:
-            pass
-
-        if self.parent.samplingareapage.samplingtype == 'moving':
+	if event.GetInt() == 0:
+	    self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                   label = _('Width size (in cells)? '))
+            self.widthTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+            self.sizer.Add(item = self.widthLabel, border=5, pos=(3, 1),
+                          flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+            self.sizer.Add(item = self.widthTxt, border=5, pos=(3, 2),
+                       flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+            self.heightLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                   label = _('Height size (in cells)? '))
+            self.heightTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+            self.sizer.Add(item = self.heightLabel, border=5, pos=(4, 1),
+                          flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+            self.sizer.Add(item = self.heightTxt, border=5, pos=(4, 2),
+                       flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+	elif event.GetInt() == 1:
             self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
-                                   label = _('Width size (in cells)?)'))
+                                   label = _('What radius size (in meters)? '))
             self.widthTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
-            wx.CallAfter(self.widthLabel.SetFocus)
-            self.sizer.Add(item = self.widthLabel, border=5, pos=(2, 1),
+            self.sizer.Add(item = self.widthLabel, border=5, pos=(3, 1),
                           flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-            self.sizer.Add(item = self.widthTxt, border=5, pos=(2, 2),
+            self.sizer.Add(item = self.widthTxt, border=5, pos=(3, 2),
                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
             self.heightLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
-                                   label = _('Height size (in cells)?)'))
+                                   label = _('Name of the circle mask'))
             self.heightTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
-            wx.CallAfter(self.heightTxt.SetFocus)
-            self.sizer.Add(item = self.heightLabel, border=5, pos=(3, 1),
+            self.sizer.Add(item = self.heightLabel, border=5, pos=(4, 1),
                           flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-            self.sizer.Add(item = self.heightTxt, border=5, pos=(3, 2),
+            self.sizer.Add(item = self.heightTxt, border=5, pos=(4, 2),
                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-        elif self.parent.samplingareapage.samplingtype == 'units':
-            self.distributionBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
-                      label= _("Select method of sampling unit distribution"),
-                      choices=[_('Random non overlapping'),
-                      _('Systematic contiguos'), _('Stratified random'),
-                      _('Systematic non contiguos'), _('Centered over sites')],
-                      majorDimension=wx.RA_SPECIFY_COLS)
-            self.sizer.Add(item = self.distributionBox, border=5, pos=(2, 1),
-                       flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-            
 
+    def OnMethod(self,event):
+        if event.GetInt() == 0:
+                # exit a window asking "What number of sampling units to use"
+            print "Random non overlapping"
+        elif event.GetInt() == 1:
+                # no window more
+            print "Systematic contiguos"
+        elif event.GetInt() == 2:
+                # exit a window asking "Insert distance between units"
+            print "Stratified random"
+        elif event.GetInt() == 3:
+                # exit a window asking "Insert number of row strates" and "Insert number of column strates"            
+            print "Systematic non contiguos"
+        elif event.GetInt() == 4:
+            print "Centered over sites"
+
+class MovingWindows(TitledPage):
+    """!Set values from keyboard for sample units"""
+
+    def __init__(self, wizard, parent):
+        TitledPage.__init__(self, wizard, _("Units"))
+
+        self.parent = parent
+        self.sizer.AddGrowableCol(2)
+        self.sizew = ''
+        self.sizeh = ''
+        # type of shape
+        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)
+        self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+
+        self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                   label = _('Width size (in cells) ?'))
+        self.widthTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+        wx.CallAfter(self.widthLabel.SetFocus)
+        self.sizer.Add(item = self.widthLabel, border=5, pos=(2, 1),
+                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+        self.sizer.Add(item = self.widthTxt, border=5, pos=(2, 2),
+                    flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+        self.heightLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                label = _('Height size (in cells) ?'))
+        self.heightTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+        wx.CallAfter(self.heightTxt.SetFocus)
+        self.sizer.Add(item = self.heightLabel, border=5, pos=(3, 1),
+                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+        self.sizer.Add(item = self.heightTxt, border=5, pos=(3, 2),
+                    flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)        
+        
+    def OnEnterPage(self,event):
+        try:
+            self.sizer.Hide(self.widthLabel)
+            self.sizer.Hide(self.widthTxt)
+            self.sizer.Hide(self.heightLabel)
+            self.sizer.Hide(self.heightTxt)
+            self.sizer.Remove(self.widthLabel)
+            self.sizer.Remove(self.widthTxt)
+            self.sizer.Remove(self.heightLabel)
+            self.sizer.Remove(self.heightTxt)
+            self.sizer.Layout()
+        except:
+            pass   
+                    
+
     def OnType(self,event):
         try:
             self.sizer.Hide(self.widthLabel)
@@ -776,8 +869,8 @@
             self.sizer.Layout()
         except:
             pass
-	if event.GetInt() == 0:
-	    self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+        if event.GetInt() == 0:
+            self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
                                    label = _('Width size (in cells)?)'))
             self.widthTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
             wx.CallAfter(self.widthLabel.SetFocus)
@@ -793,7 +886,7 @@
                           flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
             self.sizer.Add(item = self.heightTxt, border=5, pos=(3, 2),
                        flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-	elif event.GetInt() == 1:
+        elif event.GetInt() == 1:
             self.widthLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
                                    label = _('What radius size (in meters)?)'))
             self.widthTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
@@ -809,24 +902,8 @@
             self.sizer.Add(item = self.heightLabel, border=5, pos=(3, 1),
                           flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
             self.sizer.Add(item = self.heightTxt, border=5, pos=(3, 2),
-                       flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-
-    def OnMethod(self,event):
-        if event.GetInt() == 0:
-                # exit a window asking "What number of sampling units to use"
-            print "Random non overlapping"
-        elif event.GetInt() == 1:
-                # no window more
-            print "Systematic contiguos"
-        elif event.GetInt() == 2:
-                # exit a window asking "Insert distance between units"
-            print "Stratified random"
-        elif event.GetInt() == 3:
-                # exit a window asking "Insert number of row strates" and "Insert number of column strates"            
-            print "Systematic non contiguos"
-        elif event.GetInt() == 4:
-            print "Centered over sites"
-
+                       flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)     
+            
 class SummaryPage(TitledPage):
     """!Shows summary result of choosing data"""
     
@@ -868,7 +945,6 @@
                         flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)  
 
 	self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
-	self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
 	#sampling area
 	self.samplinglabel = wx.StaticText(parent = self, id = wx.ID_ANY,
 					  label = _('Sampling area type:'))
@@ -929,14 +1005,8 @@
                     % (self.parent.keyboardpage.col_up, self.parent.keyboardpage.row_up,
                     self.parent.keyboardpage.col_len, self.parent.keyboardpage.row_len)
             self.regionkeytxt.SetLabel(regKeyVals)
+        
 
-    def OnExitPage(self, event):
-        """Write the output configuration file"""
-        outputFile = open(os.path.join(self.parent.rlipath,
-                      self.parent.startpage.conf_name),"w")
-        outputFile.write(self.parent.startpage.rast)
-        outputFile.close()
-
 if __name__ == "__main__":
     import gettext
     gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)



More information about the grass-commit mailing list