Esempio n. 1
0
    def initToolbar(self):
        toolbar = QtGui.QToolBar()

        self.foregroundColorButton = pg.ColorButton(color=(255, 255, 255))
        self.foregroundColorButton.sigColorChanged.connect(self.updateCurve)
        self.foregroundColorButton.setToolTip(self.tr("Line color"))
        toolbar.addWidget(self.foregroundColorButton)

        self.backgroundColorButton = pg.ColorButton(color=(0, 0, 0))
        self.backgroundColorButton.sigColorChanged.connect(self.updateBgColor)
        self.backgroundColorButton.setToolTip(self.tr("Background color"))
        toolbar.addWidget(self.backgroundColorButton)

        self.lineWidthSpinBox = QtGui.QDoubleSpinBox()
        self.lineWidthSpinBox.setRange(0, 10)
        self.lineWidthSpinBox.setValue(1)
        self.lineWidthSpinBox.setDecimals(1)
        self.lineWidthSpinBox.setSingleStep(1)
        self.lineWidthSpinBox.valueChanged.connect(self.updateCurve)
        self.lineWidthSpinBox.setToolTip(self.tr("Line width"))
        toolbar.addWidget(self.lineWidthSpinBox)

        toolbar.addSeparator()

        self.selectDataAction = toolbar.addAction(
            QtGui.QIcon.fromTheme('x-office-spreadsheet'),
            self.tr("Import data"),
            self.importData)

        self.dataFgColorButton = pg.ColorButton(color=(0, 255, 0))
        self.dataFgColorButton.sigColorChanged.connect(self.updateDataCurve)
        self.dataFgColorButton.setToolTip(self.tr("Imported data color"))
        self.dataFgColorButton.setEnabled(False)
        toolbar.addWidget(self.dataFgColorButton)

        self.dataLwSpinBox = QtGui.QDoubleSpinBox()
        self.dataLwSpinBox.setRange(0, 10)
        self.dataLwSpinBox.setValue(2)
        self.dataLwSpinBox.setDecimals(1)
        self.dataLwSpinBox.setSingleStep(1)
        self.dataLwSpinBox.valueChanged.connect(self.updateDataCurve)
        self.dataLwSpinBox.setToolTip(self.tr("Imported data line width"))
        self.dataLwSpinBox.setEnabled(False)
        toolbar.addWidget(self.dataLwSpinBox)

        self.deleteDataAction = toolbar.addAction(
            QtGui.QIcon.fromTheme('edit-delete'),
            self.tr("Delete data"),
            self.deleteData)
        self.deleteDataAction.setEnabled(False)

        return toolbar
Esempio n. 2
0
 def resetPlotSetup(self):
     try:
         self.plotSetupTableWidget.cellChanged.disconnect()
     except:
         pass
     columns=self.data['data'].columns.tolist()
     self.xlabel=[]
     self.ylabel=[]
     for row in range(self.plotSetupTableWidget.rowCount()):
         for i in range(1,3):
             self.plotSetupTableWidget.cellWidget(row,i).currentIndexChanged.disconnect()
             self.plotSetupTableWidget.cellWidget(row,i).clear()
             self.plotSetupTableWidget.cellWidget(row,i).addItems(columns)
             self.plotSetupTableWidget.cellWidget(row,i).setCurrentIndex(i-1)
             self.plotSetupTableWidget.cellWidget(row,i).currentIndexChanged.connect(self.updateCellData)
         self.xlabel.append('[%s]'%self.plotSetupTableWidget.cellWidget(row,1).currentText())
         self.ylabel.append('[%s]'%self.plotSetupTableWidget.cellWidget(row,2).currentText())
         self.plotSetupTableWidget.cellWidget(row,3).currentIndexChanged.disconnect()
         self.plotSetupTableWidget.cellWidget(row,3).clear()
         self.plotSetupTableWidget.cellWidget(row,3).addItems(['None']+columns)
         self.plotSetupTableWidget.cellWidget(row,3).setCurrentIndex(0)
         self.plotSetupTableWidget.cellWidget(row,3).currentIndexChanged.connect(self.updateCellData)
         self.plotSetupTableWidget.setCurrentCell(row,3)
         color=self.plotSetupTableWidget.cellWidget(row,4).color()
         self.plotSetupTableWidget.setCellWidget(row, 4, pg.ColorButton(color=color))
         self.plotSetupTableWidget.cellWidget(row, 4).sigColorChanging.connect(self.updateCellData)
         self.plotSetupTableWidget.cellWidget(row, 4).sigColorChanged.connect(self.updateCellData)
         self.updatePlotData(row,i)
     self.plotSetupTableWidget.cellChanged.connect(self.updatePlotData)         
Esempio n. 3
0
def setup_cb(ui: Ui_PythIon):
    cb = pg.ColorButton(ui.scatter_plot, color=(0, 0, 255, 50))
    cb.setFixedHeight(30)
    cb.setFixedWidth(30)
    cb.move(0, 210)
    cb.show()
    return cb
Esempio n. 4
0
    def __init__(self, name, **kwargs):
        terminals = {'view': {'io': 'in'}, 'level': {'io': 'out'}}

        super().__init__(name, terminals=terminals, **kwargs)

        self.view = None

        self.iso = pg.IsocurveItem(level=0.5, pen='g')
        self.iso.setZValue(5)

        self.isoLine = pg.InfiniteLine(angle=0, movable=True, pen='g')
        self.isoLine.setValue(0.5)
        self.isoLine.setZValue(1000)

        self.isoLine.sigDragged.connect(self.updateIsocurve)

        self.panel = QWidget()
        self.panelLayout = QGridLayout(self.panel)

        self.colorButton = pg.ColorButton(self.panel)
        self.panelLayout.addWidget(self.colorButton, 1, 1)

        self.visibleCheckBox = QCheckBox('Visible', self.panel)
        self.visibleCheckBox.setChecked(True)
        self.panelLayout.addWidget(self.visibleCheckBox, 1, 2)

        self.panel.setLayout(self.panelLayout)

        self.visibleCheckBox.toggled.connect(self.setVisible)
        self.colorButton.sigColorChanged.connect(self.setIsoColor)
