-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtabs.py
More file actions
99 lines (82 loc) · 3.58 KB
/
tabs.py
File metadata and controls
99 lines (82 loc) · 3.58 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
96
97
98
99
# -*- coding: utf-8 -*-
"""
/***************************************************************************
BioDispersal
A QGIS plugin
Computes ecological continuities based on environments permeability
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2018-04-12
git sha : $Format:%H$
copyright : (C) 2018 by IRSTEA
email : mathieu.chailloux@irstea.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,idx,name,helpFile):
self.idx = idx
self.name = name
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(0,"Paramètres","paramsHelp")
stTabItem = TabItem(1,"Sous-trames","stHelp")
selectionTabItem = TabItem(2,"Sélection","selectionHelp")
fusionTabItem = TabItem(3,"Fusion","fusionHelp")
frictionTabItem = TabItem(4,"Friction","frictionHelp")
pondTabItem = TabItem(5,"Pondération","ponderationHelp")
dispersionTabItem = TabItem(6,"Dispersion","dispersionHelp")
logTabItem = TabItem(7,"Journal","logHelp")
class TabConnector:
def __init__(self,dlg):
self.tabs = [paramsTabItem,
stTabItem,
selectionTabItem,
fusionTabItem,
frictionTabItem,
pondTabItem,
dispersionTabItem,
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)