-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathapplication.py
36 lines (25 loc) · 1019 Bytes
/
application.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
from PyQt5 import QtGui, QtCore
# import the "form class" from your compiled UI
from template import Ui_CustomWidget
class CustomWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(CustomWidget, self).__init__(parent=parent)
# set up the form class as a `ui` attribute
self.ui = Ui_CustomWidget()
self.ui.setupUi(self)
# access your UI elements through the `ui` attribute
self.ui.plotWidget.plot(x=[0.0, 1.0, 2.0, 3.0],
y=[4.4, 2.5, 2.1, 2.2])
# simple demonstration of pure Qt widgets interacting with pyqtgraph
self.ui.checkBox.stateChanged.connect(self.toggleMouse)
def toggleMouse(self, state):
if state == QtCore.Qt.Checked:
enabled = True
else:
enabled = False
self.ui.plotWidget.setMouseEnabled(x=enabled, y=enabled)
if __name__ == '__main__':
app = QtGui.QApplication([])
widget = CustomWidget()
widget.show()
app.exec_()