Esempio n. 5
0
    def __init__(self, name, plotViewer, color=None):
        super().__init__(name)

        self.plotViewer = plotViewer
        self.plot = Graph.Graph(name=name,
                                clipToView=True,
                                downsampleMethod="subsample")

        self.color = color

        self.plotViewer.plt.addItem(self.plot)

        self.optionWidget = uic.loadUi(
            Config.getResource("ui/plotSettings.ui"))

        self.colorButton = pg.ColorButton(color=self.color)
        self.colorButton.sigColorChanged.connect(
            lambda val: self.applyChange("color", val.color()))
        self.optionWidget.colorBtnLayout.addWidget(self.colorButton)

        self.optionWidget.btnBg.clicked.connect(
            lambda: self.changeIndex.emit("BG", self.plot))
        self.optionWidget.btnBack.clicked.connect(
            lambda: self.changeIndex.emit("BACK", self.plot))
        self.optionWidget.btnFor.clicked.connect(
            lambda: self.changeIndex.emit("FOR", self.plot))
        self.optionWidget.btnFg.clicked.connect(
            lambda: self.changeIndex.emit("FG", self.plot))

        self.applyChange("color", self.color)
Esempio n. 6
0
    def __init__(self, *args, **kwargs):
        super(DownCtrl, self).__init__(*args, **kwargs)

        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)

        # MODE SELECTOR
        modeSelector = QtGui.QComboBox()
        modeSelector.addItem('Black')
        modeSelector.addItem('None')
        modeSelector.addItem('Features')
        modeSelector.addItem('Labels')
        modeSelector.addItem('Probabilities')
        self.layout.addWidget(modeSelector)

        # color change button
        self.colorChangeButton = pg.ColorButton('Edge Color')
        self.layout.addWidget(self.colorChangeButton)

        # Edge Size Slide
        self.brushSizeSlider = QtGui.QSlider(orientation=QtCore.Qt.Horizontal)
        self.layout.addWidget(self.brushSizeSlider)

        # Save load LABELS
        self.saveLabelsButton = QtGui.QPushButton('save Labels')
        self.layout.addWidget(self.saveLabelsButton)
        self.loadLabelsButton = QtGui.QPushButton('load Labels')
        self.layout.addWidget(self.loadLabelsButton)
    def add_elements(self, checked=[]):
        '''Add element checkboxes and set as checked if in checked.'''
        for idx, el in enumerate(self.elements):
            elbox = QtGui.QCheckBox(el)
            elbox.setChecked(el in checked)
            elbox.stateChanged.connect(self.handle_element_select)
            self.el_sel.layout().addWidget(elbox, idx, 0)
            clrbtn = pg.ColorButton()
            clrbtn.setObjectName(el)
            clrbtn.sigColorChanged.connect(self.handle_element_select)
            self.el_sel.layout().addWidget(clrbtn, idx, 1)
            pvbox = QtGui.QCheckBox()
            pvbox.stateChanged.connect(self.handle_element_select)
            self.el_sel.layout().addWidget(pvbox, idx, 2)

        # Position/velocity dimension selector.
        cb = QtGui.QComboBox()
        cb.addItem('y')
        cb.addItem('x')
        cb.currentIndexChanged.connect(self.handle_element_select)
        self.el_sel.layout().addWidget(cb)
        self.pos_vel_dim_cb = cb
        xyzcb = QtGui.QComboBox()
        xyzcb.setObjectName('xyz_map')
        xyzcb.addItem('xyz')
        xyzcb.addItem('xzy')
        xyzcb.addItem('yxz')
        xyzcb.addItem('yzx')
        xyzcb.addItem('zxy')
        xyzcb.addItem('zyx')
        xyzcb.currentIndexChanged.connect(self.handle_xyz_map_select)
        self.el_sel.layout().addWidget(xyzcb)
        self.xyz_cb = xyzcb
 def create_color_button(self, ch, ch_layout):
     """Create color button to change the color of the line"""
     color_btn = pg.ColorButton()
     color_btn.setMaximumWidth(17)
     color_btn.setToolTip('Click to change the color of the line')
     color_btn.sigColorChanged.connect(partial(self.change_line_color, ch))
     color_btn.setMaximumHeight(17)
     ch_layout.addWidget(color_btn, 3, 8)
Esempio n. 9
0
 def create(self):
     for i in range(self.num):
         self.comp[i] = pg.ColorButton(self.parent)
         self.comp[i].setFixedSize(30, 30)
         self.comp[i].setColor(color=self.colors[i])
         self.comp[i].sigColorChanged.connect(partial(self.setColor,
                                                      comp=i))
         self.addWidget(self.comp[i])
     self.addStretch(1)
Esempio n. 10
0
 def __init__(self, param, depth):
     WidgetParameterItem.__init__(self, param, depth)
     layout = self.layoutWidget.layout()
     if depth == 1:
         # color defaults to red if not set in opts
         color = param.opts['color'] if 'color' in param.opts else (255, 0,
                                                                    0, 255)
         self.colorBtn = pg.ColorButton(self.treeWidget(), color)
         layout.insertWidget(0, self.colorBtn)
         self.colorBtn.clicked.disconnect()
         self.colorBtn.clicked.connect(self.colorChange)
         self.colorBtn.setMaximumWidth(30)
Esempio n. 11
0
 def selectionBox(self):
     self.selectionBoxlayout = QHBoxLayout()
     widget = QtGui.QWidget()
     combo1 = signalTypeComboBox(0, self)
     combo2 = signalElementComboBox(0, self)
     combo3 = signalPVComboBox(0, self)
     combo4 = signalRateComboBox(0, self)
     self.addButton = QPushButton('Add Signal')
     self.addButton.setFixedWidth(100)
     self.addButton.clicked.connect(self.addTableRow)
     combo1.addItems(('Off', 'Quads', 'Dipoles', 'Correctors', 'BPMs'))
     combo2.addItems(magnets['Off']['Names'])
     combo3.addItems(magnets['Off']['PVs'].keys())
     combo4.addItems(
         [i + ' Hz' for i in ('1', '5', '10', '25', '50', '100')])
     combo1.setEditable(True)
     combo1.lineEdit().setReadOnly(True)
     combo1.lineEdit().setAlignment(Qt.AlignCenter)
     combo1.setMinimumWidth(80)
     combo1.setMaximumWidth(100)
     combo2.setEditable(True)
     combo2.lineEdit().setReadOnly(True)
     combo2.lineEdit().setAlignment(Qt.AlignCenter)
     combo2.setMinimumWidth(80)
     combo2.setMaximumWidth(100)
     combo3.setEditable(True)
     combo3.lineEdit().setReadOnly(True)
     combo3.lineEdit().setAlignment(Qt.AlignCenter)
     combo3.setMinimumWidth(80)
     combo3.setMaximumWidth(100)
     combo4.setEditable(True)
     combo4.lineEdit().setReadOnly(True)
     combo4.lineEdit().setAlignment(Qt.AlignCenter)
     combo4.setCurrentIndex(2)
     combo4.setMinimumWidth(80)
     combo4.setMaximumWidth(100)
     self.colorbox = pg.ColorButton()
     self.colorbox.setMinimumWidth(60)
     self.colorbox.setMaximumWidth(80)
     self.colorbox.setFlat(True)
     if (self.rowNumber < 0):
         self.colorbox.setColor(self.penColors[0])
     else:
         self.colorbox.setColor(self.penColors[self.rowNumber])
     self.selectionBoxlayout.addWidget(combo1, 2)
     self.selectionBoxlayout.addWidget(combo2, 3)
     self.selectionBoxlayout.addWidget(combo3, 2)
     self.selectionBoxlayout.addWidget(combo4, 1)
     self.selectionBoxlayout.addWidget(self.colorbox, 1)
     self.selectionBoxlayout.addWidget(self.addButton, 1)
     widget.setLayout(self.selectionBoxlayout)
     widget.setMaximumHeight(100)
     return widget
