[GRASS-SVN] r53309 - sandbox/lucadelu
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 3 08:44:09 PDT 2012
Author: lucadelu
Date: 2012-10-03 08:44:08 -0700 (Wed, 03 Oct 2012)
New Revision: 53309
Modified:
sandbox/lucadelu/r.li.setup.py
Log:
big improvement in r.li.setup, thanks to anna kratochvilova
Modified: sandbox/lucadelu/r.li.setup.py
===================================================================
--- sandbox/lucadelu/r.li.setup.py 2012-10-03 14:22:32 UTC (rev 53308)
+++ sandbox/lucadelu/r.li.setup.py 2012-10-03 15:44:08 UTC (rev 53309)
@@ -4,10 +4,11 @@
@brief GUI per r.li.setup module
Classes:
- - RLiSetupFrame (first frame to show existing conf file and choose some operation)
+ - 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)
+ sampling region)
- Keybord (page to insert region areas from keybord)
- SamplingAreas (define sampling area)
- SummaryPage (show choosen options)
@@ -25,15 +26,12 @@
sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython'))
import wx
-import wx.lib.mixins.listctrl as listmix
import wx.wizard as wiz
import wx.lib.scrolledpanel as scrolled
-import time
from core import globalvar
from gui_core import gselect
from core import gcmd
-from core import utils
from location_wizard.wizard import TitledPage as TitledPage
from grass.script import core as grass
from grass.script import raster as grast
@@ -42,55 +40,65 @@
## r.li.windows.tcl:
#exec echo "SAMPLINGFRAME $per_x|$per_y|$per_rl|$per_cl" >> $env(TMP).set
+
def checkValue(value):
if value == '':
wx.FindWindowById(wx.ID_FORWARD).Enable(False)
else:
wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
def retRLiPath():
major_version = int(grass.version()['version'].split('.', 1)[0])
- rlipath = os.path.join(os.environ['HOME'], '.grass%d' % major_version, 'r.li')
+ rlipath = os.path.join(os.environ['HOME'], '.grass%d' % major_version,
+ 'r.li')
if os.path.exists(rlipath):
return rlipath
else:
os.mkdir(rlipath)
return rlipath
+
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
+
+ def __init__(self, parent, id=wx.ID_ANY, title=_("r.li.setup"),
+ style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER, **kwargs):
+ ###VARIABLES
self.parent = parent
self.cmd = "r.li.setup"
self.rlipath = retRLiPath()
self.listfiles = self.ListFiles()
###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)
+ 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)
+ 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_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 = wx.Button(parent=self.panel, id=wx.ID_ANY,
+ label=_("Create"))
self.btn_new.SetToolTipString(_('Create a new configuration file'))
- self.btn_rename = wx.Button(parent = self.panel, id = wx.ID_ANY, label = _("Rename"))
- self.btn_rename.SetToolTipString(_('Renane a configuration file'))
+ self.btn_rename = wx.Button(parent=self.panel, id=wx.ID_ANY,
+ label=_("Rename"))
+ self.btn_rename.SetToolTipString(_('Rename a 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.btn_new.Bind(wx.EVT_BUTTON, self.OnNew)
self.btn_rename.Bind(wx.EVT_BUTTON, self.OnRename)
self._layout()
###END BUTTONS
@@ -104,24 +112,24 @@
def _layout(self):
"""Set the layout"""
sizer = wx.BoxSizer(wx.VERTICAL)
- ###CONFILES
+ ###CONFILES
confilesSizer = wx.StaticBoxSizer(self.confilesBox, wx.HORIZONTAL)
- confilesSizer.Add(item = self.listfileBox, proportion = 1,
- flag = wx.EXPAND)
+ confilesSizer.Add(item=self.listfileBox, proportion=1,
+ flag=wx.EXPAND)
###END CONFILES
- ###BUTTONS
+ ###BUTTONS
buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
- buttonSizer.Add(item = self.btn_new, flag = wx.ALL, border = 5)
- buttonSizer.Add(item = self.btn_rename, 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
+ buttonSizer.Add(item=self.btn_new, flag=wx.ALL, border=5)
+ buttonSizer.Add(item=self.btn_rename, 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)
+ 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)
@@ -135,23 +143,23 @@
#return all the configuration files in self.rlipath, check if there are
#link or directory and doesn't add them
for l in os.listdir(self.rlipath):
- if os.path.isfile(os.path.join(self.rlipath,l)):
- listfiles.append(l)
+ if os.path.isfile(os.path.join(self.rlipath, l)):
+ listfiles.append(l)
return listfiles
- def OnClose(self,event):
+ 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)
+ 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))
+ grass.try_remove(os.path.join(self.rlipath, confile))
return
def OnNew(self, event):
@@ -166,35 +174,39 @@
try:
confile = self.listfiles[self.listfileBox.GetSelections()[0]]
except:
- gcmd.GMessage(parent = self,
- message = _("You have to select a configuration file"))
+ gcmd.GMessage(parent=self,
+ message=_("You have to select a configuration file"))
return
- dlg = wx.TextEntryDialog(parent = self.parent,
- message = _('Set te new name for %s configuration file') % confile,
- caption = _('Rename configuration file'))
+ dlg = wx.TextEntryDialog(parent=self.parent,
+ message=_('Set te new name for %s " \
+ "configuration file') % confile,
+ caption=_('Rename configuration file'))
if dlg.ShowModal() == wx.ID_OK:
res = dlg.GetValue()
newname = "%s%s%s" % (self.rlipath, os.sep, res)
- os.rename(os.path.join(self.rlipath,confile), newname)
+ os.rename(os.path.join(self.rlipath, confile), newname)
self.listfiles = self.ListFiles()
self.listfileBox.Clear()
- self.listfileBox.Set(self.listfiles)
+ self.listfileBox.Set(self.listfiles)
+
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"))
+ self.parent = parent ## GMFrame
+ self.wizard = wiz.Wizard(parent=parent, id=wx.ID_ANY,
+ title=_("Create new configuration file for " \
+ "r.li modules"))
self.rlipath = retRLiPath()
#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)
- self.samplingunits = SampleUnitsKeyPage(self.wizard, self)
+ self.units = SampleUnitsKeyPage(self.wizard, self)
self.moving = MovingWindows(self.wizard, self)
#order of pages
@@ -203,47 +215,47 @@
self.keyboardpage.SetNext(self.samplingareapage)
self.samplingareapage.SetPrev(self.startpage)
self.samplingareapage.SetNext(self.summarypage)
- self.samplingunits.SetPrev(self.samplingareapage)
- self.samplingunits.SetNext(self.summarypage)
+ self.units.SetPrev(self.samplingareapage)
+ self.units.SetNext(self.summarypage)
self.moving.SetPrev(self.samplingareapage)
self.moving.SetNext(self.summarypage)
self.summarypage.SetPrev(self.samplingareapage)
- #layout
+ #layout
self.startpage.DoLayout()
self.keyboardpage.DoLayout()
self.samplingareapage.DoLayout()
self.summarypage.DoLayout()
- self.samplingunits.DoLayout()
+ self.units.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)
+ 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()
+ dlg.Destroy()
else:
self._write_confile()
self._cleanup()
dlg.Destroy()
-
else:
self.wizard.Destroy()
- gcmd.GMessage(parent = self.parent,
- message = _("r.li.setup wizard canceled. "
- "Configuration file not created."))
+ gcmd.GMessage(parent=self.parent,
+ message=_("r.li.setup wizard canceled. "
+ "Configuration file not created."))
self._cleanup()
def _write_confile(self):
"""Write the configuration file"""
- f = open(os.path.join(self.rlipath,self.startpage.conf_name),'w')
+ f = open(os.path.join(self.rlipath, self.startpage.conf_name), 'w')
+ self.rasterinfo = grast.raster_info(self.startpage.rast)
self._write_region(f)
self._write_area(f)
f.close()
@@ -253,42 +265,109 @@
grass.use_temp_region()
# Temporarily aligning region resolution to $RASTER resolution
# keep boundary settings
- grass.run_command('g.region', rast = self.startpage.rast)
+ grass.run_command('g.region', rast=self.startpage.rast)
self.gregion = grass.region()
+ self.SF_NSRES = self.gregion['nsres']
+ self.SF_EWRES = self.gregion['ewres']
- def _write_region(self,fil):
+ def _write_region(self, fil):
"""Write the region"""
- self.rasterinfo = grast.raster_info(self.startpage.rast)
if self.startpage.region == 'whole':
fil.write("SAMPLINGFRAME 0|0|1|1\n")
self._temp_region()
self.SF_X = 0.0
self.SF_Y = 0.0
- self.SF_RL = abs(int(float(self.gregion['s']-self.gregion['n']) / float(self.gregion['nsres'])))
- self.SF_CL = abs(int(float(self.gregion['e']-self.gregion['w']) / float(self.gregion['ewres'])))
+ self.SF_RL = abs(int(float(self.gregion['s'] - self.gregion['n'])
+ / float(self.gregion['nsres'])))
+ self.SF_CL = abs(int(float(self.gregion['e'] - self.gregion['w'])
+ / float(self.gregion['ewres'])))
+ self.SF_N = self.gregion['n']
+ self.SF_S = self.gregion['s']
+ self.SF_E = self.gregion['e']
+ self.SF_W = self.gregion['w']
elif self.startpage.region == 'key':
self._temp_region()
self.SF_X = self.keyboardpage.col_up
self.SF_Y = self.keyboardpage.row_up
self.SF_RL = self.keyboardpage.row_len
- self.SF_CL = self.keyboardpage.col_len
+ self.SF_CL = self.keyboardpage.col_len
+ self.SF_N = self.gregion['n'] - (self.SF_NSRES * self.SF_Y)
+ self.SF_S = self.gregion['n'] - (self.SF_NSRES * self.SF_Y + self.SF_RL)
+ self.SF_W = self.gregion['w'] + (self.SF_EWRES * self.SF_X)
+ self.SF_E = self.gregion['w'] + (self.SF_EWRES * self.SF_X + self.SF_CL)
per_x = float(self.SF_X) / float(self.rasterinfo['cols'])
per_y = float(self.SF_Y) / float(self.rasterinfo['rows'])
per_rl = float(self.SF_RL) / float(self.rasterinfo['cols'])
per_cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
- fil.write("SAMPLINGFRAME %f|%f|%f|%f\n" % (per_x,per_y,per_rl,per_cl))
+ fil.write("SAMPLINGFRAME %s|%s|%s|%s\n" % (str(per_x), str(per_y),
+ str(per_rl), str(per_cl)))
- def _write_area(self,fil):
+ def _circle(self, radius, mask):
+ """create a circle mask"""
+ self.CIR_RL = round((2 * radius) / self.rasterinfo['ewres'])
+ self.CIR_CL = round((2 * radius) / self.rasterinfo['nsres'])
+ if not self.CIR_RL % 2:
+ self.CIR_RL += 1
+ if not self.CIR_CL % 2:
+ self.CIR_CL += 1
+ eastEdge = float(self.SF_W + (self.CIR_RL * self.SF_EWRES))
+ southEdge = float(self.SF_N - (self.CIR_CL * self.SF_NSRES))
+ grass.del_temp_region()
+ grass.use_temp_region()
+ grass.run_command('g.region', n=self.SF_N, s=southEdge, e=eastEdge,
+ w=self.SF_W)
+ xcenter = grass.region(complete=True)['center_easting']
+ ycenter = grass.region(complete=True)['center_northing']
+ grass.run_command('r.circle', flags='b', out=mask, max=radius,
+ coordinate=[xcenter, ycenter])
+ grass.del_temp_region()
+ grass.use_temp_region()
+ grass.run_command('g.region', rast=self.startpage.rast)
+
+ def _write_area(self, fil):
"""Write the region"""
if self.samplingareapage.samplingtype == 'whole':
x = float(self.SF_X) / float(self.rasterinfo['cols'])
- cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
+ cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
y = float(self.SF_Y) / float(self.rasterinfo['rows'])
rl = float(self.SF_RL) / float(self.rasterinfo['rows'])
if self.startpage.region == 'whole':
- fil.write("SAMPLEAREA %.1f|%.1f|%.1f|%.1f\n" % (x,y,rl,cl))
+ fil.write("SAMPLEAREA %s|%s|%s|%s\n" % (str(per_x), str(per_y),
+ str(rl), str(cl)))
elif self.startpage.region == 'key':
- fil.write("SAMPLEAREA %f|%f|%f|%f\n" % (x,y,rl,cl))
+ fil.write("SAMPLEAREA %s|%s|%s|%s\n" % (str(per_x), str(per_y),
+ str(rl), str(cl)))
+ elif self.samplingareapage.samplingtype == 'moving':
+ if self.moving.boxtype == 'circle':
+ self._circle(self.moving.width, self.moving.height)
+ cl = float(self.CIR_CL) / float(self.rasterinfo['cols'])
+ rl = float(self.CIR_RL) / float(self.rasterinfo['rows'])
+ else:
+ cl = float(self.moving.width) / float(self.rasterinfo['cols'])
+ rl = float(self.moving.height) / float(self.rasterinfo['rows'])
+ fil.write("SAMPLEAREA -1|-1|%s|%s" % (str(rl), str(cl)))
+ if self.moving.boxtype == 'circle':
+ fil.write("|%s" % self.moving.height)
+ fil.write("\nMOVINGWINDOW\n")
+ elif self.samplingareapage.samplingtype == 'units':
+ if self.units.boxtype == 'circle':
+ self._circle(self.units.width, self.units.height)
+ cl = float(self.CIR_CL) / float(self.rasterinfo['cols'])
+ rl = float(self.CIR_RL) / float(self.rasterinfo['rows'])
+ else:
+ cl = float(self.units.width) / float(self.rasterinfo['cols'])
+ rl = float(self.units.height) / float(self.rasterinfo['rows'])
+ fil.write("SAMPLEAREA -1|-1|%s|%s\n" % (str(rl), str(cl)))
+ if self.units.distrtype == 'non_overlapping':
+ fil.write("RANDOMNONOVERLAPPING %s\n" % str(NUMERO))
+ elif self.units.distrtype == 'systematic_contiguos':
+ fil.write("SYSTEMATICCONTIGUOUS\n")
+ elif self.units.distrtype == 'stratified_random':
+ fil.write("STRATIFIEDRANDOM %s|%s" % (str(NUMERO), str(NUMERO)))
+ elif self.units.distrtype == 'systematic_noncontiguos':
+ fil.write("SYSTEMATICNONCONTIGUOUS %s\n" % str(NUMERO))
+ elif self.units.distrtype == 'centered_oversites':
+ fil.write("")
def _cleanup(self):
"""Clean all the variables to save into configuration file"""
@@ -301,9 +380,14 @@
self.keyboardpage.row_len = ''
self.keyboardpage.row_up = ''
self.samplingareapage.samplingtype = 'whole'
- self.samplingunits.sizew = ''
- self.samplingunits.sizeh = ''
+ self.units.width = ''
+ self.units.height = ''
+ self.units.boxtype = ''
+ self.moving.width = ''
+ self.moving.height = ''
+ self.moving.boxtype = ''
+
class FirstPage(TitledPage):
"""
Set name of configuration file, choose raster and optionally vector/sites
@@ -315,62 +399,72 @@
self.region = 'whole'
self.rast = ''
self.conf_name = ''
- self.vect = ''
- wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ self.vect = ''
self.parent = parent
- 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.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))
+ 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),
+ self.sizer.Add(item=self.newconflabel, border=5, pos=(0, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.newconftxt, border=5, pos=(1, 2),
+ self.sizer.Add(item=self.newconftxt, border=5, pos=(0, 1),
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),
+ 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=(1, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.mapselect, border=5, pos=(2, 2),
+ self.sizer.Add(item=self.mapselect, border=5, pos=(1, 1),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
#vector
- self.vectsellabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- 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),
+ self.vectsellabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ 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.vectsellabel.Enable(False)
+ self.vectselect.Enable(False)
+ self.sizer.Add(item=self.vectsellabel, border=5, pos=(2, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.vectselect, border=5, pos=(3, 2),
+ self.sizer.Add(item=self.vectselect, border=5, pos=(2, 1),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
#define sampling region
self.sampling_reg = wx.RadioBox(parent=self, id=wx.ID_ANY,
- label= _("Define sampling region (region for analysis)"),
- choices=[_('Whole map layer'),
- _('Keyboard setting'), _('Draw the sampling frame')],
- majorDimension=wx.RA_SPECIFY_COLS)
+ label=" %s " % _("Define sampling " \
+ " region(region for analysis)"),
+ choices=[_('Whole map layer'),
+ _('Keyboard setting'),
+ _('Draw the sampling frame')],
+ majorDimension=1,
+ style=wx.RA_SPECIFY_ROWS)
+
+ self.sampling_reg.EnableItem(2, False) # disable 'draw' for now
+ self.sampling_reg.SetItemToolTip(2, _("This option is not supported yet"))
self.sizer.Add(item=self.sampling_reg,
flag=wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, border=5,
- pos=(5, 1), span=(5, 2))
+ pos=(4, 0), span=(1, 2))
#bindings
self.sampling_reg.Bind(wx.EVT_RADIOBOX, self.OnSampling)
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_CHANGED, self.OnEnterPage)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
- wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ wx.CallAfter(wx.FindWindowById(wx.ID_FORWARD).Enable, False)
+ # wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ # self.OnName(None)
- def OnSampling(self,event):
+ def OnSampling(self, event):
"""!Change map type"""
if event.GetInt() == 0:
self.region = 'whole'
@@ -378,51 +472,41 @@
elif event.GetInt() == 1:
self.region = 'key'
self.SetNext(self.parent.keyboardpage)
- elif event.GetInt() == 2:
- self.region = 'draw'
- #to remove when I know how to connect or create a monitor
- gcmd.GMessage(parent = self,
- message = _("Function not supported yet"))
- return
- 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)
+ elif event.GetInt() == 2: # currently disabled
+ self.region = 'draw'
- 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 " % self.conf_name \
- + "already exists, please change name"))
+ def OnName(self, event):
+ """!Sets the name of configuration file"""
+ self.conf_name = self.newconftxt.GetValue()
+ if self.conf_name in self.parent.parent.listfiles:
+ gcmd.GMessage(parent=self,
+ message=_("The configuration file %s "
+ "already exists, please change name") % self.conf_name)
self.newconftxt.SetValue('')
- 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)
- else:
- wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ self.conf_name = ''
+ next = wx.FindWindowById(wx.ID_FORWARD)
+ next.Enable(self.CheckInput())
def OnRast(self, event):
"""!Sets raster map"""
self.rast = event.GetString()
- 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)
+ next = wx.FindWindowById(wx.ID_FORWARD)
+ next.Enable(self.CheckInput())
def OnVector(self, event):
"""!Sets vector map"""
self.vect = event.GetString()
- 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)
+ next = wx.FindWindowById(wx.ID_FORWARD)
+ next.Enable(self.CheckInput())
+ def CheckInput(self):
+ """!Check input fields.
+
+ @return True if configuration file is given and raster xor vector map,
+ False otherwise
+ """
+ return bool(self.conf_name and (bool(self.rast) != bool(self.vect)))
+
def OnExitPage(self, event=None):
"""!Function during exiting"""
if self.region == 'draw' or self.conf_name == '' or self.rast == '':
@@ -437,11 +521,12 @@
self.SetNext(self.parent.samplingareapage)
self.parent.samplingareapage.SetPrev(self)
elif self.region == 'draw':
- gcmd.GMessage(parent = self,
- message = _("Function not supported yet"))
+ 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
@@ -456,58 +541,60 @@
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'))
+ 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))
+ 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),
+
+ 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),
+ 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.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))
+ 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)
-
+
+ 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.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))
+ 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),
+
+ 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),
+ 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.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))
+ 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),
+
+ 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.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.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)
@@ -515,26 +602,26 @@
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
- def OnColLeft(self,event):
+ def OnColLeft(self, event):
"""!Sets the name of configuration file"""
self.col_up = self.ColUpLefttxt.GetValue()
checkValue(self.col_up)
- def OnRowLeft(self,event):
+ def OnRowLeft(self, event):
"""!Sets the name of configuration file"""
self.row_up = self.RowUpLefttxt.GetValue()
checkValue(self.row_up)
- def OnColLen(self,event):
+ def OnColLen(self, event):
"""!Sets the name of configuration file"""
self.col_len = self.ColLentxt.GetValue()
checkValue(self.col_len)
- def OnRowLen(self,event):
+ def OnRowLen(self, event):
"""!Sets the name of configuration file"""
self.row_len = self.RowLentxt.GetValue()
checkValue(self.row_len)
-
+
def OnEnterPage(self, event):
"""!Sets the default values, for the entire map
"""
@@ -553,6 +640,7 @@
else:
wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
class SamplingAreasPage(TitledPage):
"""
Set name of configuration file, choose raster and optionally vector/sites
@@ -562,74 +650,77 @@
TitledPage.__init__(self, wizard, _("Insert sampling areas"))
self.samplingtype = 'whole'
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"))
+ self.radioBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
+ label="",
+ choices=[_("Whole map layer"),
+ _("Regions"),
+ _("Sample units"),
+ _("Moving window"),
+ _("Select areas from the\n"
+ "overlayed vector map")],
+ majorDimension=1,
+ style=wx.RA_SPECIFY_COLS | wx.NO_BORDER)
+ self.radioBox.EnableItem(1, False)
+ self.radioBox.SetItemToolTip(1, _("This option is not supported yet"))
# 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))
-
- wx.FindWindowById(wx.ID_FORWARD).Enable(False)
+ self.sizer.Add(item=self.radioBox, flag=wx.ALIGN_LEFT, pos=(0, 0))
+ 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=1,
+ style=wx.RA_SPECIFY_ROWS)
+ self.regionBox.EnableItem(1, False)
+ self.regionBox.SetItemToolTip(1, _("This option is not supported yet"))
+ self.sizer.Add(self.regionBox, flag=wx.ALIGN_CENTER, pos=(1, 0))
+
# 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())
+ self.radioBox.Bind(wx.EVT_RADIOBOX, self.SetVal)
+ self.regionBox.Bind(wx.EVT_RADIOBOX, self.OnRegionDraw)
+ self.regionbox = 'keybord'
+
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
def OnEnterPage(self, event):
"""!Insert values into text controls for summary of location
creation options
"""
- try:
- self.sizer.Hide(self.radio5)
- self.sizer.Remove(self.radio5)
- self.sizer.Layout()
- except:
- pass
- if self.parent.startpage.vect != '':
- 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())
-
+ self.SetVal(None)
+ if self.parent.startpage.vect:
+ self.radioBox.ShowItem(4, True)
+ else:
+ self.radioBox.ShowItem(4, False)
+ self.sizer.Layout()
+
+ wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
def SetVal(self, event):
"""!Choose method"""
- if event.GetId() == self.radio1.GetId():
- self.samplingtype = 'whole'
- self.DrawNothing()
- elif event.GetId() == self.radio2.GetId():
- self.samplingtype = 'regions'
- self.Region()
- elif event.GetId() == self.radio3.GetId():
- self.samplingtype = 'units'
- self.SetNext(self.parent.samplingunits)
- self.KeyDraw()
- elif event.GetId() == self.radio4.GetId():
- self.samplingtype = 'moving'
- self.SetNext(self.parent.moving)
- self.KeyDraw()
- elif event.GetId() == self.radio5.GetId():
- self.samplingtype = 'vector'
- self.DrawNothing()
+ radio = self.radioBox.GetSelection()
+ if radio == 0:
+ self.samplingtype = 'whole'
+ self.DrawNothing()
+ # elif event.GetInt() == 1: # disabled
+ # self.samplingtype = 'regions'
+ # self.Region()
+ elif radio == 2:
+ self.samplingtype = 'units'
+ self.SetNext(self.parent.units)
+ self.KeyDraw()
+ elif radio == 3:
+ self.samplingtype = 'moving'
+ self.SetNext(self.parent.moving)
+ self.KeyDraw()
+ elif radio == 4:
+ self.samplingtype = 'vector'
+ self.DrawNothing()
def Region(self):
- """show this only if radio2 it is selected"""
+ """show this only if radio2 it is selected"""
try:
self.sizer.Hide(self.regionBox)
self.sizer.Remove(self.regionBox)
@@ -645,54 +736,33 @@
#self.sizer.Add(self.regionBox, flag = wx.ALIGN_CENTER, pos = (6, 1))
#self.sizer.Layout()
#self.SetNext(self.parent.draw)
- gcmd.GMessage(parent = self, message = _("Function not supported yet"))
+ gcmd.GMessage(parent=self, message=_("Function not supported yet"))
return
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:
- pass
- 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.Show(self.regionBox)
self.sizer.Layout()
- self.regionbox = 'keybord'
- wx.FindWindowById(wx.ID_FORWARD).Enable(True)
- self.regionBox.Bind(wx.EVT_RADIOBOX, self.OnRegionDraw)
- def OnRegionDraw(self,event):
+ def OnRegionDraw(self, event):
"""Function called by KeyDraw to find what method is choosed"""
if event.GetInt() == 0:
self.regionbox = 'keybord'
- self.SetNext(self.parent.samplingunits)
+ self.SetNext(self.parent.units)
elif event.GetInt() == 1:
self.regionbox = 'drawmouse'
- #to remove when I know how to connect or create a monitor
- gcmd.GMessage(parent = self,
- message = _("Function not supported yet"))
return
- #self.SetNext(self.parent.draw)
- wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+ #self.SetNext(self.parent.draw)
def DrawNothing(self):
""""""
- try:
- self.sizer.Hide(self.regionBox)
- self.sizer.Remove(self.regionBox)
- self.sizer.Layout()
- except:
- pass
+ self.sizer.Hide(self.regionBox)
+ self.sizer.Layout()
+
self.SetNext(self.parent.summarypage)
- wx.FindWindowById(wx.ID_FORWARD).Enable(True)
+
class SampleUnitsKeyPage(TitledPage):
"""!Set values from keyboard for sample units"""
@@ -700,112 +770,142 @@
TitledPage.__init__(self, wizard, _("Units"))
self.parent = parent
- self.scrollPanel = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
- self.scrollPanel.SetupScrolling(scroll_x = False)
- self.sizer = wx.BoxSizer()
- self.sizer.Add(self.scrollPanel, proportion = 1, flag = wx.EXPAND)
- self.panelSizer = wx.GridBagSizer(5,5)
- self.sizew = ''
- self.sizeh = ''
+ self.scrollPanel = scrolled.ScrolledPanel(parent=self, id=wx.ID_ANY)
+ self.scrollPanel.SetupScrolling(scroll_x=False)
+
+ self.panelSizer = wx.GridBagSizer(5, 5)
+ self.width = ''
+ self.height = ''
+ self.boxtype = ''
# type of shape
self.typeBox = wx.RadioBox(parent=self.scrollPanel, id=wx.ID_ANY,
- majorDimension=1, style=wx.RA_SPECIFY_COLS,
- label= _("Select type of shape"),
- choices=[_('Rectangle'), _('Circle')])
+ majorDimension=1, style=wx.RA_SPECIFY_COLS,
+ label=" %s " % _("Select type of shape"),
+ choices=[_('Rectangle'), _('Circle')])
- self.panelSizer.Add(self.typeBox, flag = wx.ALIGN_LEFT, pos = (1, 1), span = (1, 2))
+ self.panelSizer.Add(self.typeBox, flag=wx.ALIGN_LEFT, pos=(0, 0),
+ span=(1, 2))
+
+ self.widthLabel = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY)
+ self.widthTxt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
+ size=(250, -1))
+
+ self.panelSizer.Add(item=self.widthLabel, pos=(1, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.panelSizer.Add(item=self.widthTxt, pos=(1, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ self.heightLabel = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY)
+ self.heightTxt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
+ size=(250, -1))
+
+ self.panelSizer.Add(item=self.heightLabel, pos=(2, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.panelSizer.Add(item=self.heightTxt, pos=(2, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.widthLabels = [_('Width size (in cells)? '),
+ _('What radius size (in meters)? ')]
+ self.heightLabels = [_('Height size (in cells)? '),
+ _('Name of the circle mask')]
+
self.distributionBox = wx.RadioBox(parent=self.scrollPanel, id=wx.ID_ANY,
- majorDimension=1, style=wx.RA_SPECIFY_COLS,
- label= _("Select method of sampling unit distribution"),
- choices=[_('Random non overlapping'),
- _('Systematic contiguos'), _('Stratified random'),
- _('Systematic non contiguos'), _('Centered over sites')]
- )
- self.panelSizer.Add(item = self.distributionBox, pos=(2, 1), span = (1, 2),
+ majorDimension=1, style=wx.RA_SPECIFY_COLS,
+ label= " %s " % _("Select method of sampling unit distribution"),
+ choices=[_('Random non overlapping'),
+ _('Systematic contiguos'),
+ _('Stratified random'),
+ _('Systematic non contiguos'),
+ _('Centered over sites')]
+ )
+ self.panelSizer.Add(item=self.distributionBox, pos=(3, 0), span=(1, 2),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.widthLabel = wx.StaticText(parent = self.scrollPanel, id = wx.ID_ANY,
- label = _('Width size (in cells)? '))
- self.widthTxt = wx.TextCtrl(parent = self.scrollPanel, id = wx.ID_ANY, size=(250, -1))
-
- self.panelSizer.Add(item = self.widthLabel, pos=(3, 1),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.panelSizer.Add(item = self.widthTxt, pos=(3, 2),
+ self.distr1Label = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY,
+ label=_("What number of Sampling " \
+ "Units to use?"))
+ self.distr1Txt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
+ size=(250, -1))
+ self.panelSizer.Add(item=self.distr1Label, pos=(4, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-
- self.heightLabel = wx.StaticText(parent = self.scrollPanel, id = wx.ID_ANY,
- label = _('Height size (in cells)? '))
- self.heightTxt = wx.TextCtrl(parent = self.scrollPanel, id = wx.ID_ANY, size=(250, -1))
-
- self.panelSizer.Add(item = self.heightLabel, pos=(4, 1),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.panelSizer.Add(item = self.heightTxt, pos=(4, 2),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-
+ self.panelSizer.Add(item=self.distr1Txt, pos=(4, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ self.distr2Label = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY)
+ self.distr2Txt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
+ size=(250, -1))
+ self.panelSizer.Add(item=self.distr2Label, pos=(5, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.panelSizer.Add(item=self.distr2Txt, pos=(5, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.panelSizer.Hide(self.distr2Txt)
+
self.typeBox.Bind(wx.EVT_RADIOBOX, self.OnType)
+ self.distributionBox.Bind(wx.EVT_RADIOBOX, self.OnDistr)
+ self.widthTxt.Bind(wx.EVT_TEXT, self.OnWidth)
+ self.heightTxt.Bind(wx.EVT_TEXT, self.OnHeight)
#self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+ self.sizer.Add(item=self.scrollPanel, pos=(0, 0), flag=wx.EXPAND)
+ self.sizer.AddGrowableCol(0)
+ self.sizer.AddGrowableRow(0)
self.scrollPanel.SetSizer(self.panelSizer)
- 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.Remove(self.heightLabel)
- self.sizer.Remove(self.heightTxt)
- self.sizer.Layout()
- except:
- pass
- 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 = _('What radius size (in meters)? '))
- 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 = _('Name of the circle mask'))
- 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.OnType(None)
- 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"
+ def OnType(self, event):
+ chosen = self.typeBox.GetSelection()
+ self.widthLabel.SetLabel(self.widthLabels[chosen])
+ self.heightLabel.SetLabel(self.heightLabels[chosen])
+ self.panelSizer.Layout()
+ if chosen == 0:
+ self.boxtype = 'rectangle'
+ else:
+ self.boxtype = 'circle'
+ def OnDistr(self, event):
+ chosen = self.distributionBox.GetSelection()
+ if chosen == 0:
+ self.distrtype = 'non_overlapping'
+ self.distr1Label.SetLabel(_("What number of Sampling Units to use?"))
+ self.panelSizer.Show(self.distr1Txt)
+ self.distr2Label.SetLabel("")
+ self.panelSizer.Hide(self.distr2Txt)
+ self.panelSizer.Layout()
+ elif chosen == 1:
+ self.distrtype = 'systematic_contiguos'
+ self.distr1Label.SetLabel("")
+ self.distr2Label.SetLabel("")
+ self.panelSizer.Hide(self.distr1Txt)
+ self.panelSizer.Hide(self.distr2Txt)
+ self.panelSizer.Layout()
+ elif chosen == 2:
+ self.distrtype = 'stratified_random'
+ self.distr1Label.SetLabel(_("Insert number of row strates"))
+ self.distr2Label.SetLabel(_("Insert number of column strates"))
+ self.panelSizer.Show(self.distr1Txt)
+ self.panelSizer.Show(self.distr2Txt)
+ self.panelSizer.Layout()
+ elif chosen == 3:
+ self.distrtype = 'systematic_noncontiguos'
+ self.distr1Label.SetLabel(_("Insert distance between units"))
+ self.panelSizer.Show(self.distr1Txt)
+ self.distr2Label.SetLabel("")
+ self.panelSizer.Hide(self.distr2Txt)
+ self.panelSizer.Layout()
+ elif chosen == 4:
+ self.distrtype = 'centered_oversites'
+ self.distr1Label.SetLabel("")
+ self.distr2Label.SetLabel("")
+ self.panelSizer.Hide(self.distr2Txt)
+ self.panelSizer.Hide(self.distr1Txt)
+ self.panelSizer.Layout()
+
+ def OnWidth(self, event):
+ self.width = event.GetString()
+
+ def OnHeight(self, event):
+ self.height = event.GetString()
+
+
class MovingWindows(TitledPage):
"""!Set values from keyboard for sample units"""
@@ -814,151 +914,159 @@
self.parent = parent
self.sizer.AddGrowableCol(2)
- self.sizew = ''
- self.sizeh = ''
+ self.width = ''
+ self.height = ''
+ self.boxtype = ''
# type of shape
self.typeBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
- label= _("Select type of shape"),
+ label=" %s " % _("Select type of shape"),
choices=[_('Rectangle'), _('Circle')],
- majorDimension=wx.RA_SPECIFY_COLS)
+ majorDimension=1,
+ style=wx.RA_SPECIFY_COLS)
- self.sizer.Add(self.typeBox, flag = wx.ALIGN_LEFT, pos = (1, 1))
+ 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),
+ 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=(2, 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=(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)
- self.sizer.Hide(self.widthTxt)
- self.sizer.Hide(self.heightLabel)
- self.sizer.Hide(self.heightTxt)
- self.sizer.Hide(self.distributionBox)
- self.sizer.Remove(self.widthLabel)
- self.sizer.Remove(self.widthTxt)
- self.sizer.Remove(self.heightLabel)
- self.sizer.Remove(self.heightTxt)
- self.sizer.Remove(self.distributionBox)
- self.sizer.Layout()
- except:
- pass
- 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)
- 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),
+ 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=(3, 1),
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),
+ 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:
- 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))
- 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 = _('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),
- 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)
-
+
+ self.widthLabels = [_('Width size (in cells)? '),
+ _('What radius size (in meters)? ')]
+ self.heightLabels = [_('Height size (in cells)? '),
+ _('Name of the circle mask')]
+
+ self.widthTxt.Bind(wx.EVT_TEXT, self.OnWidth)
+ self.heightTxt.Bind(wx.EVT_TEXT, self.OnHeight)
+
+ def OnEnterPage(self, event):
+ self.OnType(None)
+
+ def OnType(self, event):
+ chosen = self.typeBox.GetSelection()
+ self.widthLabel.SetLabel(self.widthLabels[chosen])
+ self.heightLabel.SetLabel(self.heightLabels[chosen])
+ self.sizer.Layout()
+ if chosen == 0:
+ self.boxtype = 'rectangle'
+ else:
+ self.boxtype = 'circle'
+
+ def OnWidth(self, event):
+ self.width = event.GetString()
+
+ def OnHeight(self, event):
+ self.height = event.GetString()
+
+
class SummaryPage(TitledPage):
"""!Shows summary result of choosing data"""
-
+
def __init__(self, wizard, parent):
TitledPage.__init__(self, wizard, _("Summary"))
global rlisettings
-
+
self.parent = parent
- self.sizer.AddGrowableCol(2)
-
+ self.sizer.AddGrowableCol(2)
+
#configuration file name
- self.conflabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _('Configuration file name:'))
- self.conftxt = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = "")
- self.sizer.Add(item = self.conflabel, border=5, pos=(1, 1),
+ self.conflabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label=_('Configuration file name:'))
+ self.conftxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.conflabel, border=5, pos=(0, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.conftxt, border=5, pos=(1, 2),
+ self.sizer.Add(item=self.conftxt, border=5, pos=(0, 1),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
#raster name
- self.rastlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _('Raster name:'))
- self.rasttxt = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = "")
- self.sizer.Add(item = self.rastlabel, border=5, pos=(2, 1),
+ self.rastlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label=_('Raster name:'))
+ self.rasttxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.rastlabel, border=5, pos=(1, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.rasttxt, border=5, pos=(1, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+
+ #vector name
+ self.vectlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label=_('Vector name:'))
+ self.vecttxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.vectlabel, border=5, pos=(2, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.rasttxt, border=5, pos=(2, 2),
+ self.sizer.Add(item=self.vecttxt, border=5, pos=(2, 1),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-
+
#region type name
- self.regionlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _('Region type:'))
- self.regiontxt = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = "")
- self.sizer.Add(item = self.regionlabel, border=5, pos=(4, 1),
+ self.regionlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label=_('Region type:'))
+ self.regiontxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.regionlabel, border=5, pos=(3, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.regiontxt, border=5, pos=(4, 2),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.regiontxt, border=5, pos=(3, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
- #sampling area
- self.samplinglabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _('Sampling area type:'))
- self.samplingtxt = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = "")
- self.sizer.Add(item = self.samplinglabel, border=5, pos=(6, 1),
+ #region keyboard
+ self.regionkeylabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.regionkeytxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.regionkeylabel, border=5, pos=(4, 0),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.samplingtxt, border=5, pos=(6, 2),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.regionkeytxt, border=5, pos=(4, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+ #sampling area
+ self.samplinglabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label=_('Sampling area type:'))
+ self.samplingtxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.samplinglabel, border=5, pos=(5, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.samplingtxt, border=5, pos=(5, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ #shapetype
+ self.shapelabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.shapetxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.shapelabel, border=5, pos=(6, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.shapetxt, border=5, pos=(6, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ #shapedim
+ self.shapewidthlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.shapewidthtxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.shapewidthlabel, border=5, pos=(7, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.shapewidthtxt, border=5, pos=(7, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.shapeheightlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.shapeheighttxt = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label="")
+ self.sizer.Add(item=self.shapeheightlabel, border=5, pos=(8, 0),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+ self.sizer.Add(item=self.shapeheighttxt, border=5, pos=(8, 1),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
def OnEnterPage(self, event):
"""!Insert values into text controls for summary of location
@@ -966,58 +1074,59 @@
"""
self.conftxt.SetLabel(self.parent.startpage.conf_name)
self.rasttxt.SetLabel(self.parent.startpage.rast)
- self.samplingtxt.SetLabel(self.parent.samplingareapage.samplingtype)
+ self.samplingtxt.SetLabel(self.parent.samplingareapage.samplingtype)
self.regiontxt.SetLabel(self.parent.startpage.region)
- try:
- #try to remove label and text of vector and region key
- self.sizer.Hide(self.vectlabel)
- self.sizer.Hide(self.vecttxt)
- self.sizer.Remove(self.vectlabel)
- self.sizer.Remove(self.vecttxt)
-
- self.sizer.Hide(self.regionkeylabel)
- self.sizer.Hide(self.regionkeytxt)
- self.sizer.Remove(self.regionkeylabel)
- self.sizer.Remove(self.regionkeytxt)
- self.sizer.Layout()
- except:
- pass
-
- if self.parent.startpage.vect != '':
- #vector name
- self.vectlabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _('Vector name:'))
- self.vecttxt = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = "")
- self.sizer.Add(item = self.vectlabel, border=5, pos=(3, 1),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.vecttxt, border=5, pos=(3, 2),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.vecttxt.SetLabel(self.parent.startpage.vect)
-
- if self.parent.startpage.region == 'key':
+ self.vecttxt.SetLabel(self.parent.startpage.vect)
+ if self.parent.startpage.region == 'key':
#region keybord values
- self.regionkeylabel = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = _('Region keybord values:'))
-
- self.regionkeytxt = wx.StaticText(parent = self, id = wx.ID_ANY,
- label = "")
- self.sizer.Add(item = self.regionkeylabel, border=5, pos=(5, 1),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- self.sizer.Add(item = self.regionkeytxt, border=5, pos=(5, 2),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
- regKeyVals = "Column left up: %s - Row left up: %s\nColumn length: %s - Row length: %s\n" \
- % (self.parent.keyboardpage.col_up, self.parent.keyboardpage.row_up,
- self.parent.keyboardpage.col_len, self.parent.keyboardpage.row_len)
+ self.regionkeylabel.SetLabel(_('Region keybord values:'))
+ regKeyVals = "Column left up: %s - Row left up: %s\n" \
+ "Column length: %s - Row length: %s\n" % (
+ self.parent.keyboardpage.col_up,
+ self.parent.keyboardpage.row_up,
+ self.parent.keyboardpage.col_len,
+ self.parent.keyboardpage.row_len)
self.regionkeytxt.SetLabel(regKeyVals)
-
+ else:
+ self.regionkeylabel.SetLabel("")
+ self.regionkeytxt.SetLabel("")
+ if self.parent.samplingareapage.samplingtype == 'units':
+ self.shapelabel.SetLabel(_('Type of shape:'))
+ self.shapetxt.SetLabel(self.parent.units.boxtype)
+ if self.parent.units.boxtype == 'circle':
+ self.shapewidthlabel.SetLabel(_("Radius size:"))
+ self.shapeheightlabel.SetLabel(_("Name circle mask:"))
+ else:
+ self.shapewidthlabel.SetLabel(_("Width size:"))
+ self.shapeheightlabel.SetLabel(_("Heigth size:"))
+ self.shapewidthtxt.SetLabel(self.parent.units.width)
+ self.shapeheighttxt.SetLabel(self.parent.units.height)
+ elif self.parent.samplingareapage.samplingtype == 'moving':
+ self.shapelabel.SetLabel(_('Type of shape:'))
+ self.shapetxt.SetLabel(self.parent.moving.boxtype)
+ if self.parent.moving.boxtype == 'circle':
+ self.shapewidthlabel.SetLabel(_("Radius size:"))
+ self.shapeheightlabel.SetLabel(_("Name circle mask:"))
+ else:
+ self.shapewidthlabel.SetLabel(_("Width size:"))
+ self.shapeheightlabel.SetLabel(_("Heigth size:"))
+ self.shapewidthtxt.SetLabel(self.parent.moving.width)
+ self.shapeheighttxt.SetLabel(self.parent.moving.height)
+ else:
+ self.shapelabel.SetLabel("")
+ self.shapetxt.SetLabel("")
+ self.shapewidthlabel.SetLabel("")
+ self.shapewidthtxt.SetLabel("")
+ self.shapeheightlabel.SetLabel("")
+ self.shapeheighttxt.SetLabel("")
+
if __name__ == "__main__":
import gettext
- gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
+ gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'),
+ unicode=True)
+
app = wx.App(0)
- frame = RLiSetupFrame(parent = None)
+ frame = RLiSetupFrame(parent=None)
frame.Show()
- app.MainLoop()
-
+ app.MainLoop()
\ No newline at end of file
More information about the grass-commit
mailing list