ghelp.py 45 KB

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