irrad_control/gui/widgets/plot_widgets.py
def _setup_widget(self):
        """Setup of the additional widgets to control the appearance and content of the PlotWidget"""

        _sub_layout_1 = QtWidgets.QHBoxLayout()
        _sub_layout_2 = QtWidgets.QHBoxLayout()

        # Create checkboxes in order to show/hide curves in plots
        if hasattr(self.pw, 'show_data') and hasattr(self.pw, 'curves'):
            _sub_layout_1.addWidget(QtWidgets.QLabel('Show curve(s):'))
            all_checkbox = QtWidgets.QCheckBox('All')
            all_checkbox.setFont(_BOLD_FONT)
            all_checkbox.setChecked(True)
            _sub_layout_2.addWidget(all_checkbox)
            for curve in self.pw.curves:
                checkbox = QtWidgets.QCheckBox(curve)
                checkbox.setChecked(True)
                all_checkbox.stateChanged.connect(lambda _, cbx=checkbox: cbx.setChecked(all_checkbox.isChecked()))
                checkbox.stateChanged.connect(lambda v, n=checkbox.text(): self.pw.show_data(n, bool(v)))
                _sub_layout_2.addWidget(checkbox)

        else:
            logging.warning("{} has no 'show_data' method. Please implement it!".format(type(self.pw).__name__))

        _sub_layout_1.addStretch()

        # Whenever x axis is time add spinbox to change time period for which data is shown
        if hasattr(self.pw, 'update_period'):

            # Add horizontal helper line if we're looking at scrolling data plot
            unit = self.pw.plt.getAxis('left').labelUnits or '[?]'
            label = self.pw.plt.getAxis('left').labelText or 'Value'
            self.helper_line = pg.InfiniteLine(angle=0, label=label + ': {value:.2E} ' + unit)
            self.helper_line.setMovable(True)
            self.helper_line.setPen(color='w', style=pg.QtCore.Qt.DashLine, width=2)
            if hasattr(self.pw, 'unitChanged'):
                self.pw.unitChanged.connect(lambda u: setattr(self.helper_line.label, 'format', self.pw.plt.getAxis('left').labelText + ': {value:.2E} ' + u))
                self.pw.unitChanged.connect(self.helper_line.label.valueChanged)
            hl_checkbox = QtWidgets.QCheckBox('Show helper line')
            hl_checkbox.stateChanged.connect(
                lambda v: self.pw.plt.addItem(self.helper_line) if v else self.pw.plt.removeItem(self.helper_line))
            _sub_layout_1.addWidget(hl_checkbox)

            spinbox = QtWidgets.QSpinBox()
            spinbox.setRange(1, 3600)
            spinbox.setValue(self.pw._period)
            spinbox.setPrefix('Time period: ')
            spinbox.setSuffix(' s')
            spinbox.valueChanged.connect(lambda v: self.pw.update_period(v))
            _sub_layout_1.addWidget(spinbox)

        # Button to move self.pw to PlotWindow instance
        self.btn_open = QtWidgets.QPushButton()
        self.btn_open.setIcon(self.btn_open.style().standardIcon(QtWidgets.QStyle.SP_TitleBarMaxButton))
        self.btn_open.setToolTip('Open plot in window')
        self.btn_open.setFixedSize(25, 25)
        self.btn_open.clicked.connect(self.move_to_win)
        self.btn_open.clicked.connect(lambda: self.layout().insertStretch(1))
        self.btn_open.clicked.connect(lambda: self.btn_open.setEnabled(False))
        self.btn_open.clicked.connect(lambda: self.btn_close.setEnabled(True))

        # Button to close self.pw to PlotWindow instance
        self.btn_close = QtWidgets.QPushButton()
        self.btn_close.setIcon(self.btn_open.style().standardIcon(QtWidgets.QStyle.SP_TitleBarCloseButton))
        self.btn_close.setToolTip('Close plot in window')
        self.btn_close.setFixedSize(25, 25)
        self.btn_close.setEnabled(False)
        self.btn_close.clicked.connect(lambda: self.btn_close.setEnabled(False))
        self.btn_close.clicked.connect(lambda: self.external_win.close())

        _sub_layout_1.addWidget(self.btn_open)
        _sub_layout_1.addWidget(self.btn_close)

        self.sub_layout.addLayout(_sub_layout_1)
        self.sub_layout.addLayout(_sub_layout_2)
        
        # Insert everything into main layout
        self.layout().insertLayout(0, self.sub_layout)
        self.layout().insertWidget(1, self.pw)
