eric6/MicroPython/MicroPythonGraphWidget.py

changeset 8143
2c730d5fd177
parent 8067
a467ab075be0
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
49 self.__layout.setContentsMargins(2, 2, 2, 2) 49 self.__layout.setContentsMargins(2, 2, 2, 2)
50 self.setLayout(self.__layout) 50 self.setLayout(self.__layout)
51 51
52 self.__chartView = QChartView(self) 52 self.__chartView = QChartView(self)
53 self.__chartView.setSizePolicy( 53 self.__chartView.setSizePolicy(
54 QSizePolicy.Expanding, QSizePolicy.Expanding) 54 QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
55 self.__layout.addWidget(self.__chartView) 55 self.__layout.addWidget(self.__chartView)
56 56
57 self.__verticalLayout = QVBoxLayout() 57 self.__verticalLayout = QVBoxLayout()
58 self.__verticalLayout.setContentsMargins(0, 0, 0, 0) 58 self.__verticalLayout.setContentsMargins(0, 0, 0, 0)
59 self.__layout.addLayout(self.__verticalLayout) 59 self.__layout.addLayout(self.__verticalLayout)
61 self.__saveButton = QToolButton(self) 61 self.__saveButton = QToolButton(self)
62 self.__saveButton.setIcon(UI.PixmapCache.getIcon("fileSave")) 62 self.__saveButton.setIcon(UI.PixmapCache.getIcon("fileSave"))
63 self.__saveButton.setToolTip(self.tr("Press to save the raw data")) 63 self.__saveButton.setToolTip(self.tr("Press to save the raw data"))
64 self.__saveButton.clicked.connect(self.on_saveButton_clicked) 64 self.__saveButton.clicked.connect(self.on_saveButton_clicked)
65 self.__verticalLayout.addWidget(self.__saveButton) 65 self.__verticalLayout.addWidget(self.__saveButton)
66 self.__verticalLayout.setAlignment(self.__saveButton, Qt.AlignHCenter) 66 self.__verticalLayout.setAlignment(self.__saveButton,
67 67 Qt.AlignmentFlag.AlignHCenter)
68 spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum, 68
69 QSizePolicy.Expanding) 69 spacerItem = QSpacerItem(20, 20, QSizePolicy.Policy.Minimum,
70 QSizePolicy.Policy.Expanding)
70 self.__verticalLayout.addItem(spacerItem) 71 self.__verticalLayout.addItem(spacerItem)
71 72
72 label = QLabel(self.tr("max. X:")) 73 label = QLabel(self.tr("max. X:"))
73 self.__verticalLayout.addWidget(label) 74 self.__verticalLayout.addWidget(label)
74 self.__verticalLayout.setAlignment(label, Qt.AlignHCenter) 75 self.__verticalLayout.setAlignment(label,
76 Qt.AlignmentFlag.AlignHCenter)
75 77
76 self.__maxX = 100 78 self.__maxX = 100
77 self.__maxXSpinBox = QSpinBox() 79 self.__maxXSpinBox = QSpinBox()
78 self.__maxXSpinBox.setMinimum(100) 80 self.__maxXSpinBox.setMinimum(100)
79 self.__maxXSpinBox.setMaximum(1000) 81 self.__maxXSpinBox.setMaximum(1000)
80 self.__maxXSpinBox.setSingleStep(100) 82 self.__maxXSpinBox.setSingleStep(100)
81 self.__maxXSpinBox.setToolTip(self.tr( 83 self.__maxXSpinBox.setToolTip(self.tr(
82 "Enter the maximum number of data points to be plotted.")) 84 "Enter the maximum number of data points to be plotted."))
83 self.__maxXSpinBox.setValue(self.__maxX) 85 self.__maxXSpinBox.setValue(self.__maxX)
84 self.__maxXSpinBox.setAlignment(Qt.AlignRight) 86 self.__maxXSpinBox.setAlignment(Qt.AlignmentFlag.AlignRight)
85 self.__verticalLayout.addWidget(self.__maxXSpinBox) 87 self.__verticalLayout.addWidget(self.__maxXSpinBox)
86 88
87 # holds the data to be checked for plotable data 89 # holds the data to be checked for plotable data
88 self.__inputBuffer = [] 90 self.__inputBuffer = []
89 # holds the raw data 91 # holds the raw data
110 self.__axisY.setRange(-self.__maxY, self.__maxY) 112 self.__axisY.setRange(-self.__maxY, self.__maxY)
111 self.__axisY.setLabelFormat("%d") 113 self.__axisY.setLabelFormat("%d")
112 self.__chart.setAxisX(self.__axisX, self.__series[0]) 114 self.__chart.setAxisX(self.__axisX, self.__series[0])
113 self.__chart.setAxisY(self.__axisY, self.__series[0]) 115 self.__chart.setAxisY(self.__axisY, self.__series[0])
114 self.__chartView.setChart(self.__chart) 116 self.__chartView.setChart(self.__chart)
115 self.__chartView.setRenderHint(QPainter.Antialiasing) 117 self.__chartView.setRenderHint(QPainter.RenderHint.Antialiasing)
116 self.preferencesChanged() 118 self.preferencesChanged()
117 119
118 self.__maxXSpinBox.valueChanged.connect(self.__handleMaxXChanged) 120 self.__maxXSpinBox.valueChanged.connect(self.__handleMaxXChanged)
119 121
120 @pyqtSlot() 122 @pyqtSlot()
125 chartColorTheme = Preferences.getMicroPython("ChartColorTheme") 127 chartColorTheme = Preferences.getMicroPython("ChartColorTheme")
126 if chartColorTheme == -1: 128 if chartColorTheme == -1:
127 # automatic selection of light or dark depending on desktop 129 # automatic selection of light or dark depending on desktop
128 # color scheme 130 # color scheme
129 if e5App().usesDarkPalette(): 131 if e5App().usesDarkPalette():
130 self.__chart.setTheme(QChart.ChartThemeDark) 132 self.__chart.setTheme(QChart.ChartTheme.ChartThemeDark)
131 else: 133 else:
132 self.__chart.setTheme(QChart.ChartThemeLight) 134 self.__chart.setTheme(QChart.ChartTheme.ChartThemeLight)
133 else: 135 else:
134 self.__chart.setTheme(chartColorTheme) 136 self.__chart.setTheme(chartColorTheme)
135 137
136 @pyqtSlot(bytes) 138 @pyqtSlot(bytes)
137 def processData(self, data): 139 def processData(self, data):

eric ide

mercurial