Esempio n. 12
0
 def addLegendItem(self, name):
     parentTreeWidget = QtGui.QTreeWidgetItem([name])
     self.layout.addTopLevelItem(parentTreeWidget)
     plotOnOff = QCheckBox()
     plotOnOff.setChecked(True)
     plotOnOff.toggled.connect(lambda x: self.togglePlotOnOff(name, x))
     self.addTreeWidget(parentTreeWidget, name, "Plot On?", plotOnOff)
     signalRate = QComboBox()
     signalRate.setFixedSize(80,25)
     signalRate.setStyleSheet("subcontrol-origin: padding;\
     subcontrol-position: top right;\
     width: 15px;\
     border-left-width: 0px;\
     border-left-color: darkgray;\
     border-left-style: solid;\
     border-top-right-radius: 3px; /* same radius as the QComboBox */\
     border-bottom-right-radius: 3px;\
      ")
     i = 0
     selected = 0
     for rate in [0.1,1,5,10,25,50,100]:
         signalRate.addItem(str(rate)+' Hz')
         if self.records[name]['timer'] == 1.0/rate:
             selected = i
         i += 1
     signalRate.setCurrentIndex(selected)
     signalRate.currentIndexChanged.connect(lambda x: self.changeSampleRate(name, signalRate))
     self.addTreeWidget(parentTreeWidget, name, "Signal Rate", signalRate)
     colorbox = pg.ColorButton()
     colorbox.setFixedSize(30,25)
     colorbox.setFlat(True)
     colorbox.setColor(self.records[name]['pen'])
     colorbox.sigColorChanged.connect(lambda x: self.changePenColor(name, x))
     colorbox.sigColorChanging.connect(lambda x: self.changePenColor(name, x))
     self.addTreeWidget(parentTreeWidget, name, "Plot Color", colorbox)
     saveButton = QPushButton('Save Data')
     saveButton.setFixedSize(74,20)
     saveButton.setFlat(True)
     saveButton.clicked.connect(lambda x: self.saveCurve(name))
     self.addTreeWidget(parentTreeWidget, name, "Save Signal", saveButton)
     resetButton = QPushButton('Clear')
     resetButton.setFixedSize(50,20)
     resetButton.setFlat(True)
     resetButton.clicked.connect(lambda x: self.clearCurve(name))
     self.addTreeWidget(parentTreeWidget, name, "Clear Signal", resetButton)
     deleteRowButton = QPushButton()
     deleteRowButton.setFixedSize(50,20)
     deleteRowButton.setFlat(True)
     deleteRowButton.setIcon(self.deleteIcon)
     deleteRowChild = self.addTreeWidget(parentTreeWidget, name, "Delete Signal", deleteRowButton)
     deleteRowButton.clicked.connect(lambda x: self.deleteRow(name, deleteRowChild))
     self.newRowNumber += 1
Esempio n. 13
0
 def addPlots(self,plotIndex=None,color=None):
     #self.plotSetupTableWidget.clear()
     # if self.parentWidget() is None or self.plotSetupTableWidget.rowCount()==0:
     try:
         self.plotSetupTableWidget.cellChanged.disconnect()
     except:
         pass
     columns=self.data['data'].columns.tolist()
     if len(columns)>=2:
         self.plotSetupTableWidget.insertRow(self.plotSetupTableWidget.rowCount())
         row=self.plotSetupTableWidget.rowCount()-1
         self.plotSetupTableWidget.setItem(row,0,QTableWidgetItem('Data_%d'%self.plotNum))
         for i in range(1,3):
             self.plotSetupTableWidget.setCellWidget(row,i,QComboBox())
             self.plotSetupTableWidget.cellWidget(row,i).addItems(columns)
             if plotIndex is not None:
                 self.plotSetupTableWidget.cellWidget(row,i).setCurrentIndex(plotIndex[i-1])
             else:
                 self.plotSetupTableWidget.cellWidget(row,i).setCurrentIndex(i-1)
             self.plotSetupTableWidget.cellWidget(row,i).currentIndexChanged.connect(self.updateCellData)
         self.xlabel.append('[%s]'%self.plotSetupTableWidget.cellWidget(row,1).currentText())
         self.ylabel.append('[%s]'%self.plotSetupTableWidget.cellWidget(row,2).currentText())
         self.plotSetupTableWidget.setCellWidget(row,3,QComboBox())
         self.plotSetupTableWidget.cellWidget(row,3).addItems(['None']+columns)
         if color is None:
             color=next(self.colcycler)#array([random.randint(200, high=255),0,0])
         self.plotSetupTableWidget.setCellWidget(row, 4,pg.ColorButton(color=color))
         self.plotSetupTableWidget.cellWidget(row, 4).sigColorChanging.connect(self.updateCellData)
         self.plotSetupTableWidget.cellWidget(row, 4).sigColorChanged.connect(self.updateCellData)
         if plotIndex is not None:
                 self.plotSetupTableWidget.cellWidget(row,3).setCurrentIndex(plotIndex[-1])
         else:
             # try:
             #     self.plotSetupTableWidget.cellWidget(row,3).setCurrentIndex(2)
             # except:
             #
             if len(columns)>2:
                 self.plotSetupTableWidget.cellWidget(row,3).setCurrentIndex(3)
             else:
                 self.plotSetupTableWidget.cellWidget(row,3).setCurrentIndex(0)
         self.plotSetupTableWidget.cellWidget(row,3).currentIndexChanged.connect(self.updateCellData)
         self.plotSetupTableWidget.setCurrentCell(row,3)
         self.updatePlotData(row,3)
         self.plotNum+=1
     else:
         QMessageBox.warning(self,'Data file error','The data file do not have two or more columns to be plotted.',QMessageBox.Ok)
     self.plotSetupTableWidget.cellChanged.connect(self.updatePlotData)
