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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
# -*- coding: utf-8 -*-
import sys
import numpy as np
from PyQt5 import QtCore, QtGui, QtWidgets
from qwt.PyQt5.QtGui import QApplication, QPen
from qwt.PyQt5.QtCore import Qt
from qwt import QwtPlot, QwtPlotMarker, QwtLegend, QwtPlotCurve, QwtText
class SimplePlot(QwtPlot):
def __init__(self, *args):
QwtPlot.__init__(self, *args)
self.setCanvasBackground(Qt.Qt.white)
self.alignScales()
# Initialize data
self.x = arange(0.0, 100.1, 0.5)
self.y = zeros(len(self.x), Float)
self.z = zeros(len(self.x), Float)
self.setTitle("A Moving QwtPlot Demonstration")
self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend);
self.curveR = Qwt.QwtPlotCurve("Data Moving Right")
self.curveR.attach(self)
self.curveL = Qwt.QwtPlotCurve("Data Moving Left")
self.curveL.attach(self)
self.curveL.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
Qt.QBrush(),
Qt.QPen(Qt.Qt.yellow),
Qt.QSize(7, 7)))
self.curveR.setPen(Qt.QPen(Qt.Qt.red))
self.curveL.setPen(Qt.QPen(Qt.Qt.blue))
mY = Qwt.QwtPlotMarker()
mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop)
mY.setLineStyle(Qwt.QwtPlotMarker.HLine)
mY.setYValue(0.0)
mY.attach(self)
self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time (seconds)")
self.setAxisTitle(Qwt.QwtPlot.yLeft, "Values")
self.startTimer(50)
self.phase = 0.0
# replot
self.replot()
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1122, 649)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("Icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setToolTipDuration(-10)
MainWindow.setDocumentMode(False)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.PrinterProfiles_label = QtWidgets.QLabel(self.centralwidget)
self.PrinterProfiles_label.setGeometry(QtCore.QRect(20, 10, 141, 18))
self.PrinterProfiles_label.setObjectName("PrinterProfiles_label")
self.PrinterProfiles_comboBox = QtWidgets.QComboBox(self.centralwidget)
self.PrinterProfiles_comboBox.setGeometry(QtCore.QRect(50, 35, 120, 30))
self.PrinterProfiles_comboBox.setCurrentText("")
self.PrinterProfiles_comboBox.setObjectName("PrinterProfiles_comboBox")
self.Port_label = QtWidgets.QLabel(self.centralwidget)
self.Port_label.setGeometry(QtCore.QRect(200, 10, 31, 18))
self.Port_label.setObjectName("Port_label")
self.Port_comboBox = QtWidgets.QComboBox(self.centralwidget)
self.Port_comboBox.setGeometry(QtCore.QRect(230, 30, 230, 30))
self.Port_comboBox.setObjectName("Port_comboBox")
self.Baudrate_label = QtWidgets.QLabel(self.centralwidget)
self.Baudrate_label.setGeometry(QtCore.QRect(480, 10, 61, 18))
self.Baudrate_label.setObjectName("Baudrate_label")
self.Baudrate_comboBox = QtWidgets.QComboBox(self.centralwidget)
self.Baudrate_comboBox.setGeometry(QtCore.QRect(510, 30, 100, 30))
self.Baudrate_comboBox.setObjectName("Baudrate_comboBox")
self.Refresh_pushButton = QtWidgets.QPushButton(self.centralwidget)
self.Refresh_pushButton.setGeometry(QtCore.QRect(630, 30, 88, 30))
self.Refresh_pushButton.setObjectName("Refresh_pushButton")
self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.gridLayoutWidget.setGeometry(QtCore.QRect(570, 80, 551, 541))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.graphicsView = QtWidgets.QGraphicsView(self.gridLayoutWidget)
self.graphicsView.setObjectName("graphicsView")
self.gridLayout.addWidget(self.graphicsView, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
demo = SimplePlot(self)
grid.addWidget(demo, 2, 2, 1, 1)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1122, 30))
self.menubar.setObjectName("menubar")
self.menuFiles = QtWidgets.QMenu(self.menubar)
self.menuFiles.setObjectName("menuFiles")
self.menuEdit = QtWidgets.QMenu(self.menubar)
self.menuEdit.setObjectName("menuEdit")
self.menuPrinter_Profiles = QtWidgets.QMenu(self.menuEdit)
self.menuPrinter_Profiles.setObjectName("menuPrinter_Profiles")
self.menuPlastic_Profile = QtWidgets.QMenu(self.menuEdit)
self.menuPlastic_Profile.setObjectName("menuPlastic_Profile")
self.menuSettings = QtWidgets.QMenu(self.menubar)
self.menuSettings.setObjectName("menuSettings")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionQuit = QtWidgets.QAction(MainWindow)
self.actionQuit.setObjectName("actionQuit")
self.actionQuit.triggered.connect(QtWidgets.QApplication.quit)
self.actionNew_PrinterProfile = QtWidgets.QAction(MainWindow)
self.actionNew_PrinterProfile.setObjectName("actionNew_PrinterProfile")
self.actionEdit_PrinterProfile = QtWidgets.QAction(MainWindow)
self.actionEdit_PrinterProfile.setObjectName("actionEdit_PrinterProfile")
self.actionNew_PlasticProfile = QtWidgets.QAction(MainWindow)
self.actionNew_PlasticProfile.setObjectName("actionNew_PlasticProfile")
self.actionEdit_PlasticProfile = QtWidgets.QAction(MainWindow)
self.actionEdit_PlasticProfile.setObjectName("actionEdit_PlasticProfile")
self.actionAbout = QtWidgets.QAction(MainWindow)
self.actionAbout.setObjectName("actionAbout")
self.menuFiles.addAction(self.actionQuit)
self.menuPrinter_Profiles.addAction(self.actionNew_PrinterProfile)
self.menuPrinter_Profiles.addAction(self.actionEdit_PrinterProfile)
self.menuPlastic_Profile.addAction(self.actionNew_PlasticProfile)
self.menuPlastic_Profile.addAction(self.actionEdit_PlasticProfile)
self.menuEdit.addAction(self.menuPrinter_Profiles.menuAction())
self.menuEdit.addAction(self.menuPlastic_Profile.menuAction())
self.menuSettings.addAction(self.actionAbout)
self.menubar.addAction(self.menuFiles.menuAction())
self.menubar.addAction(self.menuEdit.menuAction())
self.menubar.addAction(self.menuSettings.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "CNControl [1.0 - BETA]"))
self.PrinterProfiles_label.setText(_translate("MainWindow", "List of printer profiles:"))
self.PrinterProfiles_comboBox.setStatusTip(_translate("MainWindow", "Slect your printer profile to load the printer settings"))
self.Port_label.setText(_translate("MainWindow", "Port:"))
self.Port_comboBox.setStatusTip(_translate("MainWindow", "Select a prot to connect to the printer"))
self.Baudrate_label.setText(_translate("MainWindow", "Baudrate:"))
self.Baudrate_comboBox.setStatusTip(_translate("MainWindow", "Select the speed of the serial port transfer with your printer (default: 115200)"))
self.Refresh_pushButton.setStatusTip(_translate("MainWindow", "Reload default settings"))
self.Refresh_pushButton.setText(_translate("MainWindow", "Refresh"))
self.menuFiles.setTitle(_translate("MainWindow", "Fi&les"))
self.menuEdit.setTitle(_translate("MainWindow", "E&dit"))
self.menuPrinter_Profiles.setTitle(_translate("MainWindow", "Printer Profiles"))
self.menuPlastic_Profile.setTitle(_translate("MainWindow", "Plastic Profile"))
self.menuSettings.setTitle(_translate("MainWindow", "Tools"))
self.actionQuit.setText(_translate("MainWindow", "Quit"))
self.actionQuit.setStatusTip(_translate("MainWindow", "Quit the application"))
self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
self.actionNew_PrinterProfile.setText(_translate("MainWindow", "New Profile"))
self.actionNew_PrinterProfile.setStatusTip(_translate("MainWindow", "Create a new profile for your printer"))
self.actionEdit_PrinterProfile.setText(_translate("MainWindow", "Edit Profile"))
self.actionEdit_PrinterProfile.setToolTip(_translate("MainWindow", "Edit Profile"))
self.actionEdit_PrinterProfile.setStatusTip(_translate("MainWindow", "Edit an existing printer profile"))
self.actionNew_PlasticProfile.setText(_translate("MainWindow", "New Profile"))
self.actionNew_PlasticProfile.setStatusTip(_translate("MainWindow", "Create a new profile for your plastic"))
self.actionEdit_PlasticProfile.setText(_translate("MainWindow", "Edit Profile"))
self.actionEdit_PlasticProfile.setStatusTip(_translate("MainWindow", "Edit an existing plastic profile"))
self.actionAbout.setText(_translate("MainWindow", "About CNControl"))
self.actionAbout.setStatusTip(_translate("MainWindow", "About the application"))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_()) |
Partager