Graph mockup

This commit is contained in:
jpk 2020-01-21 14:19:14 +01:00
parent 714bf2892d
commit f769eca8f9
2 changed files with 1543 additions and 99 deletions

1510
res/MainWindow.ui Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +1,49 @@
#!/usr/bin/env python
import sys
from PyQt5.QtWidgets import (
QApplication, QWidget, QMainWindow, QLabel, QFrame, QComboBox, QPushButton,
QButtonGroup, QRadioButton
from PySide2.QtWidgets import (
QApplication, QMainWindow
)
import PyQt5.QtGui as QtGui
import pyqtgraph as pg
from PySide2.QtCharts import (
QtCharts
)
from UM24CUI import Ui_MainWindow
import random
class UM24Lab(QMainWindow):
def __init__(self, screen_width=1280, screen_height=1024):
super().__init__()
self.title = 'UM24C USB Meter Lab'
self.width = 800
self.height = 600
self.left = screen_width // 2 - self.width // 2
self.top = screen_height // 2 - self.height // 2
self.init_ui()
def __init__(self):
super(UM24Lab, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
def init_ui(self):
"""
Window Layout
+---------+-----------------------+
|(1) |(3) |
| (1.1) | |
| (1.2) | PLOTS |
| | |
+---------+ |
|(2) +------+------+---------+
| |(4) | | |
| | (4.1)| (4.2)|(4.3) |
| | | | |
| | | |---------|
| | | |(4.4) |
| | | | |
+---------+------+------+---------+
self.ui.plotVoltage = QtCharts.QChart()
self.ui.widgetVoltage.setChart(self.ui.plotVoltage)
"""
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.statusBar().showMessage('Idle')
self.ui.plotCurrent = QtCharts.QChart()
self.ui.widgetCurrent.setChart(self.ui.plotCurrent)
centralWidget = QWidget()
centralLayout = QtGui.QHBoxLayout()
centralWidget.setLayout(centralLayout)
voltage = self.ui.plotVoltage
series = QtCharts.QLineSeries()
series.setName('Voltage')
for x in range(100):
y = random.randint(0, 10)
series.append(x, y)
voltage.addSeries(series)
# (1) Device Control
# (1.1) Device Management
deviceWidget = QWidget()
layout = QtGui.QHBoxLayout()
deviceWidget.setLayout(layout)
self.deviceSelect = QComboBox()
layout.addWidget(self.deviceSelect)
# TODO: Populate deviceSelect
self.btnDeviceConnect = QPushButton('Connect')
layout.addWidget(self.btnDeviceConnect)
centralLayout.addWidget(deviceWidget)
# (1.2) Screen Control
screenWidget = QWidget()
layout = QtGui.QGridLayout()
screenWidget.setLayout(layout)
self.screenIndicator = QWidget()
screenManagementButtons = QButtonGroup()
group = QWidget()
groupLayout = QtGui.QHBoxLayout()
group.setLayout(groupLayout)
for i in range(7):
btn = QRadioButton()
screenManagementButtons.addButton(btn)
groupLayout.addWidget(btn)
layout.addWidget(group, 0, 0, 0, 1)
# TODO: Select initial screen
self.btnRotateScreen = QPushButton('Rotate')
layout.addWidget(self.btnRotateScreen, 1, 0)
self.btnNextPage = QPushButton('Next')
layout.addWidget(self.btnNextPage, 1, 1,)
centralLayout.addWidget(screenWidget)
# TODO: Screen Timeout
# (2) Group Memory
# TODO: List groups: Capacity (mAh) and Energy (mWh)
# (3) Plots
plotWidget = QWidget()
layout = QtGui.QHBoxLayout()
plotWidget.setLayout(layout)
self.plotVoltage = pg.PlotWidget()
self.plotCurrent = pg.PlotWidget()
layout.addWidget(self.plotCurrent)
layout.addWidget(self.plotVoltage)
centralLayout.addWidget(plotWidget)
# (4) Current Measurement
# TODO: (4.1) Voltage, Current, Power, Impedance
# TODO: (4.2) Recorder
# TODO: (4.3) USB D+/D-, Mode
# TODO: (4.4) Temperature (°C, °F)
self.setCentralWidget(centralWidget)
self.show()
def slot_connect_device(self):
self.statusBar().showMessage('Connecting...')
# TODO: connect to UM24C
current = self.ui.plotCurrent
series = QtCharts.QLineSeries()
series.setName('Current')
for x in range(100):
y = random.randint(0, 10)
series.append(x, y)
current.addSeries(series)
if __name__ == '__main__':
app = QApplication(sys.argv)
screen_resolution = app.desktop().screenGeometry()
labview = UM24Lab(screen_resolution.width(), screen_resolution.height())
labview = UM24Lab()
labview.show()
sys.exit(app.exec_())