Esempio n. 14
0
    def __init__(self, pwin, parent=None):
        super().__init__(parent)

        self.pwin = pwin
        self.__quiver = []

        self.setTitle(self.tr("Polarization (Quiver)"))
        self.setCheckable(True)
        self.setChecked(False)

        layout = QtGui.QFormLayout()

        glabel = QtGui.QLabel(self.tr("Grid Size"))
        self.grid = QtGui.QSpinBox()
        self.grid.setRange(5, 100)
        self.grid.setValue(10)
        self.grid.valueChanged.connect(self.updateGrid)
        glabel.setBuddy(self.grid)
        layout.addRow(glabel, self.grid)

        clabel = QtGui.QLabel(self.tr("Color"))
        self.color = pg.ColorButton(color=(85, 170, 255))
        self.color.sigColorChanging.connect(self.setColor)
        clabel.setBuddy(self.color)
        layout.addRow(clabel, self.color)

        alabel = QtGui.QLabel(self.tr("Arrow Length"))
        self.arrow = QtGui.QSpinBox()
        self.arrow.setRange(2, 100)
        self.arrow.setSingleStep(5)
        self.arrow.setValue(40)
        self.arrow.valueChanged.connect(self.updateArrows)
        alabel.setBuddy(self.arrow)
        layout.addRow(alabel, self.arrow)

        hlabel = QtGui.QLabel(self.tr("Head Length"))
        self.head = QtGui.QSpinBox()
        self.head.setRange(0, 100)
        self.head.setSingleStep(5)
        self.head.setValue(40)
        self.head.setSuffix(" %")
        self.head.valueChanged.connect(self.updateArrows)
        hlabel.setBuddy(self.head)
        layout.addRow(hlabel, self.head)

        self.toggled.connect(self.toggleQuiver)
        self.setLayout(layout)
Esempio n. 15
0
    def __init__(self):
        TemplateBaseClass.__init__(self)
        
        # Create the main window
        self.ui = WindowTemplate()
        self.ui.setupUi(self)
        self.ui.Res_comboBox.addItems(["0.004","0.008","0.016","0.032","0.064","0.128","0.256","0.512"])
        self.ui.FittingFunc_comboBox.addItems(["Stretched Exponential","Double Exponential", "Single Exponential"])
        self.ui.FittingMethod_comboBox.addItems(["diff_ev", "fmin_tnc"])
        
        #set up file menu
        self.ui.actionOpen.triggered.connect(self.open_file)
        self.ui.actionOpen_IRF_File.triggered.connect(self.open_irf_file)
        self.ui.actionSave.triggered.connect(self.save_file)
        self.ui.actionExit.triggered.connect(self.close_application)
        
        #set up ui signals
        self.ui.plot_pushButton.clicked.connect(self.plot)
        self.ui.fit_pushButton.clicked.connect(self.call_fit_and_plot)
        self.ui.clear_pushButton.clicked.connect(self.clear_plot)
        self.ui.export_plot_pushButton.clicked.connect(self.pub_ready_plot_export)
        self.ui.calculate_srv_pushButton.clicked.connect(self.calculate_srv)

        self.ui.log_checkBox.stateChanged.connect(self.make_semilog)
        self.ui.fit_with_irf_checkBox.stateChanged.connect(self.switch_fit_settings)
        self.ui.FittingFunc_comboBox.currentTextChanged.connect(self.switch_function_tab)
        self.ui.FittingMethod_comboBox.currentTextChanged.connect(self.switch_init_params_groupBox)
        self.ui.separate_irf_checkBox.stateChanged.connect(self.switch_open_irf)
        self.ui.export_data_pushButton.clicked.connect(self.export_data)
        self.ui.clear_export_data_pushButton.clicked.connect(self.clear_export_data)

        #set up plot color button
        self.plot_color_button = pg.ColorButton(color=(255,0,0))
        self.ui.plot_color_button_container.layout().addWidget(self.plot_color_button)
        self.plot_color = self.plot_color_button.color()
        self.plot_color_button.sigColorChanged.connect(self.plot_color_changed)

        self.file = None
        self.out = None # output file after fitting
        self.data_list = []

        #variables accounting for data received from FLIM analysis
        self.opened_from_flim = False #switched to True in FLIM_plot when "analyze lifetime" clicked
        self.hist_data_from_flim = [] #container for flim roi data

        self.show()
Esempio n. 16
0
    def __init__(self, parent=None, **kwargs):
        super(AppWindow, self).__init__(parent)
        self.I = kwargs.get('I', None)
        a = self.I.WS2812B([[0xAA, 0x00, 0xFF]], 'SQR1')
        TOTAL_PIXELS = 3
        self.Frame = QtGui.QFrame()
        self.Holder = QtGui.QVBoxLayout()
        self.Frame.setLayout(self.Holder)
        self.setCentralWidget(self.Frame)
        self.setWindowTitle('Set color of WS2812B RGB LEDs')

        self.btns = [pg.ColorButton() for a in range(TOTAL_PIXELS)]
        for sld in self.btns:
            self.Holder.addWidget(sld)

        self.COLS = [[1, 0, 1]] * len(self.btns)
        for btn in self.btns:
            btn.sigColorChanging.connect(self.change)
Esempio n. 17
0
    def __init__(self, name, **kwargs):
        terminals = {
            'view': {
                'io': 'in'
            },
            'pos': {
                'io': 'out'
            },
            'image': {
                'io': 'out'
            },
            'mask': {
                'io': 'out'
            },
            'maskedImage': {
                'io': 'out'
            }
        }
        super().__init__(name, terminals=terminals, **kwargs)
        self.roi = self.makeRoi()
        self.panel = QWidget()
        self.panelLayout = QGridLayout(self.panel)

        self.colorButton = pg.ColorButton(self.panel)
        self.panelLayout.addWidget(self.colorButton, 1, 1)

        self.visibleCheckBox = QCheckBox('Visible', self.panel)
        self.visibleCheckBox.setChecked(True)
        self.panelLayout.addWidget(self.visibleCheckBox, 1, 2)

        self.saveButton = QPushButton('Save', self.panel)
        self.panelLayout.addWidget(self.saveButton, 2, 1)

        self.loadButton = QPushButton('Load', self.panel)
        self.panelLayout.addWidget(self.loadButton, 2, 2)

        self.panel.setLayout(self.panelLayout)

        self.colorButton.sigColorChanged.connect(self.setRoiColor)
        self.visibleCheckBox.toggled.connect(self.setVisible)
        self.saveButton.clicked.connect(self.saveRoi)
        self.loadButton.clicked.connect(self.loadRoi)

        self.view = None
