[GRASS-SVN] r48977 - in sandbox: . lucadelu
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 28 07:45:34 EDT 2011
Author: lucadelu
Date: 2011-10-28 04:45:34 -0700 (Fri, 28 Oct 2011)
New Revision: 48977
Added:
sandbox/lucadelu/
sandbox/lucadelu/r.li.setup.py
Log:
add r.li.setup.py
Added: sandbox/lucadelu/r.li.setup.py
===================================================================
--- sandbox/lucadelu/r.li.setup.py (rev 0)
+++ sandbox/lucadelu/r.li.setup.py 2011-10-28 11:45:34 UTC (rev 48977)
@@ -0,0 +1,608 @@
+"""
+ at package rlisetup.py
+
+ at brief GUI per r.li.setup module
+
+Classes:
+ - RLiSetupFrame (first frame to show existing conf file and choose some operation)
+ - RLIWizard (the main wizard)
+ - FirstPage (first page of wizard, choose name of conf file, raster, vector,
+ sampling region)
+ - Keybord (page to insert region areas from keybord)
+ - SamplingAreas (define sampling area)
+
+(C) 2011 by the GRASS Development Team
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Luca Delucchi <lucadeluge gmail com>
+"""
+
+import sys
+import os
+
+global rlisettings
+
+rlisettings = {'region' : 'whole', 'rast' : '', 'vect' : '',
+ 'conf_name' : '', 'vectorarea' : True, }
+
+sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython',
+ 'gui_modules'))
+
+import wx
+import wx.lib.mixins.listctrl as listmix
+import wx.wizard as wiz
+import wx.lib.scrolledpanel as scrolled
+import time
+
+import globalvar
+import gselect
+import gcmd
+import utils
+from location_wizard import TitledPage as TitledPage
+from grass.script import core as grass
+
+#@TODO create wizard instead of progressively increasing window
+
+#@NOTE: r.li.setup writes in the settings file with
+## r.li.windows.tcl:
+#exec echo "SAMPLINGFRAME $per_x|$per_y|$per_rl|$per_cl" >> $env(TMP).set
+
+class RLiSetupFrame(wx.Frame):
+ def __init__(self, parent, id = wx.ID_ANY,
+ style = wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER,
+ title = _("r.li.setup"), **kwargs):
+ ###VARIABLES
+ self.parent = parent
+ self.cmd = "r.li.setup"
+ self.major_version = int(grass.version()['version'].split('.', 1)[0])
+ self.rlipath = os.path.join(os.environ['HOME'], '.grass%d' % self.major_version, 'r.li')
+ #check if self.rlipath exists
+ self.CheckFolder()
+ #return all the configuration files in self.rlipath
+ self.listfiles = os.listdir(self.rlipath)
+ ###END VARIABLES
+ #init of frame
+ wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
+ self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
+ self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
+ #box for select configuration file
+ self.confilesBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
+ label= _('Available sampling area configuration files'))
+ self.listfileBox = wx.ListBox(parent = self.panel, id = wx.ID_ANY,
+ choices = self.listfiles)
+ ###BUTTONS
+ #definition
+ self.btn_close = wx.Button(parent = self.panel, id = wx.ID_CLOSE)
+ self.btn_help = wx.Button(parent = self.panel, id = wx.ID_HELP)
+ self.btn_remove = wx.Button(parent = self.panel, id = wx.ID_ANY, label = _("Remove"))
+ self.btn_remove.SetToolTipString(_('Remove a configuration file'))
+ self.btn_new = wx.Button(parent = self.panel, id = wx.ID_ANY, label = _("Create"))
+ self.btn_new.SetToolTipString(_('Create a new configuration file'))
+ #set action for button
+ self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose)
+ self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp)
+ self.btn_remove.Bind(wx.EVT_BUTTON, self.OnRemove)
+ self.btn_new.Bind(wx.EVT_BUTTON, self.OnNew)
+ self._layout()
+ ###END BUTTONS
+
+ ###SIZE FRAME
+ self.SetMinSize(self.GetBestSize())
+ ##Please check this because without this the size it is not the min
+ self.SetClientSize(self.GetBestSize())
+ ###END SIZE
+
+ def _layout(self):
+ """Set the layout"""
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ ###CONFILES
+ confilesSizer = wx.StaticBoxSizer(self.confilesBox, wx.HORIZONTAL)
+ confilesSizer.Add(item = self.listfileBox, proportion = 1,
+ flag = wx.EXPAND)
+ ###END CONFILES
+ ###BUTTONS
+ buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
+ buttonSizer.Add(item = self.btn_new, flag = wx.ALL, border = 5)
+ buttonSizer.Add(item = self.btn_remove, flag = wx.ALL, border = 5)
+ buttonSizer.Add(item = self.btn_help, flag = wx.ALL, border = 5)
+ buttonSizer.Add(item = self.btn_close, flag = wx.ALL, border = 5)
+ ###END BUTTONS
+ #add to sizer
+ sizer.Add(item = confilesSizer, proportion = 0,
+ flag = wx.ALIGN_LEFT | wx.EXPAND | wx.ALL, border = 3)
+ sizer.Add(item = buttonSizer, proportion = 0,
+ flag = wx.ALIGN_RIGHT | wx.ALL, border = 3)
+ #set dimension
+ self.panel.SetAutoLayout(True)
+ self.panel.SetSizer(sizer)
+ sizer.Fit(self.panel)
+ self.Layout()
+
+ def CheckFolder(self):
+ """!Check if the folder of r.li it is present in the .grass7 path"""
+ if os.path.exists(self.rlipath):
+ return
+ else:
+ os.mkdir(self.rlipath)
+ return
+
+ def ListFiles(self):
+ """!Check the configuration files inside the path"""
+ return os.listdir(self.rlipath)
+
+ def OnClose(self,event):
+ """!Close window"""
+ self.Destroy()
+
+ 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)
+
+class RLIWizard(object):
+ """
+ Start wizard here and finish wizard here
+ """
+
+ def __init__(self, parent):
+ self.parent = parent # GMFrame
+ self.wizard = wiz.Wizard(parent=parent, id=wx.ID_ANY, title=_("Create new configuration file for r.li modules"))
+
+ #pages
+ self.startpage = FirstPage(self.wizard, self)
+ self.keyboardpage = KeybordPage(self.wizard, self)
+ self.samplingareapage = SamplingAreasPage(self.wizard, self)
+ self.summarypage = SummaryPage(self.wizard, self)
+
+ #order of pages
+ self.startpage.SetNext(self.keyboardpage)
+
+ self.keyboardpage.SetPrev(self.startpage)
+ self.keyboardpage.SetNext(self.samplingareapage)
+
+ self.samplingareapage.SetPrev(self.startpage)
+ self.samplingareapage.SetNext(self.summarypage)
+
+ self.summarypage.SetPrev(self.samplingareapage)
+ #layout
+ self.startpage.DoLayout()
+ self.keyboardpage.DoLayout()
+ self.samplingareapage.DoLayout()
+ self.summarypage.DoLayout()
+
+ self.wizard.FitToPage(self.startpage)
+
+ #run_wizard
+ self.wizard.RunWizard(self.startpage)
+
+
+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.parent = parent
+ self.region = ''
+ self.rast = ''
+ self.conf_name = ''
+ self.vect = ''
+ self.vectorarea = True
+
+ self.sizer.AddGrowableCol(2)
+ #name of output configuration file
+ self.newconflabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _('Name for new configuration file to create'))
+
+ 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),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ #raster
+ self.mapsellabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _('Raster map to use to select areas'))
+ self.mapselect = gselect.Select(parent = self, id = wx.ID_ANY, size = (250, -1),
+ type = 'cell', multiple = False)
+ self.sizer.Add(item = self.mapsellabel, border=5, pos=(2, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item = self.mapselect, border=5, pos=(2, 2),
+ 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'))
+ 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),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item = self.vectselect, border=5, pos=(3, 2),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ #define sempling region
+ self.sempling_reg = wx.RadioBox(parent=self, id=wx.ID_ANY,
+ label= _("Define sempling region (region for analysis)"),
+ choices=[_('Whole map layer'),
+ _('Keyboard setting'), _('Draw the sempling frame')],
+ majorDimension=wx.RA_SPECIFY_COLS)
+ self.sizer.Add(item=self.sempling_reg,
+ flag=wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, border=5,
+ pos=(5, 1), span=(5, 2))
+ #bindings
+ self.sempling_reg.Bind(wx.EVT_RADIOBOX, self.OnSempling)
+ self.newconftxt.Bind(wx.EVT_KILL_FOCUS, self.OnName)
+ self.vectselect.Bind(wx.EVT_TEXT, self.OnVector)
+ self.mapselect.Bind(wx.EVT_TEXT, self.OnRast)
+
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnEnterPage)
+ #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+
+ wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+
+ def OnSempling(self,event):
+ """!Change map type"""
+ if event.GetInt() == 0:
+ #rlisetting['region'] = 'whole'
+ self.region = 'whole'
+ self.SetNext(self.parent.samplingareapage)
+ elif event.GetInt() == 1:
+ #rlisetting['region'] = 'key'
+ #rlisetting['vectorarea'] = False
+ self.vectorarea = False
+ self.region = 'key'
+ self.SetNext(self.parent.keyboardpage)
+ elif event.GetInt() == 2:
+ #rlisetting['region'] = 'draw'
+ #rlisetting['vectorarea'] = False
+ self.vectorarea = False
+ self.region = 'draw'
+ wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ #if rlisetting['conf_name'] != '' and rlisetting['rast'] != '' and not \
+ if self.conf_name != '' and self.rast != '' and not \
+ wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
+ def OnName(self,event):
+ """!Sets the name of configuration file"""
+ self.conf_name = self.newconftxt.GetValue()
+ #rlisetting['conf_name'] = self.newconftxt.GetValue()
+ #if rlisetting['region'] != '' and rlisetting['rast'] != '' and not \
+ if self.region != '' and self.rast != '' and not \
+ wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
+ def OnRast(self, event):
+ """!Sets raster map"""
+ self.rast = event.GetString()
+ #rlisetting['rast'] = event.GetString()
+ #if rlisetting['region'] != '' and rlisetting['conf_name'] != '' and not \
+ if self.region != '' and self.conf_name != '' and not \
+ wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
+ def OnVector(self, event):
+ """!Sets vector map"""
+ self.vect = event.GetString()
+ #rlisetting['vect'] = event.GetString()
+
+ def OnEnterPage(self, event=None):
+ #if rlisetting['region'] == '' or rlisetting['rast'] == '' or rlisetting['conf_name'] == '':
+ if self.region == '' or self.conf_name == '' or self.rast == '':
+ wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ else:
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+ if event.GetDirection():
+ if self.region == 'key':
+ #if rlisetting['region'] == 'key':
+ self.SetNext(self.parent.keyboardpage)
+ #elif rlisetting['region'] == 'whole':
+ #rlisetting['vectorarea'] = False
+ elif self.region == 'whole':
+ self.vectorarea = False
+ self.SetNext(self.parent.samplingareapage)
+ elif self.region == 'draw':
+ #elif rlisetting['region'] == 'draw':
+ #rlisetting['vectorarea'] = False
+ self.vectorarea = False
+ gcmd.GMessage(parent = self,
+ message = _("Function not supported yet"))
+ event.Veto()
+ return
+
+
+class KeybordPage(TitledPage):
+ """
+ Set name of configuration file, choose raster and optionally vector/sites
+ """
+
+ def __init__(self, wizard, parent):
+ TitledPage.__init__(self, wizard, _("Insert sempling frame parameter"))
+
+ self.parent = parent
+ self.sizer.AddGrowableCol(2)
+
+ #print rlisetting['rast']
+ self.col_up = ''
+ 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,
+ label = _('Column of upper left corner'))
+
+ self.ColUpLefttxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+ wx.CallAfter(self.ColUpLeftlabel.SetFocus)
+
+ self.sizer.Add(item = self.ColUpLeftlabel, border=5, pos=(1, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item = self.ColUpLefttxt, border=5, pos=(1, 2),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ #row up/left
+ self.RowUpLeftlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _('Row of upper left corner'))
+
+ self.RowUpLefttxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+ wx.CallAfter(self.RowUpLeftlabel.SetFocus)
+
+ self.sizer.Add(item = self.RowUpLeftlabel, border=5, pos=(2, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item = self.RowUpLefttxt, border=5, pos=(2, 2),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ #row lenght
+ self.RowLenlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _('Row lenght of sampling frame'))
+
+ self.RowLentxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+ wx.CallAfter(self.RowLenlabel.SetFocus)
+
+ self.sizer.Add(item = self.RowLenlabel, border=5, pos=(3, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item = self.RowLentxt, border=5, pos=(3, 2),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ #column lenght
+ self.ColLenlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _('Row lenght of sampling frame'))
+
+ self.ColLentxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(250, -1))
+ wx.CallAfter(self.ColLenlabel.SetFocus)
+
+ self.sizer.Add(item = self.ColLenlabel, border=5, pos=(4, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item = self.ColLentxt, border=5, pos=(4, 2),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ 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.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnEnterPage)
+
+ def OnColLeft(self,event):
+ """!Sets the name of configuration file"""
+ self.col_up = self.ColUpLefttxt.GetValue()
+ if self.row_up != '' and self.col_len != '' and self.row_len != '' \
+ and not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
+ def OnRowLeft(self,event):
+ """!Sets the name of configuration file"""
+ self.row_up = self.RowUpLefttxt.GetValue()
+ if self.col_up != '' and self.col_len != '' and self.row_len != '' \
+ and not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
+ def OnColLen(self,event):
+ """!Sets the name of configuration file"""
+ self.col_len = self.ColLentxt.GetValue()
+ if self.row_up != '' and self.col_up != '' and self.row_len != '' \
+ and not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
+ def OnRowLeft(self,event):
+ """!Sets the name of configuration file"""
+ self.row_len = self.RowLentxt.GetValue()
+ if self.row_up != '' and self.col_len != '' and self.col_up != '' \
+ 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
+ """
+
+ def __init__(self, wizard, parent):
+ TitledPage.__init__(self, wizard, _("Insert sempling areas"))
+
+ self.parent = parent
+ self.sizer.AddGrowableCol(2)
+ # toggles
+ self.radio1 = wx.RadioButton(parent = self, id = wx.ID_ANY,
+ label = _("Whole maplayer"),
+ style = wx.RB_GROUP)
+ self.radio2 = wx.RadioButton(parent = self, id = wx.ID_ANY,
+ label = _("Regions"))
+ self.radio3 = wx.RadioButton(parent = self, id = wx.ID_ANY,
+ 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)
+ self.sizer.Add(item = self.radio1, flag = wx.ALIGN_LEFT, pos = (1, 1))
+ self.sizer.Add(item = self.radio2, flag = wx.ALIGN_LEFT, pos = (2, 1))
+ 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)
+ self.regionBox = wx.StaticText(parent = self, id = wx.ID_ANY,label = _(''))
+ self.sizer.Add(item = self.regionBox, flag = wx.ALIGN_CENTER, pos = (6, 1))
+ # bindings
+ self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id = self.radio1.GetId())
+ 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)
+
+
+ def SetVal(self, event):
+ """!Choose method"""
+ if event.GetId() == self.radio1.GetId():
+ self.DrawNothing()
+ elif event.GetId() == self.radio2.GetId():
+ self.Region()
+ elif event.GetId() == self.radio3.GetId():
+ self.KeyDraw()
+ elif event.GetId() == self.radio4.GetId():
+ self.KeyDraw()
+ elif event.GetId() == self.radio5.GetId():
+ self.DrawNothing()
+
+ def Region(self):
+ #show this only if radio2 it is selected
+ self.sizer.Remove(self.regionBox)
+ self.sizer.Layout()
+ self.regionBox = wx.GridBagSizer(vgap = 1, hgap = 2)
+ self.regionLabel = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _('Enter the number of region to draw'))
+ self.regionTxt = wx.TextCtrl(parent = self, id = wx.ID_ANY, size=(50, -1))
+ self.regionBox.Add(self.regionLabel, pos = (1, 1))
+ self.regionBox.Add(self.regionLabel, pos = (1, 2))
+ self.sizer.Add(self.regionBox, flag = wx.ALIGN_CENTER, pos = (6, 1))
+ self.sizer.Layout()
+
+ def KeyDraw(self):
+ #show this only if radio3 and radio4 it is selected
+ self.sizer.Remove(self.regionBox)
+ self.sizer.Layout()
+ self.regionBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
+ label= _("Choose a method"),
+ choices=[_('Use keyboard to enter sampling area'),
+ _('Use mouse to draw sampling area')],
+ majorDimension=wx.RA_SPECIFY_COLS)
+ self.sizer.Add(self.regionBox, flag = wx.ALIGN_CENTER, pos = (6, 1))
+ self.sizer.Layout()
+
+ def DrawNothing(self):
+ self.sizer.Remove(self.regionBox)
+ self.sizer.Layout()
+ self.regionBox = wx.StaticText(parent = self, id = wx.ID_ANY,label = _(''))
+ self.sizer.Add(self.regionBox, flag = wx.ALIGN_CENTER, pos = (6, 1))
+ self.sizer.Layout()
+
+class SampleUnitsKeyPage(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.typeBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
+ label= _("Select type of shape"),
+ choices=[_('Rectangle'), _('Circle')],
+ majorDimension=wx.RA_SPECIFY_COLS)
+ 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(self.typeBox, flag = wx.ALIGN_LEFT, pos = (1, 1))
+ self.sizer.Add(self.distributionBox, flag = wx.ALIGN_LEFT, pos = (2, 1))
+
+ self.typeBox.Bind(wx.EVT_RADIOBOX, self.OnType)
+ self.distributionBox.Bind(wx.EVT_RADIOBOX, self.OnMethod)
+
+ def OnType(self):
+ if event.GetInt() == 0:
+ print "activate the textctrl for rectangle"
+ elif event.GetInt() == 1:
+ print "activate the textctrl for circle"
+
+ def OnMethod(self):
+ if event.GetInt() == 0:
+ print "Random non overlapping"
+ elif event.GetInt() == 1:
+ print "Systematic contiguos"
+ elif event.GetInt() == 2:
+ print "Stratified random"
+ elif event.GetInt() == 3:
+ print "Systematic non contiguos"
+ 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"""
+
+ def __init__(self, wizard, parent):
+ TitledPage.__init__(self, wizard, _("Summary"))
+
+ self.parent = parent
+ self.sizer.AddGrowableCol(1)
+
+
+if __name__ == "__main__":
+ import gettext
+ gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+
+ app = wx.App(0)
+ frame = RLiSetupFrame(parent = None)
+ frame.Show()
+ app.MainLoop()
+
More information about the grass-commit
mailing list