Setup of the additional widgets to control the appearance and content of the PlotWidget
Setup of the additional widgets to control the appearance and content of the PlotWidget
Setup of the additional widgets to control the appearance and content of the PlotWidget
def _setup_widget(self):
        _sub_layout_1 = QtWidgets.QHBoxLayout()
        _sub_layout_2 = QtWidgets.QHBoxLayout()
        if hasattr(self.pw, 'show_data') and hasattr(self.pw, 'curves'):
            _sub_layout_1.addWidget(QtWidgets.QLabel('Show curve(s):'))
            all_checkbox = QtWidgets.QCheckBox('All')
            all_checkbox.setFont(_BOLD_FONT)
            all_checkbox.setChecked(True)
            _sub_layout_2.addWidget(all_checkbox)
            for curve in self.pw.curves:
                checkbox = QtWidgets.QCheckBox(curve)
                checkbox.setChecked(True)
                all_checkbox.stateChanged.connect(lambda _, cbx=checkbox: cbx.setChecked(all_checkbox.isChecked()))
                checkbox.stateChanged.connect(lambda v, n=checkbox.text(): self.pw.show_data(n, bool(v)))
                _sub_layout_2.addWidget(checkbox)
        else:
            logging.warning("{} has no 'show_data' method. Please implement it!".format(type(self.pw).__name__))
        _sub_layout_1.addStretch()
        if hasattr(self.pw, 'update_period'):
            unit = self.pw.plt.getAxis('left').labelUnits or '[?]'
            label = self.pw.plt.getAxis('left').labelText or 'Value'
            self.helper_line = pg.InfiniteLine(angle=0, label=label + ': {value:.2E} ' + unit)
            self.helper_line.setMovable(True)
            self.helper_line.setPen(color='w', style=pg.QtCore.Qt.DashLine, width=2)
            if hasattr(self.pw, 'unitChanged'):
                self.pw.unitChanged.connect(lambda u: setattr(self.helper_line.label, 'format', self.pw.plt.getAxis('left').labelText + ': {value:.2E} ' + u))
                self.pw.unitChanged.connect(self.helper_line.label.valueChanged)
            hl_checkbox = QtWidgets.QCheckBox('Show helper line')
            hl_checkbox.stateChanged.connect(
                lambda v: self.pw.plt.addItem(self.helper_line) if v else self.pw.plt.removeItem(self.helper_line))
            _sub_layout_1.addWidget(hl_checkbox)
            spinbox = QtWidgets.QSpinBox()
            spinbox.setRange(1, 3600)
            spinbox.setValue(self.pw._period)
            spinbox.setPrefix('Time period: ')
            spinbox.setSuffix(' s')
            spinbox.valueChanged.connect(lambda v: self.pw.update_period(v))
            _sub_layout_1.addWidget(spinbox)
        self.btn_open = QtWidgets.QPushButton()
        self.btn_open.setIcon(self.btn_open.style().standardIcon(QtWidgets.QStyle.SP_TitleBarMaxButton))
        self.btn_open.setToolTip('Open plot in window')
        self.btn_open.setFixedSize(25, 25)
        self.btn_open.clicked.connect(self.move_to_win)
        self.btn_open.clicked.connect(lambda: self.layout().insertStretch(1))
        self.btn_open.clicked.connect(lambda: self.btn_open.setEnabled(False))
        self.btn_open.clicked.connect(lambda: self.btn_close.setEnabled(True))
        self.btn_close = QtWidgets.QPushButton()
        self.btn_close.setIcon(self.btn_open.style().standardIcon(QtWidgets.QStyle.SP_TitleBarCloseButton))
        self.btn_close.setToolTip('Close plot in window')
        self.btn_close.setFixedSize(25, 25)
        self.btn_close.setEnabled(False)
        self.btn_close.clicked.connect(lambda: self.btn_close.setEnabled(False))
        self.btn_close.clicked.connect(lambda: self.external_win.close())
        _sub_layout_1.addWidget(self.btn_open)
        _sub_layout_1.addWidget(self.btn_close)
        self.sub_layout.addLayout(_sub_layout_1)
        self.sub_layout.addLayout(_sub_layout_2)
        self.layout().insertLayout(0, self.sub_layout)
        self.layout().insertWidget(1, self.pw)
