def init(self, lesson): self.listSteps.clear() self.lesson = lesson bulletIcon = QIcon(os.path.dirname(__file__) + '/bullet.png') for step in lesson.steps: item = QListWidgetItem(step.name) self.listSteps.addItem(item) item.setHidden(step.steptype == Step.AUTOMATEDSTEP) item.setIcon(bulletIcon) self.currentStep = 0 self.lessonNameLabel.setText("<b>Current lesson:</b> %s" % lesson.name) self.moveToNextStep()
def init(self, lesson): self.resetGui() self.listSteps.clear() self.lesson = lesson bulletIcon = QIcon(os.path.dirname(__file__) + "/bullet.png") for step in lesson.steps: item = QListWidgetItem(step.name) self.listSteps.addItem(item) item.setHidden(step.steptype == Step.AUTOMATEDSTEP) item.setIcon(bulletIcon) self.currentStep = 0 self.lessonNameLabel.setText("<b>Current lesson:</b> {}".format(lesson.name)) self.btnMove.setText(self.tr("Next step")) self.btnMove.setToolTip(self.tr("Move to next step")) self.moveToNextStep()
def startUI(self): if self.first_start == True: # Connect to the export button to do the real work self.dlg.exportButton = self.dlg.buttonBox.button( QDialogButtonBox.Ok) self.dlg.exportButton.disconnect() self.dlg.exportButton.setText(self.tr(u'Export')) self.dlg.exportButton.clicked.connect(self.doIt) else: # clear the 3 lists self.dlg.checkAll.setChecked(False) self.dlg.listLayer.clear() self.dlg.listLayout.clear() self.dlg.supportedFormatsBox.clear() self.dlg.checkAll.clicked.connect(self.checkAll) self.dlg.browse.setStorageMode(QgsFileWidget.StorageMode.GetDirectory) #init the list of layers #old method who doesn't keep the order #lay = QgsProject.instance().mapLayers() #layers = list(lay.values()) layers = QgsProject.instance().layerTreeRoot().layerOrder() self.listLayersId = [] #a initialiser correctement for layer in layers: #init the list of layersID self.listLayersId.append(layer.id()) #create the list of layers in UI, and add a checkbox item = QListWidgetItem() item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Unchecked) item.setText(layer.name()) self.dlg.listLayer.addItem(item) item2 = QListWidgetItem() item2.setFlags(item2.flags() | Qt.ItemIsEditable) item2.setFlags(item2.flags() ^ QtCore.Qt.ItemIsUserCheckable) #if self.first_start == True: item2.setText('Double click to set/change the title') item2.setForeground(QBrush(QtCore.Qt.darkGray)) self.dlg.listLayer.addItem(item2) item2.setHidden(True) self.dlg.listLayer.clicked.connect(self.layerCheckedEvent) # init the list of layouts and insert them in UI layouts = QgsProject.instance().layoutManager().printLayouts() layoutsName = [] for layout in layouts: layoutsName.append(layout.name()) self.dlg.listLayout.addItems(layoutsName) #init the list of supported formats self.dlg.supportedFormatsBox.addItems(self.getSupportedFormats()) #set a the default directory on PDF. Put a signal to open browser in last saved PDF, SVG ou image self.defaultDirectory = QSettings().value('/UI/lastSaveAsPdfFile') self.defaultDirectory = self.dlg.supportedFormatsBox.currentIndexChanged.connect( self.selectDefaultDirectory) self.first_start = False