def addItemsCompleter(self, list_, icon=None): for text in list_: if not text in self.itemsListName: item = QListWidgetItem() if icon != None: item.setIcon(icon) item.setText(text) self.addItem(item) self.itemsList.append(item) self.itemsListName.append(item.text())
def addNewItem(self, name, icon=None): if not name in self.itemsListName: item = QListWidgetItem() if icon: item.setIcon(icon) item.setText(name) self.addItem(item) self.itemsList.append(item) self.itemsListName.append(name) return item
def _add_task(self, title, checked): """ inserts a task at the beginning of the ui.taskList widget """ item = QListWidgetItem() item.setText(title) if checked: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) self.ui.taskList.insertItem(0, item)
def update_save_list(): save_list.clear() try: file_list = os.listdir(config['backup_folder_path']) file_list.reverse() for filename in file_list: text = filename try: created = arrow.get(filename, FILENAME_FORMAT) created.shift(hour=-1) text = created.humanize(locale='en_gb') except Exception as e: print e list_item = QListWidgetItem() list_item.setData(1, filename) list_item.setText(text) save_list.addItem(list_item) except Exception as e: print "Error opening directory", e
def __createContents(self): self.contentsWidget = QListWidget() self.contentsWidget.setViewMode(QListView.ListMode) self.contentsWidget.setMovement(QListView.Static) toolBar = QListWidgetItem(self.contentsWidget) toolBar.setText(self.tr("Toolbar")) toolBar.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) worksheet = QListWidgetItem(self.contentsWidget) worksheet.setText(self.tr("Worksheet")) worksheet.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) computation = QListWidgetItem(self.contentsWidget) computation.setText(self.tr("Computation")) computation.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) currentItem = QSettings().value("preferences/currentitem", self.tr(QtReduceDefaults.CURRENTITEM)) if currentItem == self.tr("Toolbar"): self.contentsWidget.setCurrentItem(toolBar) elif currentItem == self.tr("Worksheet"): self.contentsWidget.setCurrentItem(worksheet) elif currentItem == self.tr("Computation"): self.contentsWidget.setCurrentItem(computation) self.contentsWidget.currentItemChanged.connect(self.changePage)
def __init__(self, obj=None): """Initialize task panel.""" self.form = Gui.PySideUic.loadUi(TASKPAGE) self.tabs = self.form.RenderTabs self.tabs.setCurrentIndex(0) self.layout = self.tabs.findChild(QFormLayout, "FieldsLayout") self.material_type_combo = self.form.findChild(QComboBox, "MaterialType") # Initialize material name combo self.material_combo = self.form.MaterialNameLayout.itemAt(0).widget() self.existing_materials = { obj.Label: obj for obj in App.ActiveDocument.Objects if is_valid_material(obj) } self.material_combo.addItems(list(self.existing_materials.keys())) self.material_combo.currentTextChanged.connect( self.on_material_name_changed) # Initialize material type combo # Note: itemAt(0) is label, itemAt(1) is combo self.material_type_combo = self.form.findChild(QComboBox, "MaterialType") material_type_set = [MaterialSettingsTaskPanel.NONE_MATERIAL_TYPE ] + list(STD_MATERIALS) self.material_type_combo.addItems(material_type_set) self.material_type_combo.currentTextChanged.connect( self.on_material_type_changed) self._set_layout_visible("FieldsLayout", False) self.fields = [] # Initialize Father layout self._set_layout_visible("FatherLayout", False) self.father_field = self.form.FatherLayout.itemAt(1).widget() # Initialize Passthru Renderers selector rdrwidget = self.form.findChild(QListWidget, "Renderers") for rdr in VALID_RENDERERS: item = QListWidgetItem() item.setText(rdr) item.setIcon(QIcon(os.path.join(ICONDIR, f"{rdr}.svg"))) rdrwidget.addItem(item) rdrwidget.setViewMode(QListView.IconMode) rdrwidget.setIconSize(QSize(48, 48)) rdrwidget.setMaximumWidth(96) rdrwidget.setSpacing(6) rdrwidget.setMovement(QListView.Static) rdrwidget.currentTextChanged.connect( self.on_passthrough_renderer_changed) self.passthru_rdr = rdrwidget self.passthru = self.form.findChild(QPlainTextEdit, "PassthroughEdit") self.passthru.textChanged.connect(self.on_passthrough_text_changed) self.passthru_cache = {} self._set_layout_visible("PassthruLayout", False) # Get selected material and initialize material type combo with it selection = {obj.Label for obj in Gui.Selection.getSelection()} selected_materials = selection & self.existing_materials.keys() try: selected_material = selected_materials.pop() except KeyError: pass else: self.material_combo.setCurrentText(selected_material)