Esempio n. 18
0
def main():
    app = QtGui.QApplication([])
    win = QtGui.QMainWindow()
    btn = pg.ColorButton()
    win.setCentralWidget(btn)
    win.show()

    arduino = connect_arduino()

    def change(btn):
        r, g, b, a = btn.color().getRgb()
        arduino.write(b'\n')
        arduino.write(struct.pack('BBB', r, g, b))

    btn.sigColorChanging.connect(change)

    # start main loop
    if sys.flags.interactive != 1:
        app.exec_()
Esempio n. 19
0
        def __init__(self, node, I2Cs, evaluator, batLevel, fallbackEvaluator):
            super(AppWindow.nrfHandler, self).__init__()
            self.setupUi(self)
            self.node = node
            self.title.setText(hex(node.ADDRESS) + ' %d%%' % (batLevel))
            self.title.setStyleSheet(
                "* {color: white; background: qlineargradient( x1:0 y1:0, x2:2 y2:0, stop:0 green, stop:%.1f red);}"
                % (batLevel / 100.))
            self.cmd = evaluator
            self.cmd2 = fallbackEvaluator
            for i in I2Cs:
                self.items.addItem('I2C:' + hex(i))
            self.items.addItems(['ADC:CS3', 'ADC:BAT'])

            self.colbtn = pg.ColorButton()
            self.colbtn.setMaximumWidth(30)
            self.colbtn.setMinimumHeight(25)
            self.colbtn.setStyleSheet("border-radius: 0px;padding: 0px;")
            self.horizontalLayout.addWidget(self.colbtn)
            self.colbtn.sigColorChanging.connect(self.setRGB)
Esempio n. 20
0
    def __init__(self, parent=None, **kwargs):
        super(AppWindow, self).__init__(parent)
        self.setupUi(self)
        self.I = kwargs.get('I', None)
        self.setWindowTitle(self.I.H.version_string + ' : ' +
                            params.get('name', '').replace('\n', ' '))

        self.I.NRF.start_token_manager()
        print(self.I.readLog())
        self.plot = self.add2DPlot(self.plot_area)
        self.plot.setLabel('bottom', 'Datapoints')
        self.plot.enableAutoRange(True, True)
        self.plot.setXRange(0, 1000)
        self.plot.setLimits(xMin=0, xMax=1000)
        self.curves = []
        self.nodeWidgets = []
        self.nodeList = []
        self.acquireList = []
        self.POINTS = 1000
        self.xdata = range(self.POINTS)
        self.fps = 0
        self.lastTime = time.time()
        self.updatepos = 0
        self.active_device_counter = 0
        self.right_axes = []
        self.timer = self.loopTask(2, self.updatePlots)
        self.updatepos = 0
        self.refreshTimer = self.loopTask(200, self.updateLogWindow)
        self.deviceMenus = []
        self.actionWidgets = []

        self.sensorWidgets = []
        self.availableClasses = [0x68, 0x1E, 0x5A, 0x77, 0x39, 0x40]
        self.Running = True

        self.colbtn = pg.ColorButton()
        self.colbtn.setMaximumWidth(30)
        self.colbtn.setMinimumHeight(25)
        self.colbtn.setStyleSheet("border-radius: 0px;padding: 0px;")
        self.horizontalLayout_3.addWidget(self.colbtn)
        self.colbtn.sigColorChanging.connect(self.setRGB)
Esempio n. 21
0
    def addLabel(self, id, parent, name, acronym, color):
        item = QtGui.QTreeWidgetItem([acronym, name, ''])
        item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
        item.setCheckState(0, QtCore.Qt.Unchecked)

        if parent in self.labelsById:
            root = self.labelsById[parent]['item']
        else:
            root = self.tree.invisibleRootItem()

        root.addChild(item)

        btn = pg.ColorButton(color=pg.mkColor(color))
        btn.defaultColor = color
        self.tree.setItemWidget(item, 2, btn)

        self.labelsById[id] = {'item': item, 'btn': btn}
        item.id = id
        self.labelsByAcronym[acronym] = self.labelsById[id]

        btn.sigColorChanged.connect(self.itemColorChanged)
Esempio n. 22
0
    def create_imageDock(self):
        self.imageLayout = pg.LayoutWidget()
        row = 0
        col = 0
        roiPSLabel = QLabel('ROI point-size')
        self.imageLayout.addWidget(roiPSLabel, row=row, col=col)
        col += 1
        self.roiPSLineEdit = QLineEdit('5')
        self.roiPSLineEdit.returnPressed.connect(self.updateROI)
        self.imageLayout.addWidget(self.roiPSLineEdit, row=row, col=col)
        col += 1
        roiLWLabel = QLabel('ROI line-width')
        self.imageLayout.addWidget(roiLWLabel, row=row, col=col)
        col += 1
        self.roiLWLineEdit = QLineEdit('2')
        self.roiLWLineEdit.returnPressed.connect(self.updateROI)
        self.imageLayout.addWidget(self.roiLWLineEdit, row=row, col=col)
        col += 1
        roiColorLabel = QLabel('ROI color')
        self.imageLayout.addWidget(roiColorLabel, row=row, col=col)
        col += 1
        self.roiColorButton = pg.ColorButton()
        self.roiColorButton.sigColorChanging.connect(self.updateROI)
        self.roiColorButton.sigColorChanged.connect(self.updateROI)
        self.imageLayout.addWidget(self.roiColorButton, row=row, col=col)

        row += 1
        col = 0
        self.imageWidget = Image_Widget(self.imageData)
        self.imageLayout.addWidget(self.imageWidget,
                                   row=row,
                                   col=col,
                                   colspan=6)
        self.pg_axis = self.imageWidget.imageView.getView()
        self.pg_image = self.imageWidget.imageView.getImageItem()

        self.imageDock.addWidget(self.imageLayout)
