-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabs.py
More file actions
95 lines (78 loc) · 3.31 KB
/
tabs.py
File metadata and controls
95 lines (78 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# -*- coding: utf-8 -*-
"""
/***************************************************************************
ErcTvbPluginDialog
A QGIS plugin
MitiConnect integrates ecological Connectivity in Mitigation Hierarchy
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2021-08-25
git sha : $Format:%H$
copyright : (C) 2021 by INRAE
email : mathieu.chailloux@inrae.fr
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
import os
from .qgis_lib_mc import utils
#import helps
from PyQt5.QtCore import QUrl, QFile, QIODevice, QTextStream
from PyQt5.QtGui import QTextDocument
class TabItem:
def __init__(self,helpFile):
self.descr = "TODO"
self.helpFile = helpFile
def setDescr(self,descr):
self.descr = descr
def getHelpFile(self):
plugin_dir = os.path.dirname(__file__)
help_dir = os.path.join(plugin_dir,"help")
helpFile = os.path.join(help_dir,self.helpFile + "-" + utils.curr_language + ".html")
return helpFile
paramsTabItem = TabItem("paramsHelp")
dataTabItem = TabItem("dataHelp")
spTabItem = TabItem("speciesHelp")
frictionTabItem = TabItem("frictionHelp")
scTabItem = TabItem("scenarioHelp")
launchItem = TabItem("launchHelp")
logTabItem = TabItem("logHelp")
class TabConnector:
def __init__(self,dlg):
self.tabs = [paramsTabItem,
dataTabItem,
spTabItem,
frictionTabItem,
scTabItem,
launchItem,
logTabItem]
self.dlg = dlg
self.curr_tab = 0
def initGui(self):
self.dlg.textShortHelp.setOpenLinks(True)
self.loadNTab(0)
def loadNTab(self,n):
utils.debug("[loadNTab] " + str(n))
nb_tabs = len(self.tabs)
self.curr_tab = n
if n >= nb_tabs:
utils.internal_error("[loadNTab] loading " + str(n) + " tab but nb_tabs = " + str(nb_tabs))
else:
self.loadHelpFile()
#utils.debug("source : " + str(self.dlg.textShortHelp.source()))
def loadHelpFile(self):
tabItem = self.tabs[self.curr_tab]
helpFile = tabItem.getHelpFile()
utils.debug("Help file = " + str(helpFile))
utils.checkFileExists(helpFile)
with open(helpFile) as f:
msg = f.read()
self.dlg.textShortHelp.setHtml(msg)
def connectComponents(self):
self.dlg.mTabWidget.currentChanged.connect(self.loadNTab)