Skip to content

Commit 90b9ea1

Browse files
authored
Merge pull request #1 from FeldmanLab/pyqt5
Pyqt5
2 parents 20debed + 341fe4f commit 90b9ea1

6 files changed

Lines changed: 95 additions & 85 deletions

File tree

122 KB
Binary file not shown.

Resources/dvPlotterResources_rc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# WARNING! All changes made in this file will be lost!
88

9-
from PyQt4 import QtCore
9+
from PyQt5 import QtCore
1010

1111
qt_resource_data = b"\
1212
\x00\x00\x04\xc3\

dataVaultLivePlotter.py

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
import sys
33
import os
44
import os.path
5+
from pathlib import Path
56
import twisted
6-
from PyQt4 import QtCore, QtGui, QtTest, uic
7-
from PyQt4.QtGui import *
8-
from PyQt4.QtCore import *
9-
from PyQt4.QtGui import QApplication, QPrinter
10-
from PyQt4.QtWebKit import QWebView
7+
from PyQt5 import QtCore, QtGui, QtTest, uic, QtWidgets, QtPrintSupport
8+
from PyQt5.QtGui import *
9+
from PyQt5.QtCore import *
10+
from PyQt5.QtWidgets import QApplication
11+
from PyQt5.QtPrintSupport import QPrinter
12+
#from PyQt5.QtWebEngineWidgets import QWebEngineView
1113
from twisted.internet.defer import inlineCallbacks, Deferred
1214
import numpy as np
1315
import pyqtgraph as pg
@@ -28,21 +30,19 @@
2830
print("--------------PyPDF2 not installed... Merge PDF function disabled--------------")
2931

3032

31-
32-
path = sys.path[0]
33-
34-
sys.path.append(sys.path[0] + '\Resources')
33+
path = os.path.dirname(os.path.realpath(__file__))
34+
sys.path.append(os.path.join(path, 'Resources'))
3535
import dvPlotterResources_rc
3636

37-
mainWinGUI = path + r"\startPlotter.ui"
38-
plotExtentGUI = path + r"\extentPrompt.ui"
39-
dvExplorerGUI = path + r"\dvExplorer.ui"
40-
dirExplorerGUI = path + r"\dirExplorer.ui"
41-
editInfoGUI = path + r"\editDatasetInfo.ui"
42-
plotSetupUI = path + r"\plotSetup.ui"
43-
helpWindowUI = path + r"\helpWindow.ui"
37+
mainWinGUI = os.path.join(path, 'startPlotter.ui')
38+
plotExtentGUI = os.path.join(path, 'extentPrompt.ui')
39+
dvExplorerGUI = os.path.join(path, 'dvExplorer.ui')
40+
dirExplorerGUI = os.path.join(path, 'dirExplorer.ui')
41+
editInfoGUI = os.path.join(path, 'editDatasetInfo.ui')
42+
plotSetupUI = os.path.join(path, 'plotSetup.ui')
43+
helpWindowUI = os.path.join(path, 'helpWindow.ui')
4444

45-
guiIconPath = path + r"\hex.svg"
45+
guiIconPath = os.path.join(path, 'hex.svg')
4646

4747
Ui_MainWin, QtBaseClass = uic.loadUiType(mainWinGUI)
4848
Ui_ExtPrompt, QtBaseClass = uic.loadUiType(plotExtentGUI)
@@ -433,11 +433,11 @@ def setupTable(self):
433433
headers = [min, max, pts]
434434

435435
min.setText('Minimum Value')
436-
min.setTextColor(QtGui.QColor(131,131,131))
436+
min.setForeground(QBrush(QColor(131,131,131)))
437437
max.setText('Maximum Value')
438-
max.setTextColor(QtGui.QColor(131,131,131))
438+
max.setForeground(QBrush(QColor(131,131,131)))
439439
pts.setText('Number of Points')
440-
pts.setTextColor(QtGui.QColor(131,131,131))
440+
pts.setForeground(QBrush(QColor(131,131,131)))
441441

442442
for ii in range(0, 3):
443443
self.extTable.setItem(0, ii+1, headers[ii])
@@ -459,7 +459,7 @@ def setupTable(self):
459459
for c in range(1, 4):
460460
item = QtGui.QTableWidgetItem()
461461
self.extTable.setItem(r, c, item)
462-
self.extTable.item(r, c).setBackgroundColor(QtGui.QColor(255,255,255))
462+
self.extTable.item(r, c).setBackground(QBrush(QColor(255,255,255)))
463463