Esempio n. 23
0
    def initGUI(self):
        layout = QHBoxLayout()

        v = QVBoxLayout()

        line = QFrame()
        line.setFixedSize(300, 1)
        line.setStyleSheet('background-color: rgb(149,149,149)')

        widget = QWidget()
        grid = QGridLayout()

        addTrace = QPushButton('add trace')
        addTrace.setFixedSize(100, 30)
        addTrace.clicked[bool].connect(self.addTrace)
        grid.addWidget(addTrace, 9, 0)

        self.color = pg.ColorButton()
        self.color.setFixedSize(60, 30)
        self.color.setColor(color=(225, 200, 50))
        grid.addWidget(self.color, 8, 0)

        names = [
            'Num:',
            '',
            '',
            '',
            'Show',
            '',
            '',
            '',
            'z_em:',
            '',
            '...',
            '',
            'z_abs',
            '',
            '...',
            '',
            'HI',
            '',
            '...',
            '',
            'H2',
            '',
            '...',
            '',
            'Av',
            '',
            '...',
            '',
            'Av_bump',
            '',
            '...',
            '',
        ]

        positions = [(i, j) for i in range(8) for j in range(4)]

        for position, name in zip(positions, names):
            if name == '' or (position[1] == 0 and position[0] not in [0, 2]):
                continue
            label = QLabel(name)
            width = 30 if name == '...' else 45
            label.setFixedSize(width, 30)
            grid.addWidget(label, *position)

        self.opt_but = OrderedDict([
            ('traceNum', [0, 1]),
            ('z_em_min', [2, 1]),
            ('z_em_max', [2, 3]),
            ('z_abs_min', [3, 1]),
            ('z_abs_max', [3, 3]),
            ('HI_min', [4, 1]),
            ('HI_max', [4, 3]),
            ('H2_min', [5, 1]),
            ('H2_max', [5, 3]),
            ('Av_min', [6, 1]),
            ('Av_max', [6, 3]),
            ('Av_bump_min', [7, 1]),
            ('Av_bump_max', [7, 3]),
        ])
        validator = QDoubleValidator()
        validator.setLocale(QLocale('C'))

        for opt, pos in self.opt_but.items():
            b = QLineEdit(str(getattr(self, opt)))
            b.setFixedSize(40, 30)
            b.setValidator(validator)
            b.textChanged[str].connect(partial(self.onChanged, attr=opt))
            grid.addWidget(b, pos[0], pos[1])

        for position, name in zip(positions, names):
            if position[1] == 0 and position[0] not in [0, 2]:
                s = '' if position[0] == 1 else ':'
                setattr(self, name, QCheckBox(name + s))
                getattr(self, name).setFixedSize(80, 30)
                grid.addWidget(getattr(self, name), *position)

        self.Show.setChecked(False)
        self.z_abs.setChecked(True)
        self.z_abs.stateChanged.connect(self.checkEvent)
        self.HI.setChecked(True)
        self.H2.setChecked(True)
        self.Av.setChecked(False)
        self.Av_bump.setChecked(False)

        widget.setFixedSize(250, 400)
        widget.setLayout(grid)
        v.addWidget(widget)

        v.addWidget(line)

        self.addSDSSStars = QCheckBox('add SDSS stars')
        self.addSDSSStars.setFixedSize(200, 30)
        self.addSDSSStars.stateChanged.connect(self.addStellarLocus)
        self.addSDSSStars.setChecked(False)
        v.addWidget(self.addSDSSStars)

        self.addSDSSQSO = QCheckBox('add SDSS QSO:')
        self.addSDSSQSO.setFixedSize(160, 30)
        self.addSDSSQSO.stateChanged.connect(self.addQSOSDSS)
        self.addSDSSQSO.setChecked(False)
        v.addWidget(self.addSDSSQSO)
        h = QHBoxLayout()
        self.z_SDSS_min = QLineEdit('2.6')
        self.z_SDSS_min.setFixedSize(50, 30)
        h.addWidget(self.z_SDSS_min)
        label = QLabel('...')
        label.setFixedSize(15, 30)
        h.addWidget(label)
        self.z_SDSS_max = QLineEdit('2.8')
        self.z_SDSS_max.setFixedSize(50, 30)
        h.addWidget(self.z_SDSS_max)
        h.addStretch(1)
        v.addLayout(h)

        v.addWidget(line)

        v.addWidget(QLabel('Select by criterion:'))
        self.criteria = QTextEdit('')
        self.criteria.setFixedSize(300, 200)
        self.criteria.setText('r-i 0.6 0.8 \ni-g -2.0 -0.8\ng-r 0.2 0.6')
        v.addWidget(self.criteria)
        self.select = QPushButton('Apply')
        self.select.setFixedSize(80, 30)
        self.select.clicked[bool].connect(self.applyCriteria)
        v.addWidget(self.select)

        v.addWidget(line)

        v.addWidget(QLabel('Select by name:'))
        self.names = QTextEdit('')
        self.names.setFixedSize(300, 200)
        self.names.setText('7093-0632 \n6439-0160')
        v.addWidget(self.names)
        self.shownames = QPushButton('Show')
        self.shownames.setFixedSize(80, 30)
        self.shownames.clicked[bool].connect(self.applyNames)
        v.addWidget(self.shownames)
        v.addStretch(1)
        layout.addLayout(v)

        self.plot = pg.GraphicsWindow(size=(1900, 1800))

        self.p = []
        for comb in self.combs:
            p = colorColorPlot(self, comb)
            setattr(self, p.name, p)
            self.p.append(getattr(self, p.name))
            self.plot.addItem(self.p[-1],
                              row=(len(self.p) - 1) // 4,
                              col=(len(self.p) - 1) % 4)

        self.setLinks()
        layout.addWidget(self.plot)
        self.setLayout(layout)
Esempio n. 24
0
# -*- coding: utf-8 -*-
"""
Simple example demonstrating a button which displays a colored rectangle
and allows the user to select a new color by clicking on the button.
"""
# import initExample ## Add path to library (just for examples; you do not need this)

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np

app = QtGui.QApplication([])
win = QtGui.QMainWindow()
btn = pg.ColorButton()
win.setCentralWidget(btn)
win.show()
win.setWindowTitle('pyqtgraph example: ColorButton')


def change(btn):
    print("change", btn.color())


def done(btn):
    print("done", btn.color())


btn.sigColorChanging.connect(change)
btn.sigColorChanged.connect(done)

