## ] ## ## for food in foods: ## # create an item with a caption ## item = QStandardItem(food) ## ## # add a checkbox to it ## item.setCheckable(True) ## ## # Add the item to the model ## model.appendRow(item) for pick in cat[-40].picks: # create an item with a caption item = QStandardItem(str(pick.resource_id)) # add a checkbox to it item.setCheckable(True) item.setEditable(False) item.setTristate(True) # Add the item to the model model.appendRow(item) # Apply the model to the list view list.setModel(model) # Show the window and run the app list.show() app.exec_()
def init_labels(self): j = 0 k = 1 self.Controler = {} for i in sorted(self.devices): i = self.devices[i].properties if 'Input' in i.keys(): self.main.Scan_Detector_comboBox.addItem(_fromUtf8("")) self.main.Scan_Detector_comboBox.setItemText( j, _translate("MainWindow", i['Name'], None)) self.main.Monitor_comboBox.addItem(_fromUtf8("")) self.main.Monitor_comboBox.setItemText( j, _translate("MainWindow", i['Name'], None)) self.main.Controler_Detector_comboBox.addItem(_fromUtf8("")) self.main.Controler_Detector_comboBox.setItemText( j, _translate("MainWindow", i['Name'], None)) item = QStandardItem(i['Name']) item.setCheckable(True) item.setEditable(False) self.main.Scan_Dropdown.model.appendRow(item) if j == 0: self.main.Scan_Detector_UnitLabel.setText( _translate("MainWindow", i['Input']['Calibration']['Unit'], None)) j += 1 if 'Output' in i.keys(): unit = i['Output']['Calibration']['Unit'] self.main.Scan_1st_comboBox.addItem( _translate("MainWindow", i['Name'], None)) self.main.Scan_2nd_comboBox.addItem( _translate("MainWindow", i['Name'], None)) self.main.Scan_3rd_comboBox.addItem( _translate("MainWindow", i['Name'], None)) self.main.Controler_1st_comboBox.addItem( _translate("MainWindow", i['Name'], None)) self.main.Controler_2nd_comboBox.addItem( _translate("MainWindow", i['Name'], None)) self.main.Controler_3rd_comboBox.addItem( _translate("MainWindow", i['Name'], None)) self.Controler[i['Name']] = { 'NameLabel': None, 'PosBox': None, 'IncBox': None, 'UnitLabel': None, 'AddButton': None, 'MinButton': None } self.Controler[i['Name']]['NameLabel'] = QtGui.QLabel( self.main.gridLayoutWidget_2) self.Controler[i['Name']]['NameLabel'].setObjectName( _fromUtf8("Controler_NameLabeln_%s" % i['Name'])) self.main.Controler_gridLayout.addWidget( self.Controler[i['Name']]['NameLabel'], k + 5, 0, 1, 1) self.Controler[i['Name']]['NameLabel'].setText( _translate("MainWindow", i['Name'], None)) self.Controler[i['Name']]['PosBox'] = QtGui.QDoubleSpinBox( self.main.gridLayoutWidget_2) self.Controler[i['Name']]['PosBox'].setObjectName( _fromUtf8("Controler_Pos_doubleSpinBoxn_%s" % i['Name'])) self.Controler[i['Name']]['PosBox'].setKeyboardTracking(False) self.Controler[i['Name']]['PosBox'].setSuffix(" " + unit) self.main.Controler_gridLayout.addWidget( self.Controler[i['Name']]['PosBox'], k + 5, 1, 1, 1) self.Controler[i['Name']]['IncBox'] = QtGui.QDoubleSpinBox( self.main.gridLayoutWidget_2) self.Controler[i['Name']]['IncBox'].setObjectName( _fromUtf8("Controler_Inc_doubleSpinBoxn_%s" % i['Name'])) self.Controler[i['Name']]['IncBox'].setSingleStep(0.05) self.Controler[i['Name']]['IncBox'].setSuffix(" " + unit) self.main.Controler_gridLayout.addWidget( self.Controler[i['Name']]['IncBox'], k + 5, 2, 1, 1) self.Controler[i['Name']]['AddButton'] = QtGui.QPushButton( self.main.gridLayoutWidget_2) self.Controler[i['Name']]['AddButton'].setEnabled(True) self.Controler[i['Name']]['AddButton'].setObjectName( _fromUtf8("Controler_Add_pushButton_%s" % i['Name'])) self.main.Controler_gridLayout.addWidget( self.Controler[i['Name']]['AddButton'], k + 5, 3, 1, 1) self.Controler[i['Name']]['AddButton'].setText( _translate("MainWindow", "+", None)) self.Controler[i['Name']]['MinButton'] = QtGui.QPushButton( self.main.gridLayoutWidget_2) self.Controler[i['Name']]['MinButton'].setEnabled(True) self.Controler[i['Name']]['MinButton'].setObjectName( _fromUtf8("Controler_Min_pushButtonn_%s" % i['Name'])) self.main.Controler_gridLayout.addWidget( self.Controler[i['Name']]['MinButton'], k + 5, 4, 1, 1) self.Controler[i['Name']]['MinButton'].setText( _translate("MainWindow", "-", None)) QtCore.QObject.connect(self.Controler[i['Name']]['AddButton'], QtCore.SIGNAL("clicked()"), self.ChangePos) QtCore.QObject.connect(self.Controler[i['Name']]['MinButton'], QtCore.SIGNAL("clicked()"), self.ChangePos) QtCore.QObject.connect(self.Controler[i['Name']]['PosBox'], QtCore.SIGNAL("valueChanged(double)"), self.ChangePos) k += 1 self.help_menu.addAction('&About', self.about) self.connect(self.main.Monitor_pushButton, SIGNAL("clicked()"), self.Monitor) QtCore.QObject.connect(self.main.Scan_Detector_comboBox, QtCore.SIGNAL("currentIndexChanged(int)"), self.ChangeUnit) QtCore.QObject.connect(self.main.Scan_1st_comboBox, QtCore.SIGNAL("currentIndexChanged(int)"), self.ChangeUnit) QtCore.QObject.connect(self.main.Scan_2nd_comboBox, QtCore.SIGNAL("currentIndexChanged(int)"), self.ChangeUnit) QtCore.QObject.connect(self.main.Scan_3rd_comboBox, QtCore.SIGNAL("currentIndexChanged(int)"), self.ChangeUnit) QtCore.QObject.connect(self.main.Scan_start_pushButton, QtCore.SIGNAL("clicked()"), self.StartScan) QtCore.QObject.connect(self.main.Scan_stop_pushButton, QtCore.SIGNAL("clicked()"), self.StopScan) QtCore.QObject.connect(self.main.Scan_Mult_Detector_comboBox, QtCore.SIGNAL("clicked()"), self.Mult_detect) QtCore.QObject.connect(self.main.Controler_Go, QtCore.SIGNAL("clicked()"), self.Go2Pos) QtCore.QObject.connect(self.main.Controler_Refocus, QtCore.SIGNAL("clicked()"), self.Refocus) self.main.Scan_Dropdown.create() self.InitDevices()