0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

feat: changed from PlotItem to GraphicsLayoutWidget, added LabelItem

This commit is contained in:
wyzula-jan
2023-08-04 16:32:50 +02:00
parent 2abbc2e408
commit 075cc79d6f
2 changed files with 18 additions and 7 deletions

View File

@ -52,8 +52,17 @@ class BasicPlot(QtWidgets.QWidget):
color_list = ["#384c6b", "#e28a2b", "#5E3023", "#e41a1c", "#984e83", "#4daf4a"]
color_list = BasicPlot.golden_angle_color(colormap="CET-R2", num=len(self.y_value_list))
# setup plots
self.plot = self.plot_window.getPlotItem()
# setup plots - GraphicsLayoutWidget
# LabelItem
self.label = pg.LabelItem(justify="center")
self.glw.addItem(self.label)
self.label.setText("test label")
# PlotItem
self.glw.nextRow()
self.plot = pg.PlotItem()
self.glw.addItem(self.plot)
for ii in range(len(self.y_value_list)):
pen = mkPen(color=color_list[ii], width=2, style=QtCore.Qt.DashLine)
brush = mkBrush(color=color_list[ii])
@ -64,7 +73,9 @@ class BasicPlot(QtWidgets.QWidget):
self.brushs.append(brush)
self.crosshair_v = pg.InfiniteLine(angle=90, movable=False)
self.crosshair_h = pg.InfiniteLine(angle=0, movable=False)
self.plot.addItem(self.crosshair_v, ignoreBounds=True)
self.plot.addItem(self.crosshair_h, ignoreBounds=True)
# Add textItems
self.add_text_items()
@ -95,6 +106,7 @@ class BasicPlot(QtWidgets.QWidget):
return
mousePoint = self.plot.vb.mapSceneToView(pos)
self.crosshair_v.setPos(mousePoint.x())
self.crosshair_h.setPos(mousePoint.y())
if not self.plotter_data_x:
return
self.mouse_box_data.setText("Mouse cursor")

View File

@ -22,7 +22,7 @@ border-color: rgb(166, 166, 166);</string>
</property>
<layout class="QHBoxLayout" name="layout_2">
<item>
<widget class="PlotWidget" name="plot_window" native="true"/>
<widget class="GraphicsLayoutWidget" name="glw"/>
</item>
<item>
<spacer name="Spacer">
@ -57,10 +57,9 @@ border-color: rgb(166, 166, 166);</string>
</widget>
<customwidgets>
<customwidget>
<class>PlotWidget</class>
<extends>QWidget</extends>
<header>pyqtgraph</header>
<container>1</container>
<class>GraphicsLayoutWidget</class>
<extends>QGraphicsView</extends>
<header>pyqtgraph.h</header>
</customwidget>
</customwidgets>
<resources/>