ghelp.py 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. """!
  2. @package help.py
  3. @brief Help window
  4. Classes:
  5. - SearchModuleWindow
  6. - ItemTree
  7. - MenuTreeWindow
  8. - MenuTree
  9. - AboutWindow
  10. - InstallExtensionWindow
  11. - ExtensionTree
  12. - HelpFrame
  13. - HelpWindow
  14. - HelpPanel
  15. (C) 2008-2010 by the GRASS Development Team
  16. This program is free software under the GNU General Public License
  17. (>=v2). Read the file COPYING that comes with GRASS for details.
  18. @author Martin Landa <landa.martin gmail.com>
  19. """
  20. import os
  21. import wx
  22. try:
  23. import wx.lib.agw.customtreectrl as CT
  24. # import wx.lib.agw.hyperlink as hl
  25. except ImportError:
  26. import wx.lib.customtreectrl as CT
  27. # import wx.lib.hyperlink as hl
  28. import wx.lib.flatnotebook as FN
  29. import wx.lib.scrolledpanel as scrolled
  30. import menudata
  31. import gcmd
  32. import globalvar
  33. import gdialogs
  34. class HelpFrame(wx.Frame):
  35. """!GRASS Quickstart help window"""
  36. def __init__(self, parent, id, title, size, file):
  37. wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size)
  38. sizer = wx.BoxSizer(wx.VERTICAL)
  39. # text
  40. content = HelpPanel(parent = self)
  41. content.LoadPage(file)
  42. sizer.Add(item = content, proportion=1, flag=wx.EXPAND)
  43. self.SetAutoLayout(True)
  44. self.SetSizer(sizer)
  45. self.Layout()
  46. class SearchModuleWindow(wx.Panel):
  47. """!Search module window (used in MenuTreeWindow)"""
  48. def __init__(self, parent, id = wx.ID_ANY, cmdPrompt = None,
  49. showChoice = True, showTip = False, **kwargs):
  50. self.showTip = showTip
  51. self.showChoice = showChoice
  52. self.cmdPrompt = cmdPrompt
  53. wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
  54. self._searchDict = { _('description') : 'description',
  55. _('command') : 'command',
  56. _('keywords') : 'keywords' }
  57. self.box = wx.StaticBox(parent = self, id = wx.ID_ANY,
  58. label=" %s " % _("Find module(s)"))
  59. self.searchBy = wx.Choice(parent = self, id = wx.ID_ANY,
  60. choices = [_('description'),
  61. _('keywords'),
  62. _('command')])
  63. self.searchBy.SetSelection(0)
  64. self.search = wx.TextCtrl(parent = self, id = wx.ID_ANY,
  65. value = "", size = (-1, 25),
  66. style = wx.TE_PROCESS_ENTER)
  67. self.search.Bind(wx.EVT_TEXT, self.OnSearchModule)
  68. if self.showTip:
  69. self.searchTip = gdialogs.StaticWrapText(parent = self, id = wx.ID_ANY,
  70. size = (-1, 35))
  71. if self.showChoice:
  72. self.searchChoice = wx.Choice(parent = self, id = wx.ID_ANY)
  73. if self.cmdPrompt:
  74. self.searchChoice.SetItems(self.cmdPrompt.GetCommandItems())
  75. self.searchChoice.Bind(wx.EVT_CHOICE, self.OnSelectModule)
  76. self._layout()
  77. def _layout(self):
  78. """!Do layout"""
  79. sizer = wx.StaticBoxSizer(self.box, wx.HORIZONTAL)
  80. gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
  81. gridSizer.AddGrowableCol(1)
  82. gridSizer.Add(item = self.searchBy,
  83. flag=wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
  84. gridSizer.Add(item = self.search,
  85. flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (0, 1))
  86. row = 1
  87. if self.showTip:
  88. gridSizer.Add(item = self.searchTip,
  89. flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (row, 0), span = (1, 2))
  90. row += 1
  91. if self.showChoice:
  92. gridSizer.Add(item = self.searchChoice,
  93. flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (row, 0), span = (1, 2))
  94. sizer.Add(item = gridSizer, proportion = 1)
  95. self.SetSizer(sizer)
  96. sizer.Fit(self)
  97. def GetSelection(self):
  98. """!Get selected element"""
  99. selection = self.searchBy.GetStringSelection()
  100. return self._searchDict[selection]
  101. def SetSelection(self, i):
  102. """!Set selection element"""
  103. self.searchBy.SetSelection(i)
  104. def OnSearchModule(self, event):
  105. """!Search module by keywords or description"""
  106. if not self.cmdPrompt:
  107. event.Skip()
  108. return
  109. text = event.GetString()
  110. if not text:
  111. self.cmdPrompt.SetFilter(None)
  112. mList = self.cmdPrompt.GetCommandItems()
  113. self.searchChoice.SetItems(mList)
  114. if self.showTip:
  115. self.searchTip.SetLabel(_("%d modules found") % len(mList))
  116. event.Skip()
  117. return
  118. modules = dict()
  119. iFound = 0
  120. for module, data in self.cmdPrompt.moduleDesc.iteritems():
  121. found = False
  122. sel = self.searchBy.GetSelection()
  123. if sel == 0: # -> description
  124. if text in data['desc']:
  125. found = True
  126. elif sel == 1: # keywords
  127. if self.cmdPrompt.CheckKey(text, data['keywords']):
  128. found = True
  129. else: # command
  130. if text in module:
  131. found = True
  132. if found:
  133. iFound += 1
  134. try:
  135. group, name = module.split('.')
  136. except ValueError:
  137. continue # TODO
  138. if not modules.has_key(group):
  139. modules[group] = list()
  140. modules[group].append(name)
  141. self.cmdPrompt.SetFilter(modules)
  142. self.searchChoice.SetItems(self.cmdPrompt.GetCommandItems())
  143. if self.showTip:
  144. self.searchTip.SetLabel(_("%d modules found") % iFound)
  145. event.Skip()
  146. def OnSelectModule(self, event):
  147. """!Module selected from choice, update command prompt"""
  148. cmd = event.GetString().split(' ', 1)[0]
  149. text = cmd + ' '
  150. pos = len(text)
  151. if self.cmdPrompt:
  152. self.cmdPrompt.SetText(text)
  153. self.cmdPrompt.SetSelectionStart(pos)
  154. self.cmdPrompt.SetCurrentPos(pos)
  155. self.cmdPrompt.SetFocus()
  156. desc = self.cmdPrompt.GetCommandDesc(cmd)
  157. if self.showTip:
  158. self.searchTip.SetLabel(desc)
  159. class MenuTreeWindow(wx.Panel):
  160. """!Show menu tree"""
  161. def __init__(self, parent, id = wx.ID_ANY, **kwargs):
  162. self.parent = parent # LayerManager
  163. wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
  164. self.dataBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
  165. label=" %s " % _("Menu tree (double-click to run command)"))
  166. # tree
  167. self.tree = MenuTree(parent = self, data = menudata.ManagerData())
  168. self.tree.Load()
  169. # search widget
  170. self.search = SearchModuleWindow(parent = self, showChoice = False)
  171. # buttons
  172. self.btnRun = wx.Button(self, id = wx.ID_OK, label = _("&Run"))
  173. self.btnRun.SetToolTipString(_("Run selected command"))
  174. self.btnRun.Enable(False)
  175. # bindings
  176. self.btnRun.Bind(wx.EVT_BUTTON, self.OnRun)
  177. self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated)
  178. self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnItemSelected)
  179. self.search.Bind(wx.EVT_TEXT_ENTER, self.OnShowItem)
  180. self.search.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
  181. self._layout()
  182. self.search.SetFocus()
  183. def _layout(self):
  184. """!Do dialog layout"""
  185. sizer = wx.BoxSizer(wx.VERTICAL)
  186. # body
  187. dataSizer = wx.StaticBoxSizer(self.dataBox, wx.HORIZONTAL)
  188. dataSizer.Add(item = self.tree, proportion =1,
  189. flag = wx.EXPAND)
  190. # buttons
  191. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  192. btnSizer.Add(item = self.btnRun, proportion = 0)
  193. sizer.Add(item = dataSizer, proportion = 1,
  194. flag = wx.EXPAND | wx.ALL, border = 5)
  195. sizer.Add(item = self.search, proportion=0,
  196. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
  197. sizer.Add(item = btnSizer, proportion=0,
  198. flag = wx.ALIGN_RIGHT | wx.BOTTOM | wx.RIGHT, border = 5)
  199. sizer.Fit(self)
  200. sizer.SetSizeHints(self)
  201. self.SetSizer(sizer)
  202. self.Fit()
  203. self.SetAutoLayout(True)
  204. self.Layout()
  205. def OnCloseWindow(self, event):
  206. """!Close window"""
  207. self.Destroy()
  208. def OnRun(self, event):
  209. """!Run selected command"""
  210. if not self.tree.GetSelected():
  211. return # should not happen
  212. data = self.tree.GetPyData(self.tree.GetSelected())
  213. if not data:
  214. return
  215. handler = 'self.parent.' + data['handler'].lstrip('self.')
  216. if data['handler'] == 'self.OnXTerm':
  217. wx.MessageBox(parent = self,
  218. message = _('You must run this command from the menu or command line',
  219. 'This command require an XTerm'),
  220. caption = _('Message'), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
  221. elif data['command']:
  222. eval(handler)(event = None, cmd = data['command'].split())
  223. else:
  224. eval(handler)(None)
  225. def OnShowItem(self, event):
  226. """!Show selected item"""
  227. self.tree.OnShowItem(event)
  228. if self.tree.GetSelected():
  229. self.btnRun.Enable()
  230. else:
  231. self.btnRun.Enable(False)
  232. def OnItemActivated(self, event):
  233. """!Item activated (double-click)"""
  234. item = event.GetItem()
  235. if not item or not item.IsOk():
  236. return
  237. data = self.tree.GetPyData(item)
  238. if not data or not data.has_key('command'):
  239. return
  240. self.tree.itemSelected = item
  241. self.OnRun(None)
  242. def OnItemSelected(self, event):
  243. """!Item selected"""
  244. item = event.GetItem()
  245. if not item or not item.IsOk():
  246. return
  247. data = self.tree.GetPyData(item)
  248. if not data or not data.has_key('command'):
  249. return
  250. if data['command']:
  251. label = data['command'] + ' -- ' + data['description']
  252. else:
  253. label = data['description']
  254. self.parent.SetStatusText(label, 0)
  255. def OnUpdateStatusBar(self, event):
  256. """!Update statusbar text"""
  257. element = self.search.GetSelection()
  258. self.tree.SearchItems(element = element,
  259. value = event.GetString())
  260. nItems = len(self.tree.itemsMarked)
  261. if event.GetString():
  262. self.parent.SetStatusText(_("%d modules match") % nItems, 0)
  263. else:
  264. self.parent.SetStatusText("", 0)
  265. event.Skip()
  266. class ItemTree(CT.CustomTreeCtrl):
  267. def __init__(self, parent, id = wx.ID_ANY,
  268. ctstyle = CT.TR_HIDE_ROOT | CT.TR_FULL_ROW_HIGHLIGHT | CT.TR_HAS_BUTTONS |
  269. CT.TR_LINES_AT_ROOT | CT.TR_SINGLE, **kwargs):
  270. super(ItemTree, self).__init__(parent, id, ctstyle = ctstyle, **kwargs)
  271. self.root = self.AddRoot(_("Menu tree"))
  272. self.itemsMarked = [] # list of marked items
  273. self.itemSelected = None
  274. def SearchItems(self, element, value):
  275. """!Search item
  276. @param element element index (see self.searchBy)
  277. @param value
  278. @return list of found tree items
  279. """
  280. items = list()
  281. if not value:
  282. return items
  283. item = self.GetFirstChild(self.root)[0]
  284. self._processItem(item, element, value, items)
  285. self.itemsMarked = items
  286. self.itemSelected = None
  287. return items
  288. def _processItem(self, item, element, value, listOfItems):
  289. """!Search items (used by SearchItems)
  290. @param item reference item
  291. @param listOfItems list of found items
  292. """
  293. while item and item.IsOk():
  294. subItem = self.GetFirstChild(item)[0]
  295. if subItem:
  296. self._processItem(subItem, element, value, listOfItems)
  297. data = self.GetPyData(item)
  298. if data and data.has_key(element) and \
  299. value.lower() in data[element].lower():
  300. listOfItems.append(item)
  301. item = self.GetNextSibling(item)
  302. def GetSelected(self):
  303. """!Get selected item"""
  304. return self.itemSelected
  305. def OnShowItem(self, event):
  306. """!Highlight first found item in menu tree"""
  307. if len(self.itemsMarked) > 0:
  308. if self.GetSelected():
  309. self.ToggleItemSelection(self.GetSelected())
  310. idx = self.itemsMarked.index(self.GetSelected()) + 1
  311. else:
  312. idx = 0
  313. try:
  314. self.ToggleItemSelection(self.itemsMarked[idx])
  315. self.itemSelected = self.itemsMarked[idx]
  316. self.EnsureVisible(self.itemsMarked[idx])
  317. except IndexError:
  318. self.ToggleItemSelection(self.itemsMarked[0]) # reselect first item
  319. self.EnsureVisible(self.itemsMarked[0])
  320. self.itemSelected = self.itemsMarked[0]
  321. else:
  322. for item in self.root.GetChildren():
  323. self.Collapse(item)
  324. itemSelected = self.GetSelection()
  325. if itemSelected:
  326. self.ToggleItemSelection(itemSelected)
  327. self.itemSelected = None
  328. class MenuTree(ItemTree):
  329. """!Menu tree class"""
  330. def __init__(self, parent, data, **kwargs):
  331. self.parent = parent
  332. self.menudata = data
  333. super(MenuTree, self).__init__(parent, **kwargs)
  334. def Load(self, data = None):
  335. """!Load menu data tree
  336. @param data menu data (None to use self.menudata)
  337. """
  338. if not data:
  339. data = self.menudata
  340. self.itemsMarked = [] # list of marked items
  341. for eachMenuData in data.GetMenu():
  342. for label, items in eachMenuData:
  343. item = self.AppendItem(parentId = self.root,
  344. text = label.replace('&', ''))
  345. self.__AppendItems(item, items)
  346. def __AppendItems(self, item, data):
  347. """!Append items into tree (used by Load()
  348. @param item tree item (parent)
  349. @parent data menu data"""
  350. for eachItem in data:
  351. if len(eachItem) == 2:
  352. if eachItem[0]:
  353. itemSub = self.AppendItem(parentId = item,
  354. text = eachItem[0])
  355. self.__AppendItems(itemSub, eachItem[1])
  356. else:
  357. if eachItem[0]:
  358. itemNew = self.AppendItem(parentId = item,
  359. text = eachItem[0])
  360. data = { 'item' : eachItem[0],
  361. 'description' : eachItem[1],
  362. 'handler' : eachItem[2],
  363. 'command' : eachItem[3],
  364. 'keywords' : eachItem[4] }
  365. self.SetPyData(itemNew, data)
  366. class AboutWindow(wx.Frame):
  367. def __init__(self, parent):
  368. """!Create custom About Window
  369. @todo improve styling
  370. """
  371. wx.Frame.__init__(self, parent=parent, id=wx.ID_ANY, size=(550,400),
  372. title=_('About GRASS GIS'))
  373. panel = wx.Panel(parent = self, id = wx.ID_ANY)
  374. # icon
  375. self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
  376. # get version and web site
  377. version, svn_gis_h_rev, svn_gis_h_date = gcmd.RunCommand('g.version',
  378. flags = 'r',
  379. read = True).splitlines()
  380. infoTxt = wx.Panel(parent = panel, id = wx.ID_ANY)
  381. infoSizer = wx.BoxSizer(wx.VERTICAL)
  382. infoGridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  383. infoGridSizer.AddGrowableCol(0)
  384. infoGridSizer.AddGrowableCol(1)
  385. logo = os.path.join(globalvar.ETCDIR, "gui", "icons", "grass.ico")
  386. logoBitmap = wx.StaticBitmap(parent = infoTxt, id = wx.ID_ANY,
  387. bitmap = wx.Bitmap(name = logo,
  388. type = wx.BITMAP_TYPE_ICO))
  389. infoSizer.Add(item = logoBitmap, proportion = 0,
  390. flag = wx.ALL | wx.ALIGN_CENTER, border = 25)
  391. info = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
  392. label = version.replace('GRASS', 'GRASS GIS').strip() + '\n\n')
  393. info.SetFont(wx.Font(13, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
  394. infoSizer.Add(item = info, proportion = 0,
  395. flag = wx.BOTTOM | wx.ALIGN_CENTER, border = 15)
  396. infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
  397. label = _('Official GRASS site:')),
  398. pos = (0, 0),
  399. flag = wx.ALIGN_RIGHT)
  400. infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
  401. label = 'http://grass.osgeo.org'),
  402. pos = (0, 1),
  403. flag = wx.ALIGN_LEFT)
  404. # infoGridSizer.Add(item = hl.HyperLinkCtrl(parent = self, id = wx.ID_ANY,
  405. # label = 'http://grass.osgeo.org',
  406. # URL = 'http://grass.osgeo.org'),
  407. # pos = (0, 1),
  408. # flag = wx.LEFT)
  409. infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
  410. label = _('GIS Library Revision:')),
  411. pos = (2, 0),
  412. flag = wx.ALIGN_RIGHT)
  413. infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
  414. label = svn_gis_h_rev.split(' ')[1] + ' (' +
  415. svn_gis_h_date.split(' ')[1] + ')'),
  416. pos = (2, 1),
  417. flag = wx.ALIGN_LEFT)
  418. infoSizer.Add(item = infoGridSizer,
  419. proportion = 1,
  420. flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL,
  421. border = 25)
  422. #
  423. # create pages
  424. #
  425. copyrightwin = self.PageCopyright()
  426. licensewin = self.PageLicense()
  427. authorwin = self.PageCredit()
  428. contribwin = self.PageContributors()
  429. transwin = self.PageTranslators()
  430. # create a flat notebook for displaying information about GRASS
  431. nbstyle = FN.FNB_VC8 | \
  432. FN.FNB_BACKGROUND_GRADIENT | \
  433. FN.FNB_TABS_BORDER_SIMPLE | \
  434. FN.FNB_NO_X_BUTTON
  435. aboutNotebook = FN.FlatNotebook(panel, id=wx.ID_ANY, style=nbstyle)
  436. aboutNotebook.SetTabAreaColour(globalvar.FNPageColor)
  437. # make pages for About GRASS notebook
  438. pg1 = aboutNotebook.AddPage(infoTxt, text=_("Info"))
  439. pg2 = aboutNotebook.AddPage(copyrightwin, text=_("Copyright"))
  440. pg3 = aboutNotebook.AddPage(licensewin, text=_("License"))
  441. pg4 = aboutNotebook.AddPage(authorwin, text=_("Authors"))
  442. pg5 = aboutNotebook.AddPage(contribwin, text=_("Contributors"))
  443. pg5 = aboutNotebook.AddPage(transwin, text=_("Translators"))
  444. wx.CallAfter(aboutNotebook.SetSelection, 0)
  445. # buttons
  446. btnClose = wx.Button(parent = panel, id = wx.ID_CLOSE)
  447. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  448. btnSizer.Add(item = btnClose, proportion = 0,
  449. flag = wx.ALL | wx.ALIGN_RIGHT,
  450. border = 5)
  451. # bindings
  452. # self.aboutNotebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnAGPageChanged)
  453. btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow)
  454. infoTxt.SetSizer(infoSizer)
  455. infoSizer.Fit(infoTxt)
  456. sizer = wx.BoxSizer(wx.VERTICAL)
  457. sizer.Add(item=aboutNotebook, proportion=1,
  458. flag=wx.EXPAND | wx.ALL, border=1)
  459. sizer.Add(item=btnSizer, proportion=0,
  460. flag=wx.ALL | wx.ALIGN_RIGHT, border=1)
  461. panel.SetSizer(sizer)
  462. self.Layout()
  463. def PageCopyright(self):
  464. """Copyright information"""
  465. copyfile = os.path.join(os.getenv("GISBASE"), "COPYING")
  466. if os.path.exists(copyfile):
  467. copyrightFile = open(copyfile, 'r')
  468. copytext = copyrightFile.read()
  469. copyrightFile.close()
  470. else:
  471. copytext = _('%s file missing') % 'COPYING'
  472. # put text into a scrolling panel
  473. copyrightwin = scrolled.ScrolledPanel(self, id=wx.ID_ANY,
  474. size=wx.DefaultSize,
  475. style = wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER)
  476. copyrighttxt = wx.StaticText(copyrightwin, id=wx.ID_ANY, label=copytext)
  477. copyrightwin.SetAutoLayout(True)
  478. copyrightwin.sizer = wx.BoxSizer(wx.VERTICAL)
  479. copyrightwin.sizer.Add(item=copyrighttxt, proportion=1,
  480. flag=wx.EXPAND | wx.ALL, border=3)
  481. copyrightwin.SetSizer(copyrightwin.sizer)
  482. copyrightwin.Layout()
  483. copyrightwin.SetupScrolling()
  484. return copyrightwin
  485. def PageLicense(self):
  486. """Licence about"""
  487. licfile = os.path.join(os.getenv("GISBASE"), "GPL.TXT")
  488. if os.path.exists(licfile):
  489. licenceFile = open(licfile, 'r')
  490. license = ''.join(licenceFile.readlines())
  491. licenceFile.close()
  492. else:
  493. license = _('%s file missing') % 'GPL.TXT'
  494. # put text into a scrolling panel
  495. licensewin = scrolled.ScrolledPanel(self, id=wx.ID_ANY,
  496. style = wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER)
  497. licensetxt = wx.StaticText(licensewin, id=wx.ID_ANY, label=license)
  498. licensewin.SetAutoLayout(True)
  499. licensewin.sizer = wx.BoxSizer(wx.VERTICAL)
  500. licensewin.sizer.Add(item=licensetxt, proportion=1,
  501. flag=wx.EXPAND | wx.ALL, border=3)
  502. licensewin.SetSizer(licensewin.sizer)
  503. licensewin.Layout()
  504. licensewin.SetupScrolling()
  505. return licensewin
  506. def PageCredit(self):
  507. """Credit about"""
  508. # credits
  509. authfile = os.path.join(os.getenv("GISBASE"), "AUTHORS")
  510. if os.path.exists(authfile):
  511. authorsFile = open(authfile, 'r')
  512. authors = unicode(''.join(authorsFile.readlines()), "utf-8")
  513. authorsFile.close()
  514. else:
  515. authors = _('%s file missing') % 'AUTHORS'
  516. authorwin = scrolled.ScrolledPanel(self, id=wx.ID_ANY,
  517. style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
  518. authortxt = wx.StaticText(authorwin, id=wx.ID_ANY, label=authors)
  519. authorwin.SetAutoLayout(1)
  520. authorwin.SetupScrolling()
  521. authorwin.sizer = wx.BoxSizer(wx.VERTICAL)
  522. authorwin.sizer.Add(item=authortxt, proportion=1,
  523. flag=wx.EXPAND | wx.ALL, border=3)
  524. authorwin.SetSizer(authorwin.sizer)
  525. authorwin.Layout()
  526. return authorwin
  527. def PageContributors(self):
  528. """Contributors info"""
  529. contribfile = os.path.join(os.getenv("GISBASE"), "contributors.csv")
  530. if os.path.exists(contribfile):
  531. contribFile = open(contribfile, 'r')
  532. contribs = list()
  533. for line in contribFile.readlines():
  534. cvs_id, name, email, country, osgeo_id, rfc2_agreed = line.split(',')
  535. contribs.append((name, email, country, osgeo_id))
  536. contribs[0] = (_('Name'), _('E-mail'), _('Country'), _('OSGeo_ID'))
  537. contribFile.close()
  538. else:
  539. contribs = None
  540. contribwin = scrolled.ScrolledPanel(self, id=wx.ID_ANY,
  541. style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
  542. contribwin.SetAutoLayout(1)
  543. contribwin.SetupScrolling()
  544. contribwin.sizer = wx.BoxSizer(wx.VERTICAL)
  545. if not contribs:
  546. contribtxt = wx.StaticText(contribwin, id=wx.ID_ANY,
  547. label=_('%s file missing') % 'contibutors.csv')
  548. contribwin.sizer.Add(item=contribtxt, proportion=1,
  549. flag=wx.EXPAND | wx.ALL, border=3)
  550. else:
  551. contribBox = wx.FlexGridSizer(cols=4, vgap=5, hgap=5)
  552. for developer in contribs:
  553. for item in developer:
  554. contribBox.Add(item = wx.StaticText(parent = contribwin, id = wx.ID_ANY,
  555. label = item))
  556. contribwin.sizer.Add(item=contribBox, proportion=1,
  557. flag=wx.EXPAND | wx.ALL, border=3)
  558. contribwin.SetSizer(contribwin.sizer)
  559. contribwin.Layout()
  560. return contribwin
  561. def PageTranslators(self):
  562. """Translators info"""
  563. translatorsfile = os.path.join(os.getenv("GISBASE"), "translators.csv")
  564. if os.path.exists(translatorsfile):
  565. translatorsFile = open(translatorsfile, 'r')
  566. translators = dict()
  567. for line in translatorsFile.readlines()[1:]:
  568. name, email, languages = line.rstrip('\n').split(',')
  569. for language in languages.split(' '):
  570. if not translators.has_key(language):
  571. translators[language] = list()
  572. translators[language].append((name, email))
  573. translatorsFile.close()
  574. else:
  575. translators = None
  576. translatorswin = scrolled.ScrolledPanel(self, id=wx.ID_ANY,
  577. style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
  578. translatorswin.SetAutoLayout(1)
  579. translatorswin.SetupScrolling()
  580. translatorswin.sizer = wx.BoxSizer(wx.VERTICAL)
  581. if not translators:
  582. translatorstxt = wx.StaticText(translatorswin, id=wx.ID_ANY,
  583. label=_('%s file missing') % 'translators.csv')
  584. translatorswin.sizer.Add(item=translatorstxt, proportion=1,
  585. flag=wx.EXPAND | wx.ALL, border=3)
  586. else:
  587. translatorsBox = wx.FlexGridSizer(cols=3, vgap=5, hgap=5)
  588. languages = translators.keys()
  589. languages.sort()
  590. translatorsBox.Add(item = wx.StaticText(parent = translatorswin, id = wx.ID_ANY,
  591. label = _('Name')))
  592. translatorsBox.Add(item = wx.StaticText(parent = translatorswin, id = wx.ID_ANY,
  593. label = _('E-mail')))
  594. translatorsBox.Add(item = wx.StaticText(parent = translatorswin, id = wx.ID_ANY,
  595. label = _('Language')))
  596. for lang in languages:
  597. for translator in translators[lang]:
  598. name, email = translator
  599. translatorsBox.Add(item = wx.StaticText(parent = translatorswin, id = wx.ID_ANY,
  600. label = unicode(name, "utf-8")))
  601. translatorsBox.Add(item = wx.StaticText(parent = translatorswin, id = wx.ID_ANY,
  602. label = email))
  603. translatorsBox.Add(item = wx.StaticText(parent = translatorswin, id = wx.ID_ANY,
  604. label = lang))
  605. translatorswin.sizer.Add(item=translatorsBox, proportion=1,
  606. flag=wx.EXPAND | wx.ALL, border=3)
  607. translatorswin.SetSizer(translatorswin.sizer)
  608. translatorswin.Layout()
  609. return translatorswin
  610. def OnCloseWindow(self, event):
  611. """!Close window"""
  612. self.Close()
  613. class InstallExtensionWindow(wx.Frame):
  614. def __init__(self, parent, id = wx.ID_ANY,
  615. title = _("Fetch & install new extension from GRASS Addons"), **kwargs):
  616. self.parent = parent
  617. wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
  618. self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
  619. self.repoBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
  620. label=" %s " % _("Repository"))
  621. self.findBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
  622. label=" %s " % _("Find extension by"))
  623. self.treeBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
  624. label=" %s " % _("List of extensions"))
  625. self.repo = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY,
  626. value = 'https://svn.osgeo.org/grass/grass-addons')
  627. self.fullDesc = wx.CheckBox(parent = self.panel, id=wx.ID_ANY,
  628. label = _("Fetch full info including description and keywords (takes time)"))
  629. self.fullDesc.SetValue(False)
  630. self.search = SearchModuleWindow(parent = self.panel)
  631. self.search.SetSelection(2)
  632. self.tree = ExtensionTree(parent = self.panel, log = parent.GetLogWindow())
  633. self.statusbar = self.CreateStatusBar(0)
  634. self.btnFetch = wx.Button(parent = self.panel, id = wx.ID_ANY,
  635. label = _("&Fetch"))
  636. self.btnFetch.SetToolTipString(_("Fetch list of available modules from GRASS Addons SVN repository"))
  637. self.btnClose = wx.Button(parent = self.panel, id = wx.ID_CLOSE)
  638. self.btnInstall = wx.Button(parent = self.panel, id = wx.ID_ANY,
  639. label = _("&Install"))
  640. self.btnInstall.SetToolTipString(_("Install selected add-ons GRASS module"))
  641. self.btnInstall.Enable(False)
  642. self.btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow)
  643. self.btnFetch.Bind(wx.EVT_BUTTON, self.OnFetch)
  644. self.btnInstall.Bind(wx.EVT_BUTTON, self.OnInstall)
  645. self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated)
  646. self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnItemSelected)
  647. self.search.Bind(wx.EVT_TEXT_ENTER, self.OnShowItem)
  648. self.search.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
  649. self._layout()
  650. def _layout(self):
  651. """!Do layout"""
  652. sizer = wx.BoxSizer(wx.VERTICAL)
  653. repoSizer = wx.StaticBoxSizer(self.repoBox, wx.VERTICAL)
  654. repo1Sizer = wx.BoxSizer(wx.HORIZONTAL)
  655. repo1Sizer.Add(item = self.repo, proportion = 1,
  656. flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL, border = 1)
  657. repo1Sizer.Add(item = self.btnFetch, proportion = 0,
  658. flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL, border = 1)
  659. repoSizer.Add(item = repo1Sizer,
  660. flag = wx.EXPAND)
  661. repoSizer.Add(item = self.fullDesc)
  662. findSizer = wx.StaticBoxSizer(self.findBox, wx.HORIZONTAL)
  663. findSizer.Add(item = self.search, proportion = 1)
  664. treeSizer = wx.StaticBoxSizer(self.treeBox, wx.HORIZONTAL)
  665. treeSizer.Add(item = self.tree, proportion = 1,
  666. flag = wx.ALL | wx.EXPAND, border = 1)
  667. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  668. btnSizer.Add(item = self.btnClose, proportion = 0,
  669. flag = wx.RIGHT, border = 5)
  670. btnSizer.Add(item = self.btnInstall, proportion = 0)
  671. sizer.Add(item = repoSizer, proportion = 0,
  672. flag = wx.ALL | wx.EXPAND, border = 3)
  673. sizer.Add(item = findSizer, proportion = 0,
  674. flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  675. sizer.Add(item = treeSizer, proportion = 1,
  676. flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  677. sizer.Add(item = btnSizer, proportion=0,
  678. flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
  679. self.panel.SetSizer(sizer)
  680. sizer.Fit(self.panel)
  681. self.Layout()
  682. def _install(self, name):
  683. if not name:
  684. return
  685. log = self.parent.GetLogWindow()
  686. log.RunCmd(['g.extension', 'extension=' + name,
  687. 'svnurl=' + self.repo.GetValue().strip()])
  688. self.OnCloseWindow(None)
  689. def OnUpdateStatusBar(self, event):
  690. """!Update statusbar text"""
  691. element = self.search.GetSelection()
  692. if not self.tree.IsLoaded():
  693. self.SetStatusText(_("Fetch list of available extensions by clicking on 'Fetch' button"), 0)
  694. return
  695. self.tree.SearchItems(element = element,
  696. value = event.GetString())
  697. nItems = len(self.tree.itemsMarked)
  698. if event.GetString():
  699. self.SetStatusText(_("%d items match") % nItems, 0)
  700. else:
  701. self.SetStatusText("", 0)
  702. event.Skip()
  703. def OnCloseWindow(self, event):
  704. """!Close window"""
  705. self.Destroy()
  706. def OnFetch(self, event):
  707. """!Fetch list of available extensions"""
  708. self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
  709. self.tree.Load(url = self.repo.GetValue().strip(), full = self.fullDesc.IsChecked())
  710. self.SetStatusText("", 0)
  711. def OnItemActivated(self, event):
  712. item = event.GetItem()
  713. data = self.tree.GetPyData(item)
  714. if data and data.has_key('command'):
  715. self._install(data['command'])
  716. def OnInstall(self, event):
  717. """!Install selected extension"""
  718. item = self.tree.GetSelected()
  719. if not item.IsOk():
  720. return
  721. self._install(self.tree.GetItemText(item))
  722. def OnItemSelected(self, event):
  723. """!Item selected"""
  724. item = event.GetItem()
  725. self.tree.itemSelected = item
  726. data = self.tree.GetPyData(item)
  727. if not data:
  728. self.SetStatusText('', 0)
  729. self.btnInstall.Enable(False)
  730. else:
  731. self.SetStatusText(data.get('description', ''), 0)
  732. self.btnInstall.Enable(True)
  733. def OnShowItem(self, event):
  734. """!Show selected item"""
  735. self.tree.OnShowItem(event)
  736. if self.tree.GetSelected():
  737. self.btnInstall.Enable()
  738. else:
  739. self.btnInstall.Enable(False)
  740. class ExtensionTree(ItemTree):
  741. """!List of available extensions"""
  742. def __init__(self, parent, log, id = wx.ID_ANY,
  743. ctstyle = CT.TR_HIDE_ROOT | CT.TR_FULL_ROW_HIGHLIGHT | CT.TR_HAS_BUTTONS |
  744. CT.TR_LINES_AT_ROOT | CT.TR_SINGLE,
  745. **kwargs):
  746. self.parent = parent # GMFrame
  747. self.log = log
  748. super(ExtensionTree, self).__init__(parent, id, ctstyle = ctstyle, **kwargs)
  749. self._initTree()
  750. def _initTree(self):
  751. for prefix in ('display', 'database',
  752. 'general', 'imagery',
  753. 'misc', 'postscript', 'paint',
  754. 'raster', 'raster3D', 'sites', 'vector'):
  755. self.AppendItem(parentId = self.root,
  756. text = prefix)
  757. self._loaded = False
  758. def _expandPrefix(self, c):
  759. name = { 'd' : 'display',
  760. 'db' : 'database',
  761. 'g' : 'general',
  762. 'i' : 'imagery',
  763. 'm' : 'misc',
  764. 'ps' : 'postscript',
  765. 'p' : 'paint',
  766. 'r' : 'raster',
  767. 'r3' : 'raster3D',
  768. 's' : 'sites',
  769. 'v' : 'vector' }
  770. if name.has_key(c):
  771. return name[c]
  772. return c
  773. def _findItem(self, text):
  774. """!Find item"""
  775. item = self.GetFirstChild(self.root)[0]
  776. while item and item.IsOk():
  777. if text == self.GetItemText(item):
  778. return item
  779. item = self.GetNextSibling(item)
  780. return None
  781. def Load(self, url, full = False):
  782. """!Load list of extensions"""
  783. self.DeleteAllItems()
  784. self.root = self.AddRoot(_("Menu tree"))
  785. self._initTree()
  786. if full:
  787. flags = 'g'
  788. else:
  789. flags = 'l'
  790. ret = gcmd.RunCommand('g.extension', read = True,
  791. svnurl = url,
  792. flags = flags, quiet = True)
  793. if not ret:
  794. return
  795. mdict = dict()
  796. for line in ret.splitlines():
  797. if full:
  798. key, value = line.split('=', 1)
  799. if key == 'name':
  800. prefix, name = value.split('.', 1)
  801. if not mdict.has_key(prefix):
  802. mdict[prefix] = dict()
  803. mdict[prefix][name] = dict()
  804. else:
  805. mdict[prefix][name][key] = value
  806. else:
  807. prefix, name = line.strip().split('.', 1)
  808. if not mdict.has_key(prefix):
  809. mdict[prefix] = dict()
  810. mdict[prefix][name] = { 'command' : prefix + '.' + name }
  811. for prefix in mdict.keys():
  812. prefixName = self._expandPrefix(prefix)
  813. item = self._findItem(prefixName)
  814. names = mdict[prefix].keys()
  815. names.sort()
  816. for name in names:
  817. new = self.AppendItem(parentId = item,
  818. text = prefix + '.' + name)
  819. data = dict()
  820. for key in mdict[prefix][name].keys():
  821. data[key] = mdict[prefix][name][key]
  822. self.SetPyData(new, data)
  823. self._loaded = True
  824. def IsLoaded(self):
  825. """Check if items are loaded"""
  826. return self._loaded
  827. class HelpWindow(wx.html.HtmlWindow):
  828. """!This panel holds the text from GRASS docs.
  829. GISBASE must be set in the environment to find the html docs dir.
  830. The SYNOPSIS section is skipped, since this Panel is supposed to
  831. be integrated into the cmdPanel and options are obvious there.
  832. """
  833. def __init__(self, parent, grass_command, text, skip_description,
  834. **kwargs):
  835. """!If grass_command is given, the corresponding HTML help
  836. file will be presented, with all links pointing to absolute
  837. paths of local files.
  838. If 'skip_description' is True, the HTML corresponding to
  839. SYNOPSIS will be skipped, thus only presenting the help file
  840. from the DESCRIPTION section onwards.
  841. If 'text' is given, it must be the HTML text to be presented
  842. in the Panel.
  843. """
  844. self.parent = parent
  845. wx.InitAllImageHandlers()
  846. wx.html.HtmlWindow.__init__(self, parent = parent, **kwargs)
  847. gisbase = os.getenv("GISBASE")
  848. self.loaded = False
  849. self.history = list()
  850. self.historyIdx = 0
  851. self.fspath = os.path.join(gisbase, "docs", "html")
  852. self.SetStandardFonts (size = 10)
  853. self.SetBorders(10)
  854. if text is None:
  855. if skip_description:
  856. url = os.path.join(self.fspath, grass_command + ".html")
  857. self.fillContentsFromFile(url,
  858. skip_description = skip_description)
  859. self.history.append(url)
  860. self.loaded = True
  861. else:
  862. ### FIXME: calling LoadPage() is strangely time-consuming (only first call)
  863. # self.LoadPage(self.fspath + grass_command + ".html")
  864. self.loaded = False
  865. else:
  866. self.SetPage(text)
  867. self.loaded = True
  868. def OnLinkClicked(self, linkinfo):
  869. url = linkinfo.GetHref()
  870. if url[:4] != 'http':
  871. url = os.path.join(self.fspath, url)
  872. self.history.append(url)
  873. self.historyIdx += 1
  874. self.parent.OnHistory()
  875. super(HelpWindow, self).OnLinkClicked(linkinfo)
  876. def fillContentsFromFile(self, htmlFile, skip_description=True):
  877. """!Load content from file"""
  878. aLink = re.compile(r'(<a href="?)(.+\.html?["\s]*>)', re.IGNORECASE)
  879. imgLink = re.compile(r'(<img src="?)(.+\.[png|gif])', re.IGNORECASE)
  880. try:
  881. contents = []
  882. skip = False
  883. for l in file(htmlFile, "rb").readlines():
  884. if "DESCRIPTION" in l:
  885. skip = False
  886. if not skip:
  887. # do skip the options description if requested
  888. if "SYNOPSIS" in l:
  889. skip = skip_description
  890. else:
  891. # FIXME: find only first item
  892. findALink = aLink.search(l)
  893. if findALink is not None:
  894. contents.append(aLink.sub(findALink.group(1)+
  895. self.fspath+findALink.group(2),l))
  896. findImgLink = imgLink.search(l)
  897. if findImgLink is not None:
  898. contents.append(imgLink.sub(findImgLink.group(1)+
  899. self.fspath+findImgLink.group(2),l))
  900. if findALink is None and findImgLink is None:
  901. contents.append(l)
  902. self.SetPage("".join(contents))
  903. self.loaded = True
  904. except: # The Manual file was not found
  905. self.loaded = False
  906. class HelpPanel(wx.Panel):
  907. def __init__(self, parent, grass_command = "index", text = None,
  908. skip_description = False, **kwargs):
  909. self.grass_command = grass_command
  910. wx.Panel.__init__(self, parent = parent, id = wx.ID_ANY)
  911. self.content = HelpWindow(self, grass_command, text,
  912. skip_description)
  913. self.btnNext = wx.Button(parent = self, id = wx.ID_ANY,
  914. label = _("&Next"))
  915. self.btnNext.Enable(False)
  916. self.btnPrev = wx.Button(parent = self, id = wx.ID_ANY,
  917. label = _("&Previous"))
  918. self.btnPrev.Enable(False)
  919. self.btnNext.Bind(wx.EVT_BUTTON, self.OnNext)
  920. self.btnPrev.Bind(wx.EVT_BUTTON, self.OnPrev)
  921. self._layout()
  922. def _layout(self):
  923. """!Do layout"""
  924. sizer = wx.BoxSizer(wx.VERTICAL)
  925. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  926. btnSizer.Add(item = self.btnPrev, proportion = 0,
  927. flag = wx.ALL, border = 5)
  928. btnSizer.Add(item = wx.Size(1, 1), proportion = 1)
  929. btnSizer.Add(item = self.btnNext, proportion = 0,
  930. flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
  931. sizer.Add(item = self.content, proportion = 1,
  932. flag = wx.EXPAND)
  933. sizer.Add(item = btnSizer, proportion = 0,
  934. flag = wx.EXPAND)
  935. self.SetSizer(sizer)
  936. sizer.Fit(self)
  937. def LoadPage(self, path = None):
  938. """!Load page"""
  939. if not path:
  940. path = os.path.join(self.content.fspath, self.grass_command + ".html")
  941. self.content.history.append(path)
  942. self.content.LoadPage(path)
  943. def IsFile(self):
  944. """!Check if file exists"""
  945. return os.path.isfile(os.path.join(self.content.fspath, self.grass_command + ".html"))
  946. def IsLoaded(self):
  947. return self.content.loaded
  948. def OnHistory(self):
  949. """!Update buttons"""
  950. nH = len(self.content.history)
  951. iH = self.content.historyIdx
  952. if iH == nH - 1:
  953. self.btnNext.Enable(False)
  954. elif iH > -1:
  955. self.btnNext.Enable(True)
  956. if iH < 1:
  957. self.btnPrev.Enable(False)
  958. else:
  959. self.btnPrev.Enable(True)
  960. def OnNext(self, event):
  961. """Load next page"""
  962. self.content.historyIdx += 1
  963. idx = self.content.historyIdx
  964. path = self.content.history[idx]
  965. self.content.LoadPage(path)
  966. self.OnHistory()
  967. event.Skip()
  968. def OnPrev(self, event):
  969. """Load previous page"""
  970. self.content.historyIdx -= 1
  971. idx = self.content.historyIdx
  972. path = self.content.history[idx]
  973. self.content.LoadPage(path)
  974. self.OnHistory()
  975. event.Skip()