464464
def moveDefault(self):
465465
self.move(self.x0, self.y0)
@@ -470,7 +470,7 @@ def checkExt(self):
470470

471471
for r in range(1, len(self.plotInfo) + 1):
472472
for c in range(1, 4):
473-
self.extTable.item(r, c).setBackgroundColor(QtGui.QColor(255,255,255))
473+
self.extTable.item(r, c).setBackground(QBrush(QColor(255,255,255)))
474474

475475
for r in range(1, self.extTable.rowCount()):
476476
try:
@@ -495,7 +495,7 @@ def checkExt(self):
495495
self.accept()
496496
else:
497497
for ii in range(0, len(errCell)):
498-
self.extTable.item(errCell[ii][0], errCell[ii][1]).setBackgroundColor(QtGui.QColor(250,190,160))
498+
self.extTable.item(errCell[ii][0], errCell[ii][1]).setBackground(QBrush(QColor(250,190,160)))
499499

500500
def closeEvent(self, e):
501501
self.reject()
@@ -1353,13 +1353,13 @@ def __init__(self, reactor, file, dir, plotInfo, yMovePos, pencolor):
13531353
self.backBtn1.setStyleSheet("QPushButton#backBtn1 {color:rgb(131,131,131);background-color:black;border: 2px solid rgb(131,131,131);border-radius: 5px; height: 38px; width: 70px}")
13541354

13551355
self.saveMATBtn.setObjectName('saveMATBtn')
1356-
self.saveMATBtn.setStyleSheet("QPushButton#saveMATBtn {image:url(:/dvPlotter/Pictures/saveMATLAB.png);background-color: transparent; height: 23px; width: 23px;}")
1356+
self.saveMATBtn.setStyleSheet("QPushButton#saveMATBtn {border-image:url(:/dvPlotter/Pictures/saveMATLAB.png);background-color: transparent; height: 23px; width: 23px;}")
13571357
self.savePDFBtn.setObjectName('savePDFBtn')
1358-
self.savePDFBtn.setStyleSheet("QPushButton#savePDFBtn {image:url(:/dvPlotter/Pictures/savePDF.png);background-color: transparent; height: 23px; width: 23px;}")
1358+
self.savePDFBtn.setStyleSheet("QPushButton#savePDFBtn {border-image:url(:/dvPlotter/Pictures/savePDF.png);background-color: transparent; height: 23px; width: 23px;}")
13591359
self.editNotesBtn.setObjectName('editNotesBtn')
1360-
self.editNotesBtn.setStyleSheet("QPushButton#editNotesBtn {image:url(:/dvPlotter/Pictures/editNotes.png);background-color: transparent; height: 15px; width: 23px;}")
1360+
self.editNotesBtn.setStyleSheet("QPushButton#editNotesBtn {border-image:url(:/dvPlotter/Pictures/editNotes.png);background-color: transparent; height: 15px; width: 23px;}")
13611361
self.openDVBtn.setObjectName('openDVBtn')
1362-
self.openDVBtn.setStyleSheet("QPushButton#openDVBtn {image:url(:/dvPlotter/Pictures/browse.png); background-color: transparent; height: 18px; width: 18px;}")
1362+
self.openDVBtn.setStyleSheet("QPushButton#openDVBtn {border-image:url(:/dvPlotter/Pictures/browse.png); background-color: transparent; height: 18px; width: 18px;}")
13631363

13641364
self.layout.setColumnStretch(0, 1)
13651365
self.layout.setColumnStretch(1,5)
@@ -1547,7 +1547,7 @@ def openNotepad(self):
15471547
if self.noteEdits.accepted:
15481548
self.notes = self.noteEdits.textEditor.toPlainText()
15491549

1550-
class plotSaved2DWindow(QtGui.QWidget):
1550+
class plotSaved2DWindow(QtWidgets.QWidget):
15511551
def __init__(self, reactor, fileDV, dir, plotInfo, yMovePos ):
15521552
super(plotSaved2DWindow, self).__init__()
15531553

@@ -1564,8 +1564,8 @@ def __init__(self, reactor, fileDV, dir, plotInfo, yMovePos ):
15641564
self.yAxis = self.plotInfo['y axis']
15651565
self.zAxis = self.plotInfo['z axis']
15661566