# Start Qt event loop unless running in interactive mode or using pyside.
Esempio n. 25
0
    def __init__(self,
                 settings: Settings,
                 data_model: DataModel,
                 parent: Optional[QWidget] = None,
                 *args: Any) -> None:
        super().__init__(parent, *args)

        self.setObjectName('plot_dialog')

        self.settings: Settings = settings
        self.setModal(True)
        self.setWindowTitle(self.tr('Plot'))
        if parent is not None:
            self.setWindowIcon(parent.windowIcon())

        layout: QHBoxLayout = QHBoxLayout(self)

        controls_panel: QWidget = QWidget(self)
        layout.addWidget(controls_panel)
        controls_layout: QFormLayout = QFormLayout(controls_panel)

        plot: pg.PlotWidget = pg.PlotWidget(self)
        canvas: pg.PlotItem = plot.getPlotItem()
        canvas.setAxisItems({'bottom': pg.DateAxisItem()})
        layout.addWidget(plot)
        layout.setStretch(0, 0)
        cursor_balloon: pg.TextItem = pg.TextItem()
        plot.addItem(cursor_balloon, True)  # ignore bounds

        def on_mouse_moved(event: Tuple[QPointF]) -> None:
            pos: QPointF = event[0]
            if plot.sceneBoundingRect().contains(pos):
                point: QPointF = canvas.vb.mapSceneToView(pos)
                if plot.visibleRange().contains(point):
                    cursor_balloon.setPos(point)
                    cursor_balloon.setText(
                        f'{datetime.fromtimestamp(round(point.x()))}\n{point.y()}'
                    )
                    balloon_border: QRectF = cursor_balloon.boundingRect()
                    sx: float
                    sy: float
                    sx, sy = canvas.vb.viewPixelSize()
                    balloon_width: float = balloon_border.width() * sx
                    balloon_height: float = balloon_border.height() * sy
                    anchor_x: float = 0.0 if point.x() - plot.visibleRange(
                    ).left() < balloon_width else 1.0
                    anchor_y: float = 0.0 if plot.visibleRange().bottom(
                    ) - point.y() < balloon_height else 1.0
                    cursor_balloon.setAnchor((anchor_x, anchor_y))
                    cursor_balloon.setVisible(True)
                else:
                    cursor_balloon.setVisible(False)
            else:
                cursor_balloon.setVisible(False)

        self._mouse_moved_signal_proxy: pg.SignalProxy = pg.SignalProxy(
            plot.scene().sigMouseMoved, rateLimit=10, slot=on_mouse_moved)

        header: str
        column: np.ndarray
        visibility: bool
        self.lines: List[pg.PlotDataItem] = []
        self.color_buttons: List[pg.ColorButton] = []
        visible_columns_count: int = 0
        visible_headers: List[str] = []
        for header, column, visibility in zip(
                data_model.header, data_model.all_data,
                self.settings.check_items_values):
            if not (visibility and (self.settings.show_all_zero_columns
                                    or not np.alltrue((column == 0.0) | np.isnan(column)))) \
                    or header.endswith(('(s)', '(sec)', '(secs)')):
                continue
            else:
                visible_columns_count += 1
                visible_headers.append(header)

        def set_line_color(sender: pg.ColorButton) -> None:
            index: int = self.color_buttons.index(sender)
            self.lines[index].setPen(sender.color())
            self.settings.line_colors[visible_headers[index]] = sender.color()

        for header, column, visibility in zip(
                data_model.header, data_model.all_data,
                self.settings.check_items_values):
            if not (visibility and (self.settings.show_all_zero_columns
                                    or not np.alltrue((column == 0.0) | np.isnan(column)))) \
                    or header.endswith(('(s)', '(sec)', '(secs)')):
                continue
            color: QColor = self.settings.line_colors.get(
                header, pg.intColor(len(self.lines),
                                    hues=visible_columns_count))
            self.color_buttons.append(pg.ColorButton(controls_panel, color))
            controls_layout.addRow(header, self.color_buttons[-1])
            self.lines.append(
                canvas.plot(np.column_stack((data_model.all_data[0], column)),
                            name=header,
                            pen=color))
            self.color_buttons[-1].sigColorChanged.connect(set_line_color)

        self.settings.beginGroup('plot')
        window_settings: bytes = self.settings.value('geometry')
        if window_settings is not None:
            self.restoreGeometry(window_settings)
        self.settings.endGroup()
Esempio n. 26
0
 def init_color_button(self):
     color_b = pg.ColorButton(close_fit=True)
     # color_b.sigColorChanging.connect(self.print_shit)
     # color_b.sigColorChanged.connect(self.print_shit)
     return color_b
Esempio n. 27
0
import pyqtgraph as pg
from PySide6 import QtWidgets


def change(btn):
    print("change", btn.color())


def done(btn):
    print("done", btn.color())


app = QtWidgets.QApplication([])
win = QtWidgets.QMainWindow()
btn1 = pg.ColorButton()
win.setCentralWidget(btn1)
win.show()
win.setWindowTitle('pyqtgraph example: ColorButton')

btn1.sigColorChanging.connect(change)
btn1.sigColorChanged.connect(done)

app.exec()
Esempio n. 28
0
    def setup_ui(self, Form):
        self.setObjectName("Form")
        # self.resize(217, 499)
        self.gridLayout = QtGui.QGridLayout(self)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setVerticalSpacing(0)
        self.gridLayout.setObjectName("gridLayout")

        self.label = QtGui.QLabel("Title: ")
        self.gridLayout.addWidget(self.label, 0, 0)
        self.label.setFixedWidth(40)
        self.plot_name = QtGui.QLineEdit(self.plot_name)
        self.gridLayout.addWidget(self.plot_name, 0, 1)
        self.label11 = QtGui.QLabel("Topic: ")
        self.gridLayout.addWidget(self.label11, 0, 2)
        self.label11.setFixedWidth(40)
        self.topic_name = QtGui.QComboBox()
        self.topic_name.addItems(self.topics_list)
        self.gridLayout.addWidget(self.topic_name, 0, 3)
        self.topic_name.currentIndexChanged.connect(self.combox_change)
        self.label_c = QtGui.QLabel("color:")
        self.gridLayout.addWidget(self.label_c, 0, 4)
        self.colorBtn = pg.ColorButton(color=(255, 0, 0))
        self.colorBtn.sigColorChanged.connect(self.change_color)
        self.colorBtn.setFixedWidth(30)
        self.gridLayout.addWidget(self.colorBtn, 0, 5)

        # self.label1 = QtGui.QLabel("Axes")
        # self.axisLayout.addWidget(self.label1, 0, 0)
        self.label1 = QtGui.QLabel("X-Axis: ")
        self.label1.setFixedWidth(50)
        self.axisLayout.addWidget(self.label1, 0, 0)
        self.field1 = QtGui.QComboBox()
        self.field1.addItems(self.topics[self.topics_list[0]])
        self.axisLayout.addWidget(self.field1, 0, 1)
        self.label2 = QtGui.QLabel("Y-Axis: ")
        self.label2.setFixedWidth(50)
        self.axisLayout.addWidget(self.label2, 0, 2)
        self.field2 = QtGui.QComboBox()
        self.field2.addItems(self.topics[self.topics_list[0]])
        self.axisLayout.addWidget(self.field2, 0, 3)
        self.label3 = QtGui.QLabel("line_mark: ")
        self.label3.setFixedWidth(70)
        self.axisLayout.addWidget(self.label3, 0, 4)
        self.line_mark = QtGui.QComboBox()
        self.line_mark.addItems(
            ['+-', '*-', 'o-', '^-', 's-', 'x-', '.-', 'p-', 'h-', 'd-'])
        self.axisLayout.addWidget(self.line_mark, 0, 5)
        self.gridLayout.addLayout(self.axisLayout, 1, 0, 1, 6)

        self.buttonBox = QtGui.QDialogButtonBox()
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok
                                          | QtGui.QDialogButtonBox.Cancel)
        # self.gridLayout.addWidget(self.buttonBox, 4, 1)
        self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setDefault(True)
        self.btnhbLayout.addWidget(self.buttonBox)
        self.gridLayout.addLayout(self.btnhbLayout, 2, 0, 1, 6)
        self.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self,
                     QtCore.SLOT("accept()"))
        self.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self,
                     QtCore.SLOT("reject()"))
