def get_input(self, obj, key): lb = self.lb_objects for item_index in range(lb.count()): if lb.item(item_index).data(Qt.UserRole) == key: break else: item_index = None if obj is None: if item_index is None: return del self.objects[key] lb.takeItem(item_index) if not self.objects: self.send("Object", None) return else: self.objects[key] = obj item_desc = "{} {}".format( type(obj).__name__, getattr(obj, "name", "")) if item_index is None: item = QListWidgetItem(item_desc) item.setData(Qt.UserRole, key) lb.addItem(item) lb.setCurrentItem(item) else: lb.item(item_index).setText(item_desc) self._on_selection_change()
def __init__(self, rgbColors, parent=None, windowTitle="Palette Editor", **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(4, 4, 4, 4) hbox = gui.hBox(self, "Information") gui.widgetLabel( hbox, '<p align="center">You can reorder colors in the list using the' "<br/>buttons on the right or by dragging and dropping the items." "<br/>To change a specific color double click the item in the " "list.</p>", ) hbox = gui.hBox(self, box=True) self.discListbox = gui.listBox(hbox, self, enableDragDrop=1) vbox = gui.vBox(hbox) buttonUPAttr = gui.button(vbox, self, "", callback=self.moveAttrUP, tooltip="Move selected colors up") buttonDOWNAttr = gui.button( vbox, self, "", callback=self.moveAttrDOWN, tooltip="Move selected colors down", ) buttonUPAttr.setIcon(QIcon(gui.resource_filename("icons/Dlg_up3.png"))) buttonUPAttr.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)) buttonUPAttr.setMaximumWidth(30) buttonDOWNAttr.setIcon( QIcon(gui.resource_filename("icons/Dlg_down3.png"))) buttonDOWNAttr.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)) buttonDOWNAttr.setMaximumWidth(30) self.discListbox.itemDoubleClicked.connect(self.changeDiscreteColor) box = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, accepted=self.accept, rejected=self.reject, ) self.layout().addWidget(box) self.discListbox.setIconSize(QSize(25, 25)) for ind, (r, g, b) in enumerate(rgbColors): item = QListWidgetItem(ColorPixmap(QColor(r, g, b), 25), "Color %d" % (ind + 1)) item.rgbColor = (r, g, b) self.discListbox.addItem(item) self.resize(300, 300)
def update_list(self, current_word): """ Update the displayed list by filtering self.completion_list based on the current_word under the cursor (see check_can_complete). If we're not updating the list with new completions, we filter out textEdit completions, since it's difficult to apply them correctly after the user makes edits. If no items are left on the list the autocompletion should stop """ self.clear() self.display_index = [] height = self.item_height width = self.item_width if current_word: for c in self.completion_list: c['end'] = c['start'] + len(current_word) for i, completion in enumerate(self.completion_list): text = completion['text'] if not self.check_can_complete(text, current_word): continue item = QListWidgetItem() self.set_item_display( item, completion, height=height, width=width) item.setData(Qt.UserRole, completion) self.addItem(item) self.display_index.append(i) if self.count() == 0: self.hide()
def __add__(self, val): if isinstance(val, (tuple, list)): item = QListWidgetItem(str(val[0])) item.value = val[0] if val[1]: item.setCheckState(QtCore.Qt.Checked) else: item.setCheckState(QtCore.Qt.Unchecked) else: item = QListWidgetItem(str(val)) item.value = val self._form.listWidget.addItem(item) return self
def testConv(self, meineAdr): """Save a pdf of a docx file.""" try: meineDocx = meineAdr + '.docx' word = client.DispatchEx("Word.Application") target_path = meineDocx.replace(".docx", r".pdf") if path.exists(target_path): buttonReply = LIMASCalc.QMessageBox.question( self, 'Achtung', "Bericht existiert bereits, soll die PDF ersetzt werden?", LIMASCalc.QMessageBox.Yes | LIMASCalc.QMessageBox.No, LIMASCalc.QMessageBox.No) if buttonReply == LIMASCalc.QMessageBox.Yes: os.remove(target_path) self.infoPopUp("Die Datei wurde erfolgreich ersetzt.", "Erledigt") word_doc = word.Documents.Open(meineDocx) word_doc.SaveAs(target_path, FileFormat=17) word_doc.Close() #os.startfile(target_path) word.Quit() else: pass else: word_doc = word.Documents.Open(meineDocx) word_doc.SaveAs(target_path, FileFormat=17) word_doc.Close() #os.startfile(target_path) word.Quit() #self.makeMyPDF(target_path) item = QListWidgetItem(target_path) self.y.listWidget.addItem(item) self.y.listWidget.scrollToBottom() except Exception as e: raise e
def __init__(self, rgbColors, parent=None, windowTitle="Palette Editor", **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(4, 4, 4, 4) hbox = gui.hBox(self, "Information") gui.widgetLabel( hbox, '<p align="center">You can reorder colors in the list using the' '<br/>buttons on the right or by dragging and dropping the items.' '<br/>To change a specific color double click the item in the ' 'list.</p>') hbox = gui.hBox(self, box=True) self.discListbox = gui.listBox(hbox, self, enableDragDrop=1) vbox = gui.vBox(hbox) buttonUPAttr = gui.button(vbox, self, "", callback=self.moveAttrUP, tooltip="Move selected colors up") buttonDOWNAttr = gui.button(vbox, self, "", callback=self.moveAttrDOWN, tooltip="Move selected colors down") buttonUPAttr.setIcon(QIcon(gui.resource_filename("icons/Dlg_up3.png"))) buttonUPAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)) buttonUPAttr.setMaximumWidth(30) buttonDOWNAttr.setIcon(QIcon(gui.resource_filename("icons/Dlg_down3.png"))) buttonDOWNAttr.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)) buttonDOWNAttr.setMaximumWidth(30) self.discListbox.itemDoubleClicked.connect(self.changeDiscreteColor) box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, accepted=self.accept, rejected=self.reject) self.layout().addWidget(box) self.discListbox.setIconSize(QSize(25, 25)) for ind, (r, g, b) in enumerate(rgbColors): item = QListWidgetItem(ColorPixmap(QColor(r, g, b), 25), "Color %d" % (ind + 1)) item.rgbColor = (r, g, b) self.discListbox.addItem(item) self.resize(300, 300)
def textHinzu(self): self.meinText = self.y.lineEdit_28.text() item = QListWidgetItem(self.meinText) self.y.listWidget.addItem(item) self.y.listWidget.scrollToBottom()