1567-
self.connect(QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL+ QtCore.Qt.Key_C), self), QtCore.SIGNAL('activated()'),self.copyPlotToClip)
1568-
1567+
#self.connect(QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL+ QtCore.Qt.Key_C), self), QtCore.SIGNAL('activated()'),self.copyPlotToClip)
1568+
QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL+ QtCore.Qt.Key_C), self).activated.connect(self.copyPlotToClip)
15691569
self.notes = ''
15701570
self.plotTitle = self.plotInfo['title']
15711571
if self.plotTitle[0:5] == 'Plot ':
@@ -1698,13 +1698,13 @@ def __init__(self, reactor, fileDV, dir, plotInfo, yMovePos ):
16981698
self.backBtn1.setStyleSheet("QPushButton#backBtn1 {color:rgb(131,131,131);background-color:black;border: 2px solid rgb(131,131,131);border-radius: 5px; height: 38px; width: 70px}")
16991699

17001700
self.saveMATBtn.setObjectName('saveMATBtn')
1701-
self.saveMATBtn.setStyleSheet("QPushButton#saveMATBtn {image:url(:/dvPlotter/Pictures/saveMATLAB.png);background-color: transparent; height: 23px; width: 23px;}")
1701+
self.saveMATBtn.setStyleSheet("QPushButton#saveMATBtn {border-image:url(:/dvPlotter/Pictures/saveMATLAB.png);background-color: transparent; height: 23px; width: 23px;}")
17021702
self.savePDFBtn.setObjectName('savePDFBtn')
1703-
self.savePDFBtn.setStyleSheet("QPushButton#savePDFBtn {image:url(:/dvPlotter/Pictures/savePDF.png);background-color: transparent; height: 23px; width: 23px;}")
1703+
self.savePDFBtn.setStyleSheet("QPushButton#savePDFBtn {border-image:url(:/dvPlotter/Pictures/savePDF.png);background-color: transparent; height: 23px; width: 23px;}")
17041704
self.editNotesBtn.setObjectName('editNotesBtn')
1705-
self.editNotesBtn.setStyleSheet("QPushButton#editNotesBtn {image:url(:/dvPlotter/Pictures/editNotes.png);background-color: transparent; height: 15px; width: 23px;}")
1705+
self.editNotesBtn.setStyleSheet("QPushButton#editNotesBtn {border-image:url(:/dvPlotter/Pictures/editNotes.png);background-color: transparent; height: 15px; width: 23px;}")
17061706
self.openDVBtn.setObjectName('openDVBtn')
1707-
self.openDVBtn.setStyleSheet("QPushButton#openDVBtn {image:url(:/dvPlotter/Pictures/browse.png); background-color: transparent; height: 18px; width: 18px;}")
1707+
self.openDVBtn.setStyleSheet("QPushButton#openDVBtn {border-image:url(:/dvPlotter/Pictures/browse.png); background-color: transparent; height: 18px; width: 18px;}")
17081708

17091709

17101710

@@ -2188,9 +2188,13 @@ def __init__(self, parent = None):
21882188

21892189
self.lineNumberArea = LineNumberArea(self)
21902190

2191-
self.connect(self, QtCore.SIGNAL('blockCountChanged(int)'), self.updateLineNumberAreaWidth)
2192-
self.connect(self, QtCore.SIGNAL('updateRequest(QRect,int)'), self.updateLineNumberArea)
2193-
self.connect(self, QtCore.SIGNAL('cursorPositionChanged()'), self.highlightCurrentLine)
2191+
#self.connect(self, QtCore.SIGNAL('blockCountChanged(int)'), self.updateLineNumberAreaWidth)
2192+
#self.connect(self, QtCore.SIGNAL('updateRequest(QRect,int)'), self.updateLineNumberArea)
2193+
#self.connect(self, QtCore.SIGNAL('cursorPositionChanged()'), self.highlightCurrentLine)
2194+
2195+
self.blockCountChanged.connect(self.updateLineNumberAreaWidth)
2196+
self.updateRequest.connect(self.updateLineNumberArea)
2197+
self.cursorPositionChanged.connect(self.highlightCurrentLine)
21942198

21952199
self.updateLineNumberAreaWidth(0)
21962200

@@ -2368,26 +2372,26 @@ def setupTables(self):
23682372
headers = [lbl1, x1, y1, lbl2, x2, y2, z2]
23692373

23702374
num1.setText('Plot')
2371-
num1.setTextColor(QtGui.QColor(131,131,131))
2375+
num1.setForeground(QBrush(QColor(131,131,131)))
23722376
num2.setText('Plot')
2373-
num2.setTextColor(QtGui.QColor(131,131,131))
2377+
num2.setForeground(QBrush(QColor(131,131,131)))
23742378