Esempio n. 29
0
 def __init__(self, parent=None, custom=False):
     super(createNormalSelectionBox, self).__init__(parent=parent)
     self.parent = parent
     self.custom = custom
     self.selectionBoxlayout = QHBoxLayout()
     self.combo1 = signalTypeComboBox(0, self.parent)
     self.combo2 = signalElementComboBox(0, self.parent)
     self.combo3 = signalPVComboBox(0, self.parent)
     self.combo4 = signalRateComboBox(0, self.parent)
     self.addButton = QPushButton('Add Signal')
     self.addButton.setFixedWidth(100)
     if self.custom:
         self.addButton.clicked.connect(self.parent.addTableRowCustom)
     else:
         self.addButton.clicked.connect(self.parent.addTableRow)
     self.logTickBox = QCheckBox('Log Scale')
     self.combo1.addItems(self.parent.headings)
     if not self.custom:
         self.combo2.addItems(self.parent.magnetnames['Off']['Names'])
         self.combo3.addItems(self.parent.magnetnames['Off']['PVs'].keys())
     self.combo4.addItems([str(i) + ' Hz' for i in self.parent.frequencies])
     self.combo1.setEditable(True)
     self.combo1.lineEdit().setReadOnly(True)
     self.combo1.lineEdit().setAlignment(Qt.AlignCenter)
     self.combo1.setMinimumWidth(80)
     self.combo1.setMaximumWidth(100)
     if not self.custom:
         self.combo2.setEditable(True)
         self.combo2.lineEdit().setReadOnly(True)
         self.combo2.lineEdit().setAlignment(Qt.AlignCenter)
         self.combo2.setMinimumWidth(80)
         self.combo2.setMaximumWidth(100)
         self.combo3.setEditable(True)
         self.combo3.lineEdit().setReadOnly(True)
         self.combo3.lineEdit().setAlignment(Qt.AlignCenter)
         self.combo3.setMinimumWidth(80)
         self.combo3.setMaximumWidth(100)
     self.combo4.setEditable(True)
     self.combo4.lineEdit().setReadOnly(True)
     self.combo4.lineEdit().setAlignment(Qt.AlignCenter)
     self.combo4.setCurrentIndex(2)
     self.combo4.setMinimumWidth(80)
     self.combo4.setMaximumWidth(100)
     self.pvtextedit = QLineEdit()
     self.pvtextedit.setMinimumWidth(240)
     self.pvtextedit.setMaximumWidth(300)
     self.colorbox = pg.ColorButton()
     self.colorbox.setMinimumWidth(60)
     self.colorbox.setMaximumWidth(80)
     self.colorbox.setFlat(True)
     if (self.parent.rowNumber < 0):
         self.colorbox.setColor(self.parent.penColors[0])
     else:
         self.colorbox.setColor(
             self.parent.penColors[self.parent.rowNumber])
     self.selectionBoxlayout.addWidget(self.combo1, 2)
     if self.custom:
         self.selectionBoxlayout.addWidget(self.pvtextedit, 5)
     else:
         self.selectionBoxlayout.addWidget(self.combo2, 3)
         self.selectionBoxlayout.addWidget(self.combo3, 2)
     self.selectionBoxlayout.addWidget(self.combo4, 1)
     self.selectionBoxlayout.addWidget(self.logTickBox, 1)
     self.selectionBoxlayout.addWidget(self.colorbox, 1)
     self.selectionBoxlayout.addWidget(self.addButton, 1)
     self.setLayout(self.selectionBoxlayout)
     self.setMaximumHeight(100)
Esempio n. 30
0
    def setUI(self, headerInfo):

        if headerInfo == self.headerInfo:
            return

        self.headerInfo = headerInfo

        pos = 0

        for i, name in enumerate(headerInfo[0]):

            if not name in self.checks:

                self.checks[name] = [QtGui.QCheckBox(name), []]
                self.checks[name][0].setCheckState(2)
                self.checks[name][0].stateChanged.connect(self.onCheckChanged)
                self.scansLayout.addWidget(self.checks[name][0], pos, 0)

                self.colButtons[name] = [pg.ColorButton(), []]
                self.colButtons[name][0].sigColorChanging.connect(
                    self.onStyleChanged)
                self.scansLayout.addWidget(self.colButtons[name][0], pos, 1)

                self.fillButtons[name] = [pg.ColorButton(), []]
                self.fillButtons[name][0].sigColorChanging.connect(
                    self.onStyleChanged)
                self.scansLayout.addWidget(self.fillButtons[name][0], pos, 2)

                self.colButtons[name][0].setColor(self.color)
                self.fillButtons[name][0].setColor(self.fill)

            pos = pos + 1

            for j in xrange(headerInfo[1][i]):

                if j >= len(self.checks[name][1]):

                    self.checks[name][1].append(
                        QtGui.QCheckBox('scan ' + str(j)))
                    self.checks[name][1][-1].setCheckState(2)
                    self.checks[name][1][-1].stateChanged.connect(
                        self.onCheckChanged)
                    self.scansLayout.addWidget(self.checks[name][1][-1], pos,
                                               0)

                    self.colButtons[name][1].append(pg.ColorButton())
                    self.colButtons[name][1][-1].sigColorChanging.connect(
                        self.onStyleChanged)
                    self.scansLayout.addWidget(self.colButtons[name][1][-1],
                                               pos, 1)

                    self.fillButtons[name][1].append(pg.ColorButton())
                    self.fillButtons[name][1][-1].sigColorChanging.connect(
                        self.onStyleChanged)
                    self.scansLayout.addWidget(self.fillButtons[name][1][-1],
                                               pos, 2)

                    self.colButtons[name][1][-1].setColor(self.color)
                    self.fillButtons[name][1][-1].setColor(self.fill)

                pos = pos + 1