def _setup_widget ( self ) : _sub_layout_1 = QtWidgets . QHBoxLayout ( ) _sub_layout_2 = QtWidgets . QHBoxLayout ( ) if hasattr ( self . pw , 'show_data' ) and hasattr ( self . pw , 'curves' ) : _sub_layout_1 . addWidget ( QtWidgets . QLabel ( 'Show curve(s):' ) ) all_checkbox = QtWidgets . QCheckBox ( 'All' ) all_checkbox . setFont ( _BOLD_FONT ) all_checkbox . setChecked ( True ) _sub_layout_2 . addWidget ( all_checkbox ) for curve in self . pw . curves : checkbox = QtWidgets . QCheckBox ( curve ) checkbox . setChecked ( True ) all_checkbox . stateChanged . connect ( lambda _ , cbx = checkbox : cbx . setChecked ( all_checkbox . isChecked ( ) ) ) checkbox . stateChanged . connect ( lambda v , n = checkbox . text ( ) : self . pw . show_data ( n , bool ( v ) ) ) _sub_layout_2 . addWidget ( checkbox ) else : logging . warning ( "{} has no 'show_data' method. Please implement it!" . format ( type ( self . pw ) . __name__ ) ) _sub_layout_1 . addStretch ( ) if hasattr ( self . pw , 'update_period' ) : unit = self . pw . plt . getAxis ( 'left' ) . labelUnits or '[?]' label = self . pw . plt . getAxis ( 'left' ) . labelText or 'Value' self . helper_line = pg . InfiniteLine ( angle = 0 , label = label + ': {value:.2E} ' + unit ) self . helper_line . setMovable ( True ) self . helper_line . setPen ( color = 'w' , style = pg . QtCore . Qt . DashLine , width = 2 ) if hasattr ( self . pw , 'unitChanged' ) : self . pw . unitChanged . connect ( lambda u : setattr ( self . helper_line . label , 'format' , self . pw . plt . getAxis ( 'left' ) . labelText + ': {value:.2E} ' + u ) ) self . pw . unitChanged . connect ( self . helper_line . label . valueChanged ) hl_checkbox = QtWidgets . QCheckBox ( 'Show helper line' ) hl_checkbox . stateChanged . connect ( lambda v : self . pw . plt . addItem ( self . helper_line ) if v else self . pw . plt . removeItem ( self . helper_line ) ) _sub_layout_1 . addWidget ( hl_checkbox ) spinbox = QtWidgets . QSpinBox ( ) spinbox . setRange ( 1 , 3600 ) spinbox . setValue ( self . pw . _period ) spinbox . setPrefix ( 'Time period: ' ) spinbox . setSuffix ( ' s' ) spinbox . valueChanged . connect ( lambda v : self . pw . update_period ( v ) ) _sub_layout_1 . addWidget ( spinbox ) self . btn_open = QtWidgets . QPushButton ( ) self . btn_open . setIcon ( self . btn_open . style ( ) . standardIcon ( QtWidgets . QStyle . SP_TitleBarMaxButton ) ) self . btn_open . setToolTip ( 'Open plot in window' ) self . btn_open . setFixedSize ( 25 , 25 ) self . btn_open . clicked . connect ( self . move_to_win ) self . btn_open . clicked . connect ( lambda : self . layout ( ) . insertStretch ( 1 ) ) self . btn_open . clicked . connect ( lambda : self . btn_open . setEnabled ( False ) ) self . btn_open . clicked . connect ( lambda : self . btn_close . setEnabled ( True ) ) self . btn_close = QtWidgets . QPushButton ( ) self . btn_close . setIcon ( self . btn_open . style ( ) . standardIcon ( QtWidgets . QStyle . SP_TitleBarCloseButton ) ) self . btn_close . setToolTip ( 'Close plot in window' ) self . btn_close . setFixedSize ( 25 , 25 ) self . btn_close . setEnabled ( False ) self . btn_close . clicked . connect ( lambda : self . btn_close . setEnabled ( False ) ) self . btn_close . clicked . connect ( lambda : self . external_win . close ( ) ) _sub_layout_1 . addWidget ( self . btn_open ) _sub_layout_1 . addWidget ( self . btn_close ) self . sub_layout . addLayout ( _sub_layout_1 ) self . sub_layout . addLayout ( _sub_layout_2 ) self . layout ( ) . insertLayout ( 0 , self . sub_layout ) self . layout ( ) . insertWidget ( 1 , self . pw )
Setup of the additional widgets to control the appearance and content of the PlotWidget
Setup of the additional widgets to control the appearance and content of the PlotWidget
"""Setup of the additional widgets to control the appearance and content of the PlotWidget""" # Create checkboxes in order to show/hide curves in plots # Whenever x axis is time add spinbox to change time period for which data is shown # Add horizontal helper line if we're looking at scrolling data plot # Button to move self.pw to PlotWindow instance # Button to close self.pw to PlotWindow instance # Insert everything into main layout
self