23752379
lbl1.setText('Plot Title')
2376-
lbl1.setTextColor(QtGui.QColor(131,131,131))
2380+
lbl1.setForeground(QBrush(QColor(131,131,131)))
23772381
lbl2.setText('Plot Title')
2378-
lbl2.setTextColor(QtGui.QColor(131,131,131))
2382+
lbl2.setForeground(QBrush(QColor(131,131,131)))
23792383

23802384
x1.setText('X Axis')
2381-
x1.setTextColor(QtGui.QColor(131,131,131))
2385+
x1.setForeground(QBrush(QColor(131,131,131)))
23822386
y1.setText('Y Axis')
2383-
y1.setTextColor(QtGui.QColor(131,131,131))
2387+
y1.setForeground(QBrush(QColor(131,131,131)))
23842388

23852389
x2.setText('X Axis')
2386-
x2.setTextColor(QtGui.QColor(131,131,131))
2390+
x2.setForeground(QBrush(QColor(131,131,131)))
23872391
y2.setText('Y Axis')
2388-
y2.setTextColor(QtGui.QColor(131,131,131))
2392+
y2.setForeground(QBrush(QColor(131,131,131)))
23892393
z2.setText('Z Axis')
2390-
z2.setTextColor(QtGui.QColor(131,131,131))
2394+
z2.setForeground(QBrush(QColor(131,131,131)))
23912395

23922396
for ii in range(0, 3):
23932397
self.onePlots.setItem(0, ii, headers[ii])
@@ -2414,31 +2418,31 @@ def formatTable(self, num = None):
24142418
for r in range(0, self.onePlots.rowCount()):
24152419
if self.onePlots.item(r, c) != None:
24162420
self.onePlots.item(r, c).setBackground(QtGui.QColor(0,0,0))
2417-
self.onePlots.item(r, c).setTextColor(QtGui.QColor(131,131,131))
2421+
self.onePlots.item(r, c).setForeground(QBrush(QColor(131,131,131)))
24182422
if c != 0:
24192423
self.onePlots.item(r, c).setFlags(QtCore.Qt.NoItemFlags)
24202424
elif c == 0 and r != 0:
24212425

24222426
item = self.onePlots.item(r, c)
24232427
if item.text() == '':
24242428
item.setText(self.backtext1)
2425-
item.setBackgroundColor(QtGui.QColor(100,100,150))
2426-
item.setTextColor(QtGui.QColor(0,0,0))
2429+
item.setBackground(QBrush(QColor(100,100,150)))
2430+
item.setForeground(QBrush(QColor(0,0,0)))
24272431
elif num ==2:
24282432
for c in range(0, 4):
24292433
for r in range(0, self.twoPlots.rowCount()):
24302434
if self.twoPlots.item(r, c) != None:
24312435
self.twoPlots.item(r, c).setBackground(QtGui.QColor(0,0,0))
2432-
self.twoPlots.item(r, c).setTextColor(QtGui.QColor(131,131,131))
2436+
self.twoPlots.item(r, c).setForeground(QBrush(QColor(131,131,131)))
24332437
if c != 0:
24342438
self.twoPlots.item(r, c).setFlags(QtCore.Qt.NoItemFlags)
24352439
elif c == 0 and r != 0:
24362440

24372441
item = self.twoPlots.item(r, c)
24382442
if item.text() == '':
24392443
item.setText(self.backtext2)
2440-
item.setBackgroundColor(QtGui.QColor(100,100,150))
2441-
item.setTextColor(QtGui.QColor(0,0,0))
2444+
item.setBackground(QBrush(QColor(100,100,150)))
2445+
item.setForeground(QBrush(QColor(0,0,0)))
24422446
else:
24432447
pass
24442448
self.formFlag = True
@@ -2720,10 +2724,10 @@ def popDirs(self, c = None):
27202724
l = yield self.dv.dir()
27212725
for i in l[0]:
27222726
self.dirList.addItem(i)
2723-
self.dirList.item(self.dirList.count() - 1).setTextColor(QtGui.QColor(131,131,131))
2727+
self.dirList.item(self.dirList.count() - 1).setForeground(QBrush(QColor(131,131,131)))
27242728
for i in l[1]:
27252729
self.fileList.addItem(i)
2726-
self.fileList.item(self.fileList.count() - 1).setTextColor(QtGui.QColor(131,131,131))
2730+
self.fileList.item(self.fileList.count() - 1).setForeground(QBrush(QColor(131,131,131)))
27272731
if self.currentDir[-1] == '':
27282732

