GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
location_wizard/dialogs.py
Go to the documentation of this file.
1 """!
2 @package location_wizard.dialogs
3 
4 @brief Location wizard - dialogs
5 
6 Classes:
7  - dialogs::RegionDef
8  - dialogs::TransList
9  - dialogs::SelectTransformDialog
10 
11 (C) 2007-2011 by the GRASS Development Team
12 
13 This program is free software under the GNU General Public License
14 (>=v2). Read the file COPYING that comes with GRASS for details.
15 
16 @author Michael Barton
17 @author Jachym Cepicky
18 @author Martin Landa <landa.martin gmail.com>
19 """
20 import os
21 import sys
22 
23 import wx
24 import wx.lib.scrolledpanel as scrolled
25 
26 from core import globalvar
27 from core.gcmd import RunCommand
28 from location_wizard.base import BaseClass
29 
30 from grass.script import core as grass
31 
32 class RegionDef(BaseClass, wx.Dialog):
33  """!Page for setting default region extents and resolution
34  """
35  def __init__(self, parent, id = wx.ID_ANY, size = (800, 600),
36  title = _("Set default region extent and resolution"), location = None):
37  wx.Dialog.__init__(self, parent, id, title, size = size)
38  panel = wx.Panel(self, id = wx.ID_ANY)
39 
40  self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
41 
42  self.parent = parent
43  self.location = location
44 
45  #
46  # default values
47  #
48  # 2D
49  self.north = 1.0
50  self.south = 0.0
51  self.east = 1.0
52  self.west = 0.0
53  self.nsres = 1.0
54  self.ewres = 1.0
55  # 3D
56  self.top = 1.0
57  self.bottom = 0.0
58  # self.nsres3 = 1.0
59  # self.ewres3 = 1.0
60  self.tbres = 1.0
61 
62  #
63  # inputs
64  #
65  # 2D
66  self.tnorth = self.MakeTextCtrl(text = str(self.north), size = (150, -1), parent = panel)
67  self.tsouth = self.MakeTextCtrl(str(self.south), size = (150, -1), parent = panel)
68  self.twest = self.MakeTextCtrl(str(self.west), size = (150, -1), parent = panel)
69  self.teast = self.MakeTextCtrl(str(self.east), size = (150, -1), parent = panel)
70  self.tnsres = self.MakeTextCtrl(str(self.nsres), size = (150, -1), parent = panel)
71  self.tewres = self.MakeTextCtrl(str(self.ewres), size = (150, -1), parent = panel)
72 
73  #
74  # labels
75  #
76  self.lrows = self.MakeLabel(parent = panel)
77  self.lcols = self.MakeLabel(parent = panel)
78  self.lcells = self.MakeLabel(parent = panel)
79 
80  #
81  # buttons
82  #
83  self.bset = self.MakeButton(text = _("&Set region"), id = wx.ID_OK, parent = panel)
84  self.bcancel = wx.Button(panel, id = wx.ID_CANCEL)
85  self.bset.SetDefault()
86 
87  #
88  # image
89  #
90  self.img = wx.Image(os.path.join(globalvar.ETCIMGDIR, "qgis_world.png"),
91  wx.BITMAP_TYPE_PNG).ConvertToBitmap()
92 
93  #
94  # set current working environment to PERMANENT mapset
95  # in selected location in order to set default region (WIND)
96  #
97  envval = {}
98  ret = RunCommand('g.gisenv',
99  read = True)
100  if ret:
101  for line in ret.splitlines():
102  key, val = line.split('=')
103  envval[key] = val
104  self.currlocation = envval['LOCATION_NAME'].strip("';")
105  self.currmapset = envval['MAPSET'].strip("';")
106  if self.currlocation != self.location or self.currmapset != 'PERMANENT':
107  RunCommand('g.gisenv',
108  set = 'LOCATION_NAME=%s' % self.location)
109  RunCommand('g.gisenv',
110  set = 'MAPSET=PERMANENT')
111  else:
112  dlg = wx.MessageBox(parent = self,
113  message = _('Invalid location selected.'),
114  caption = _("Error"), style = wx.ID_OK | wx.ICON_ERROR)
115  return
116 
117  #
118  # get current region settings
119  #
120  region = {}
121  ret = RunCommand('g.region',
122  read = True,
123  flags = 'gp3')
124  if ret:
125  for line in ret.splitlines():
126  key, val = line.split('=')
127  region[key] = float(val)
128  else:
129  dlg = wx.MessageBox(parent = self,
130  message = _("Invalid region"),
131  caption = _("Error"), style = wx.ID_OK | wx.ICON_ERROR)
132  dlg.ShowModal()
133  dlg.Destroy()
134  return
135 
136  #
137  # update values
138  # 2D
139  self.north = float(region['n'])
140  self.south = float(region['s'])
141  self.east = float(region['e'])
142  self.west = float(region['w'])
143  self.nsres = float(region['nsres'])
144  self.ewres = float(region['ewres'])
145  self.rows = int(region['rows'])
146  self.cols = int(region['cols'])
147  self.cells = int(region['cells'])
148  # 3D
149  self.top = float(region['t'])
150  self.bottom = float(region['b'])
151  # self.nsres3 = float(region['nsres3'])
152  # self.ewres3 = float(region['ewres3'])
153  self.tbres = float(region['tbres'])
154  self.depth = int(region['depths'])
155  self.cells3 = int(region['cells3'])
156 
157  #
158  # 3D box collapsable
159  #
160  self.infoCollapseLabelExp = _("Click here to show 3D settings")
161  self.infoCollapseLabelCol = _("Click here to hide 3D settings")
162  self.settings3D = wx.CollapsiblePane(parent = panel,
163  label = self.infoCollapseLabelExp,
164  style = wx.CP_DEFAULT_STYLE |
165  wx.CP_NO_TLW_RESIZE | wx.EXPAND)
166  self.MakeSettings3DPaneContent(self.settings3D.GetPane())
167  self.settings3D.Collapse(False) # FIXME
168  self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnSettings3DPaneChanged, self.settings3D)
169 
170  #
171  # set current region settings
172  #
173  self.tnorth.SetValue(str(self.north))
174  self.tsouth.SetValue(str(self.south))
175  self.twest.SetValue(str(self.west))
176  self.teast.SetValue(str(self.east))
177  self.tnsres.SetValue(str(self.nsres))
178  self.tewres.SetValue(str(self.ewres))
179  self.ttop.SetValue(str(self.top))
180  self.tbottom.SetValue(str(self.bottom))
181  # self.tnsres3.SetValue(str(self.nsres3))
182  # self.tewres3.SetValue(str(self.ewres3))
183  self.ttbres.SetValue(str(self.tbres))
184  self.lrows.SetLabel(_("Rows: %d") % self.rows)
185  self.lcols.SetLabel(_("Cols: %d") % self.cols)
186  self.lcells.SetLabel(_("Cells: %d") % self.cells)
187 
188  #
189  # bindings
190  #
191  self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset)
192  self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel)
193  self.tnorth.Bind(wx.EVT_TEXT, self.OnValue)
194  self.tsouth.Bind(wx.EVT_TEXT, self.OnValue)
195  self.teast.Bind(wx.EVT_TEXT, self.OnValue)
196  self.twest.Bind(wx.EVT_TEXT, self.OnValue)
197  self.tnsres.Bind(wx.EVT_TEXT, self.OnValue)
198  self.tewres.Bind(wx.EVT_TEXT, self.OnValue)
199  self.ttop.Bind(wx.EVT_TEXT, self.OnValue)
200  self.tbottom.Bind(wx.EVT_TEXT, self.OnValue)
201  # self.tnsres3.Bind(wx.EVT_TEXT, self.OnValue)
202  # self.tewres3.Bind(wx.EVT_TEXT, self.OnValue)
203  self.ttbres.Bind(wx.EVT_TEXT, self.OnValue)
204 
205  self.__DoLayout(panel)
206  self.SetMinSize(self.GetBestSize())
207  self.minWindowSize = self.GetMinSize()
208 
209  def MakeSettings3DPaneContent(self, pane):
210  """!Create 3D region settings pane"""
211  border = wx.BoxSizer(wx.VERTICAL)
212  gridSizer = wx.GridBagSizer(vgap = 0, hgap = 0)
213 
214  # inputs
215  self.ttop = wx.TextCtrl(parent = pane, id = wx.ID_ANY, value = str(self.top),
216  size = (150, -1))
217  self.tbottom = wx.TextCtrl(parent = pane, id = wx.ID_ANY, value = str(self.bottom),
218  size = (150, -1))
219  self.ttbres = wx.TextCtrl(parent = pane, id = wx.ID_ANY, value = str(self.tbres),
220  size = (150, -1))
221  # self.tnsres3 = wx.TextCtrl(parent = pane, id = wx.ID_ANY, value = str(self.nsres3),
222  # size = (150, -1))
223  # self.tewres3 = wx.TextCtrl(parent = pane, id = wx.ID_ANY, value = str(self.ewres3),
224  # size = (150, -1))
225 
226  #labels
227  self.ldepth = wx.StaticText(parent = pane, label = _("Depth: %d") % self.depth)
228  self.lcells3 = wx.StaticText(parent = pane, label = _("3D Cells: %d") % self.cells3)
229 
230  # top
231  gridSizer.Add(item = wx.StaticText(parent = pane, label = _("Top")),
232  flag = wx.ALIGN_CENTER |
233  wx.LEFT | wx.RIGHT | wx.TOP, border = 5,
234  pos = (0, 1))
235  gridSizer.Add(item = self.ttop,
236  flag = wx.ALIGN_CENTER_HORIZONTAL |
237  wx.ALL, border = 5, pos = (1, 1))
238  # bottom
239  gridSizer.Add(item = wx.StaticText(parent = pane, label = _("Bottom")),
240  flag = wx.ALIGN_CENTER |
241  wx.LEFT | wx.RIGHT | wx.TOP, border = 5,
242  pos = (0, 2))
243  gridSizer.Add(item = self.tbottom,
244  flag = wx.ALIGN_CENTER_HORIZONTAL |
245  wx.ALL, border = 5, pos = (1, 2))
246  # tbres
247  gridSizer.Add(item = wx.StaticText(parent = pane, label = _("T-B resolution")),
248  flag = wx.ALIGN_CENTER |
249  wx.LEFT | wx.RIGHT | wx.TOP, border = 5,
250  pos = (0, 3))
251  gridSizer.Add(item = self.ttbres,
252  flag = wx.ALIGN_CENTER_HORIZONTAL |
253  wx.ALL, border = 5, pos = (1, 3))
254 
255  # res
256  # gridSizer.Add(item = wx.StaticText(parent = pane, label = _("3D N-S resolution")),
257  # flag = wx.ALIGN_CENTER |
258  # wx.LEFT | wx.RIGHT | wx.TOP, border = 5,
259  # pos = (2, 1))
260  # gridSizer.Add(item = self.tnsres3,
261  # flag = wx.ALIGN_CENTER_HORIZONTAL |
262  # wx.ALL, border = 5, pos = (3, 1))
263  # gridSizer.Add(item = wx.StaticText(parent = pane, label = _("3D E-W resolution")),
264  # flag = wx.ALIGN_CENTER |
265  # wx.LEFT | wx.RIGHT | wx.TOP, border = 5,
266  # pos = (2, 3))
267  # gridSizer.Add(item = self.tewres3,
268  # flag = wx.ALIGN_CENTER_HORIZONTAL |
269  # wx.ALL, border = 5, pos = (3, 3))
270 
271  # rows/cols/cells
272  gridSizer.Add(item = self.ldepth,
273  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
274  wx.ALL, border = 5, pos = (2, 1))
275 
276  gridSizer.Add(item = self.lcells3,
277  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
278  wx.ALL, border = 5, pos = (2, 2))
279 
280  border.Add(item = gridSizer, proportion = 1,
281  flag = wx.ALL | wx.ALIGN_CENTER | wx.EXPAND, border = 5)
282 
283  pane.SetSizer(border)
284  border.Fit(pane)
285 
286  def OnSettings3DPaneChanged(self, event):
287  """!Collapse 3D settings box"""
288 
289  if self.settings3D.IsExpanded():
290  self.settings3D.SetLabel(self.infoCollapseLabelCol)
291  self.Layout()
292  self.SetSize(self.GetBestSize())
293  self.SetMinSize(self.GetSize())
294  else:
295  self.settings3D.SetLabel(self.infoCollapseLabelExp)
296  self.Layout()
297  self.SetSize(self.minWindowSize)
298  self.SetMinSize(self.minWindowSize)
299 
300  self.SendSizeEvent()
301 
302  def __DoLayout(self, panel):
303  """!Window layout"""
304  frameSizer = wx.BoxSizer(wx.VERTICAL)
305  gridSizer = wx.GridBagSizer(vgap = 0, hgap = 0)
306  settings3DSizer = wx.BoxSizer(wx.VERTICAL)
307  buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
308 
309  # north
310  gridSizer.Add(item = self.MakeLabel(text = _("North"), parent = panel),
311  flag = wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL |
312  wx.TOP | wx.LEFT | wx.RIGHT, border = 5, pos = (0, 2))
313  gridSizer.Add(item = self.tnorth,
314  flag = wx.ALIGN_CENTER_HORIZONTAL |
315  wx.ALIGN_CENTER_VERTICAL |
316  wx.ALL, border = 5, pos = (1, 2))
317  # west
318  gridSizer.Add(item = self.MakeLabel(text = _("West"), parent = panel),
319  flag = wx.ALIGN_RIGHT |
320  wx.ALIGN_CENTER_VERTICAL |
321  wx.LEFT | wx.TOP | wx.BOTTOM, border = 5, pos = (2, 0))
322  gridSizer.Add(item = self.twest,
323  flag = wx.ALIGN_RIGHT |
324  wx.ALIGN_CENTER_VERTICAL |
325  wx.ALL, border = 5, pos = (2, 1))
326 
327  gridSizer.Add(item = wx.StaticBitmap(panel, wx.ID_ANY, self.img, (-1, -1),
328  (self.img.GetWidth(), self.img.GetHeight())),
329  flag = wx.ALIGN_CENTER |
330  wx.ALIGN_CENTER_VERTICAL |
331  wx.ALL, border = 5, pos = (2, 2))
332 
333  # east
334  gridSizer.Add(item = self.teast,
335  flag = wx.ALIGN_CENTER_HORIZONTAL |
336  wx.ALIGN_CENTER_VERTICAL |
337  wx.ALL, border = 5, pos = (2, 3))
338  gridSizer.Add(item = self.MakeLabel(text = _("East"), parent = panel),
339  flag = wx.ALIGN_LEFT |
340  wx.ALIGN_CENTER_VERTICAL |
341  wx.RIGHT | wx.TOP | wx.BOTTOM, border = 5, pos = (2, 4))
342  # south
343  gridSizer.Add(item = self.tsouth,
344  flag = wx.ALIGN_CENTER_HORIZONTAL |
345  wx.ALIGN_CENTER_VERTICAL |
346  wx.ALL, border = 5, pos = (3, 2))
347  gridSizer.Add(item = self.MakeLabel(text = _("South"), parent = panel),
348  flag = wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL |
349  wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5, pos = (4, 2))
350  # ns-res
351  gridSizer.Add(item = self.MakeLabel(text = _("N-S resolution"), parent = panel),
352  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
353  wx.TOP | wx.LEFT | wx.RIGHT, border = 5, pos = (5, 1))
354  gridSizer.Add(item = self.tnsres,
355  flag = wx.ALIGN_RIGHT |
356  wx.ALIGN_CENTER_VERTICAL |
357  wx.ALL, border = 5, pos = (6, 1))
358  # ew-res
359  gridSizer.Add(item = self.MakeLabel(text = _("E-W resolution"), parent = panel),
360  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
361  wx.TOP | wx.LEFT | wx.RIGHT, border = 5, pos = (5, 3))
362  gridSizer.Add(item = self.tewres,
363  flag = wx.ALIGN_RIGHT |
364  wx.ALIGN_CENTER_VERTICAL |
365  wx.ALL, border = 5, pos = (6, 3))
366  # rows/cols/cells
367  gridSizer.Add(item = self.lrows,
368  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
369  wx.ALL, border = 5, pos = (7, 1))
370 
371  gridSizer.Add(item = self.lcells,
372  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
373  wx.ALL, border = 5, pos = (7, 2))
374 
375  gridSizer.Add(item = self.lcols,
376  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER |
377  wx.ALL, border = 5, pos = (7, 3))
378 
379  # 3D
380  settings3DSizer.Add(item = self.settings3D,
381  flag = wx.ALL,
382  border = 5)
383 
384  # buttons
385  buttonSizer.Add(item = self.bcancel, proportion = 1,
386  flag = wx.ALIGN_RIGHT |
387  wx.ALIGN_CENTER_VERTICAL |
388  wx.ALL, border = 10)
389  buttonSizer.Add(item = self.bset, proportion = 1,
390  flag = wx.ALIGN_CENTER |
391  wx.ALIGN_CENTER_VERTICAL |
392  wx.ALL, border = 10)
393 
394  frameSizer.Add(item = gridSizer, proportion = 1,
395  flag = wx.ALL | wx.ALIGN_CENTER, border = 5)
396  frameSizer.Add(item = settings3DSizer, proportion = 0,
397  flag = wx.ALL | wx.ALIGN_CENTER, border = 5)
398  frameSizer.Add(item = buttonSizer, proportion = 0,
399  flag = wx.ALL | wx.ALIGN_RIGHT, border = 5)
400 
401  self.SetAutoLayout(True)
402  panel.SetSizer(frameSizer)
403  frameSizer.Fit(panel)
404  self.Layout()
405 
406  def OnValue(self, event):
407  """!Set given value"""
408  try:
409  if event.GetId() == self.tnorth.GetId():
410  self.north = float(event.GetString())
411  elif event.GetId() == self.tsouth.GetId():
412  self.south = float(event.GetString())
413  elif event.GetId() == self.teast.GetId():
414  self.east = float(event.GetString())
415  elif event.GetId() == self.twest.GetId():
416  self.west = float(event.GetString())
417  elif event.GetId() == self.tnsres.GetId():
418  self.nsres = float(event.GetString())
419  elif event.GetId() == self.tewres.GetId():
420  self.ewres = float(event.GetString())
421  elif event.GetId() == self.ttop.GetId():
422  self.top = float(event.GetString())
423  elif event.GetId() == self.tbottom.GetId():
424  self.bottom = float(event.GetString())
425  # elif event.GetId() == self.tnsres3.GetId():
426  # self.nsres3 = float(event.GetString())
427  # elif event.GetId() == self.tewres3.GetId():
428  # self.ewres3 = float(event.GetString())
429  elif event.GetId() == self.ttbres.GetId():
430  self.tbres = float(event.GetString())
431 
432  self.__UpdateInfo()
433 
434  except ValueError, e:
435  if len(event.GetString()) > 0 and event.GetString() != '-':
436  dlg = wx.MessageBox(parent = self,
437  message = _("Invalid value: %s") % e,
438  caption = _("Error"),
439  style = wx.OK | wx.ICON_ERROR)
440  # reset values
441  self.tnorth.SetValue(str(self.north))
442  self.tsouth.SetValue(str(self.south))
443  self.teast.SetValue(str(self.east))
444  self.twest.SetValue(str(self.west))
445  self.tnsres.SetValue(str(self.nsres))
446  self.tewres.SetValue(str(self.ewres))
447  self.ttop.SetValue(str(self.top))
448  self.tbottom.SetValue(str(self.bottom))
449  self.ttbres.SetValue(str(self.tbres))
450  # self.tnsres3.SetValue(str(self.nsres3))
451  # self.tewres3.SetValue(str(self.ewres3))
452 
453  event.Skip()
454 
455  def __UpdateInfo(self):
456  """!Update number of rows/cols/cells"""
457  self.rows = int((self.north - self.south) / self.nsres)
458  self.cols = int((self.east - self.west) / self.ewres)
459  self.cells = self.rows * self.cols
460 
461  self.depth = int((self.top - self.bottom) / self.tbres)
462  self.cells3 = self.rows * self.cols * self.depth
463 
464  # 2D
465  self.lrows.SetLabel(_("Rows: %d") % self.rows)
466  self.lcols.SetLabel(_("Cols: %d") % self.cols)
467  self.lcells.SetLabel(_("Cells: %d") % self.cells)
468  # 3D
469  self.ldepth.SetLabel(_("Depth: %d" % self.depth))
470  self.lcells3.SetLabel(_("3D Cells: %d" % self.cells3))
471 
472  def OnSetButton(self, event = None):
473  """!Set default region"""
474  ret = RunCommand('g.region',
475  flags = 'sgpa',
476  n = self.north,
477  s = self.south,
478  e = self.east,
479  w = self.west,
480  nsres = self.nsres,
481  ewres = self.ewres,
482  t = self.top,
483  b = self.bottom,
484  tbres = self.tbres)
485  if ret == 0:
486  self.Destroy()
487 
488  def OnCancel(self, event):
489  self.Destroy()
490 
491 class TransList(wx.VListBox):
492  """!Creates a multiline listbox for selecting datum transforms"""
493 
494  def OnDrawItem(self, dc, rect, n):
495  if self.GetSelection() == n:
496  c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT)
497  else:
498  c = self.GetForegroundColour()
499  dc.SetFont(self.GetFont())
500  dc.SetTextForeground(c)
501  dc.DrawLabel(self._getItemText(n), rect,
502  wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
503 
504  def OnMeasureItem(self, n):
505  height = 0
506  if self._getItemText(n) == None:
507  return
508  for line in self._getItemText(n).splitlines():
509  w, h = self.GetTextExtent(line)
510  height += h
511  return height + 5
512 
513  def _getItemText(self, item):
514  global transformlist
515  transitem = transformlist[item]
516  if transitem.strip() !='':
517  return transitem
518 
519 class SelectTransformDialog(wx.Dialog):
520  """!Dialog for selecting datum transformations"""
521  def __init__(self, parent, transforms, title = _("Select datum transformation"),
522  pos = wx.DefaultPosition, size = wx.DefaultSize,
523  style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
524 
525  wx.Dialog.__init__(self, parent, wx.ID_ANY, title, pos, size, style)
526 
527  global transformlist
528  self.CentreOnParent()
529 
530  # default transform number
531  self.transnum = 0
532 
533  panel = scrolled.ScrolledPanel(self, wx.ID_ANY)
534  sizer = wx.BoxSizer(wx.VERTICAL)
535 
536  #
537  # set panel sizer
538  #
539  panel.SetSizer(sizer)
540  panel.SetupScrolling()
541 
542  #
543  # dialog body
544  #
545  bodyBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
546  label = " %s " % _("Select from list of datum transformations"))
547  bodySizer = wx.StaticBoxSizer(bodyBox)
548 
549  # add no transform option
550  transforms = '---\n\n0\nDo not apply any datum transformations\n\n' + transforms
551 
552  transformlist = transforms.split('---')
553  tlistlen = len(transformlist)
554 
555  # calculate size for transform list
556  height = 0
557  width = 0
558  for line in transforms.splitlines():
559  w, h = self.GetTextExtent(line)
560  height += h
561  width = max(width, w)
562 
563  height = height + 5
564  if height > 400: height = 400
565  width = width + 5
566  if width > 400: width = 400
567 
568  #
569  # VListBox for displaying and selecting transformations
570  #
571  self.translist = TransList(panel, id = -1, size = (width, height), style = wx.SUNKEN_BORDER)
572  self.translist.SetItemCount(tlistlen)
573  self.translist.SetSelection(2)
574  self.translist.SetFocus()
575 
576  self.Bind(wx.EVT_LISTBOX, self.ClickTrans, self.translist)
577 
578  bodySizer.Add(item = self.translist, proportion = 1, flag = wx.ALIGN_CENTER|wx.ALL|wx.EXPAND)
579 
580  #
581  # buttons
582  #
583  btnsizer = wx.StdDialogButtonSizer()
584 
585  btn = wx.Button(parent = panel, id = wx.ID_OK)
586  btn.SetDefault()
587  btnsizer.AddButton(btn)
588 
589  btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
590  btnsizer.AddButton(btn)
591  btnsizer.Realize()
592 
593  sizer.Add(item = bodySizer, proportion = 1,
594  flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
595 
596  sizer.Add(item = btnsizer, proportion = 0,
597  flag = wx.ALL | wx.ALIGN_RIGHT, border = 5)
598 
599  sizer.Fit(panel)
600 
601  self.SetSize(self.GetBestSize())
602  self.Layout()
603 
604  def ClickTrans(self, event):
605  """!Get the number of the datum transform to use in g.proj"""
606  self.transnum = event.GetSelection()
607  self.transnum = self.transnum - 1
608 
609  def GetTransform(self):
610  """!Get the number of the datum transform to use in g.proj"""
611  self.transnum = self.translist.GetSelection()
612  self.transnum = self.transnum - 1
613  return self.transnum
wxGUI command interface
def GetTransform
Get the number of the datum transform to use in g.proj.
def __DoLayout
Window layout.
#define max(x, y)
Definition: draw2.c:69
def OnValue
Set given value.
Location wizard - base classes.
def MakeSettings3DPaneContent
Create 3D region settings pane.
def ClickTrans
Get the number of the datum transform to use in g.proj.
Creates a multiline listbox for selecting datum transforms.
Dialog for selecting datum transformations.
Page for setting default region extents and resolution.
def OnSetButton
Set default region.
def OnSettings3DPaneChanged
Collapse 3D settings box.
def __UpdateInfo
Update number of rows/cols/cells.
def RunCommand
Run GRASS command.
Definition: gcmd.py:625