-
Notifications
You must be signed in to change notification settings - Fork 0
/
SVGDisplay.py
62 lines (56 loc) · 2.6 KB
/
SVGDisplay.py
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
from PyQt5.QtGui import QCursor
__author__ = 'user'
from PyQt5 import QtCore, QtWidgets
from SVGView import Ui_Dialog
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QLabel
class SVGDisplay(Ui_Dialog):
"""
Create a small webkit based box to display schedule diagrams
"""
def __init__(self,parent,svgFile, fullSched, sqlite_db):
"""
Create the display box based on input parent widget and populated with
svg file whose fully qualified path and filename must be passed
"""
self._sched = fullSched
self._sqlite_db = sqlite_db
self._parent_dialog = parent
dlg = QtWidgets.QDialog()
self.setupUi(dlg)
imageUrl = QtCore.QUrl.fromLocalFile(svgFile) # Fully qualified filename
self.webView.load(imageUrl)
self.webView.setZoomFactor(0.5)
self.horizontalSlider.setValue(50)
self.horizontalSlider.valueChanged.connect(self.magnification)
self.webView.selectionChanged.connect(self.showDetails)
dlg.setVisible(True)
dlg.exec_()
def magnification(self):
self.webView.setZoomFactor(self.horizontalSlider.sliderPosition()/100)
def showDetails(self):
"""
This method is invoked when the text on the SVG schedule is selected. Firstly
the name of the schedule is read from the database, secondly a label is displayed
with the text name and thirdly the schedule in the main GUI is updated to the
chosen one from the displayed SVG file and the associated jobs displayed.
:return: None
"""
sched = self.webView.selectedText()
try: name = self._sched.getSchedName(sched, self._sqlite_db)
except KeyError: return
#Display label with description
label = QLabel('<font style="color: grey; background-color: yellow"><p>' + name + '</p></font>')
label.move(QCursor.pos().x()+30,QCursor.pos().y()+20)
label.setWindowFlags(QtCore.Qt.SplashScreen)
label.show()
QTimer.singleShot(10000,label.destroy)
#set schedule selected in main parent dialog to be that selected in the graph display
try:
if sched != '':
self._parent_dialog.comboBoxSched.setCurrentText(sched) #Change display of combo box
i = self._parent_dialog.findIndex(sched) # Where in selection combo list
self._parent_dialog.comboBoxSched.setCurrentIndex(i)
self._parent_dialog.comboBoxSched.currentIndexChanged(i)
self._parent_dialog.tablePopulate(i) #Populate main display
except TypeError : pass