27292733
self.dirName.setText('Root')
@@ -2853,10 +2857,10 @@ def popDirs(self, initDir = None, c = None):
28532857
l = yield self.dv.dir()
28542858
for i in l[0]:
28552859
self.dirList.addItem(i)
2856-
self.dirList.item(self.dirList.count() - 1).setTextColor(QtGui.QColor(131,131,131))
2860+
self.dirList.item(self.dirList.count() - 1).setForeground(QBrush(QColor(131,131,131)))
28572861
for i in l[1]:
28582862
self.fileList.addItem(i)
2859-
self.fileList.item(self.fileList.count() - 1).setTextColor(QtGui.QColor(131,131,131))
2863+
self.fileList.item(self.fileList.count() - 1).setForeground(QBrush(QColor(131,131,131)))
28602864
if self.currentDir[-1] == '':
28612865

28622866
self.dirName.setText('Root')
@@ -2952,8 +2956,8 @@ def closeEvent(self, e):
29522956
if __name__ == "__main__":
29532957
global app
29542958
app = QtGui.QApplication([])
2955-
from qtreactor import pyqt4reactor
2956-
pyqt4reactor.install()
2959+
import qt5reactor
2960+
qt5reactor.install()
29572961
from twisted.internet import reactor
29582962
window = dvPlotter(reactor)
29592963
window.show()

dirExplorer.ui

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ border-radius: 5px
7878
</property>
7979
<property name="styleSheet">
8080
<string notr="true">QPushButton#home{
81-
image:url(:/dvPlotter/Pictures/home.png);
81+
border-image:url(:/dvPlotter/Pictures/home.png);
8282
background: black;
8383

8484
}
8585

8686
QPushButton:pressed#home{
87-
image:url(:/dvPlotter/Pictures/home.png);
87+
border-image:url(:/dvPlotter/Pictures/home.png);
8888
background: black;
8989
border: 2px rgb(131,131,131);
9090
border-radius: 5px
@@ -118,7 +118,7 @@ border-radius: 5px
118118
</property>
119119
<property name="styleSheet">
120120
<string notr="true">background-color: black;
121-
text-color: rgb(131,131,131);</string>
121+
color: rgb(131,131,131);</string>
122122
</property>
123123
<property name="frameShape">
124124
<enum>QFrame::StyledPanel</enum>
@@ -176,13 +176,13 @@ text-color: rgb(131,131,131);</string>
176176
</property>
177177
<property name="styleSheet">
178178
<string notr="true">QPushButton#back{
179-
image:url(:/dvPlotter/Pictures/back.png);
179+
border-image:url(:/dvPlotter/Pictures/back.png);
180180
background: black;
181181

182182
}
183183

184184
QPushButton:pressed#back{
185-
image:url(:/dvPlotter/Pictures/back.png);
185+
border-image:url(:/dvPlotter/Pictures/back.png);
186186
background: black;
187187
border: 2px rgb(131,131,131);
188188
border-radius: 5px
@@ -250,13 +250,13 @@ border-radius: 5px
250250
</property>
251251
<property name="styleSheet">
252252
<string notr="true">QPushButton#addDir{
253-
image:url(:/dvPlotter/Pictures/add.png);
253+
border-image:url(:/dvPlotter/Pictures/add.png);
254254
background: black;
255255

256256
}
257257

258258
QPushButton:pressed#addDir{
259-
image:url(:/dvPlotter/Pictures/add.png);
259+
border-image:url(:/dvPlotter/Pictures/add.png);
260260
background: black;
261261
border: 2px rgb(131,131,131);
262262
border-radius: 5px
@@ -280,13 +280,13 @@ border-radius: 5px
280280
</property>
281281
<property name="styleSheet">
282282
<string notr="true">QPushButton#refresh{
283-
image:url(:/dvPlotter/Pictures/refresh.png);
283+
border-image:url(:/dvPlotter/Pictures/refresh.png);
284284
background: black;
285285

286286
}
287287

288288
QPushButton:pressed#refresh{
289-
image:url(:/dvPlotter/Pictures/refresh.png);
289+
border-image:url(:/dvPlotter/Pictures/refresh.png);
290290
background: black;
291291
border: 2px rgb(131,131,131);
292292
border-radius: 5px

0 commit comments

Comments
 (0)