Python PyQt5.QtWidgets 模块,QListWidgetItem() 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用PyQt5.QtWidgets.QListWidgetItem()

项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def load_endpoints(self):
        self.choose_endpoint.endpoints.clear()

        for name in listdir(str(BASE_PATH / 'endpoints')):
            if name.endswith('.json'):
                item = QListWidgetItem(name.split('.json')[0], self.choose_endpoint.endpoints)
                item.setFlags(item.flags() & ~Qt.ItemIsEnabled)

                pb_msg_to_endpoints = defaultdict(list)
                with open(str(BASE_PATH / 'endpoints' / name)) as fd:
                    for endpoint in load(fd, object_pairs_hook=OrderedDict):
                        pb_msg_to_endpoints[endpoint['request']['proto_msg'].split('.')[-1]].append(endpoint)

                for pb_msg, endpoints in pb_msg_to_endpoints.items():
                    item = QListWidgetItem(' ' * 4 + pb_msg, self.choose_endpoint.endpoints)
                    item.setFlags(item.flags() & ~Qt.ItemIsEnabled)

                    for endpoint in endpoints:
                        path_and_qs = '/' + endpoint['request']['url'].split('/', 3).pop()
                        item = QListWidgetItem(' ' * 8 + path_and_qs, self.choose_endpoint.endpoints)
                        item.setData(Qt.UserRole, endpoint)

        self.set_view(self.choose_endpoint)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def set_listWidget(self):
        # Sets the default values if the fume is closed without any elements in listWidget
        # Important: These values are preset and defined in .ui file
        defaults = ['Noch keine Mannschaften hinzugefügt...', 'Region wählen und unten auf "+" klicken']
        elements = self.settings.value('filter', defaults)
        if elements != defaults and len(elements) != 0:
            self.listWidget.clear()
            for i in elements:
                item = QtWidgets.QListWidgetItem()
                item.setText(i[0])
                item.setData(QtCore.Qt.UserRole, i[1])
                self.listWidget.addItem(item)

        # Loading selected items
        for i in self.settings.value('filter_calendar', []):
            for j in self.listWidget.findItems(i, QtCore.Qt.MatchExactly):
                j.setSelected(True)

        self.itemSelection_changed()
        self.current_selection = [x for x in self.listWidget.selectedItems()]  # for restoring selection
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def ButtonAccepted(self):
        parentListWidget = self.parent().listWidget

        # adding new elements and restore selected teams
        restoredSelection = parentListWidget.selectedItems()

        # removing all elements from current region so that we can add all new ones withount duplicates
        items = [parentListWidget.item(i) for i in range(parentListWidget.count())]
        for i in items:
            if not i.isHidden():
                parentListWidget.takeItem(i.listWidget().row(i))

        # adding selected teams
        for i in self.listWidget.selectedItems():
            item = QtWidgets.QListWidgetItem()
            item.setText(i.text())
            item.setData(QtCore.Qt.UserRole, i.data(QtCore.Qt.UserRole))
            parentListWidget.addItem(item)

        parentListWidget.sortItems()

        for i in restoredSelection:
            for j in parentListWidget.findItems(i.text(), QtCore.Qt.MatchExactly):
                j.setSelected(True)
项目:OnCue    作者:featherbear    | 项目源码 | 文件源码
def createQListWidgetItem(self, data):
            """
            Creates a QListWidgetItem() instance given a file path 
            """
            item = QtWidgets.QListWidgetItem()
            path = data.toLocalFile()
            type = oncue.lib.utils.identifyFileType(path)
            item.setText(data.fileName())
            item.setData(256, {
                'type': type,
                'path': path
            })
            if type == "media":
                item.setToolTip(oncue.lib.utils.parseMedia(path))
            else:
                item.setToolTip("Path: " + path)
            return item
项目:DGP    作者:DynamicGravitySystems    | 项目源码 | 文件源码
def log_tree(self, index: QtCore.QModelIndex):
        item = self.prj_tree.model().itemFromIndex(index)  # type: QtWidgets.QListWidgetItem
        text = str(item.text())
        return
        # if text.startswith('Flight:'):
        #     self.log.debug("Clicked Flight object")
        #     _, flight_id = text.split(' ')
        #     flight = self.project.get_flight(flight_id)  # type: prj.Flight
        #     self.log.debug(flight)
        #     grav_data = flight.gravity
        #
        #     if grav_data is not None:
        #         self.log.debug(grav_data.describe())
        #     else:
        #         self.log.debug("No grav data")
        #
        # self.log.debug(text)
        #
        # self.log.debug(item.toolTip())
        # print(dir(item))

    #####
    # Plot functions
    #####
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def build(self, notes_list):
        """ Fill the list with notes from notes_list, coloring negatives one
            in red """
        self.nb_shown = 0
        current_time = time.time()
        for note in notes_list:
            widget = QtWidgets.QListWidgetItem(note["nickname"], self)
            if current_time - note["birthdate"] < 18 * 365 * 24 * 3600:
                if note['note'] < 0:
                    widget.setBackground(self.minors_overdraft)
                else:
                    widget.setBackground(self.minors_color)
            elif note['note'] < 0:
                widget.setBackground(self.overdraft_color)

            if not note['nickname'].lower().startswith(self.search_text):
                widget.setHidden(True)
                return
            self.nb_shown += 1
项目:mindfulness-at-the-computer    作者:SunyataZero    | 项目源码 | 文件源码
def update_gui(self):
        self.updating_gui_bool = True

        # If the list is now empty, disabling buttons
        # If the list is no longer empty, enable buttons
        self.set_button_states(mc.model.PhrasesM.is_empty())

        # List
        self.list_widget.clear()
        for l_phrase in mc.model.PhrasesM.get_all():
            # self.list_widget.addItem(l_collection.title_str)
            custom_label = CustomQLabel(l_phrase.title_str, l_phrase.id_int)
            list_item = QtWidgets.QListWidgetItem()
            self.list_widget.addItem(list_item)
            self.list_widget.setItemWidget(list_item, custom_label)

        self.updating_gui_bool = False
项目:mindfulness-at-the-computer    作者:SunyataZero    | 项目源码 | 文件源码
def update_gui(self):
        self.updating_gui_bool = True

        self.list_widget.clear()
        for rest_action in model.RestActionsM.get_all():
            rest_action_title_cll = CustomQLabel(rest_action.title_str, rest_action.id_int)
            list_item = QtWidgets.QListWidgetItem()
            self.list_widget.addItem(list_item)
            self.list_widget.setItemWidget(list_item, rest_action_title_cll)

        for i in range(0, self.list_widget.count()):
            item = self.list_widget.item(i)
            rest_qll = self.list_widget.itemWidget(item)
            logging.debug("custom_qll.question_entry_id = " + str(rest_qll.question_entry_id))
            if rest_qll.question_entry_id == mc_global.active_rest_action_id_it:
                item.setSelected(True)
                return

        self.updating_gui_bool = False
项目:gtrans-web-gui    作者:takiyu    | 项目源码 | 文件源码
def _init_candidate_list(self):
        self.cand_list = QtWidgets.QListWidget(self)

        # Double click or press enter to insert
        self.cand_list.itemDoubleClicked.connect(self._set_from_list)
        self.cand_list.focusOutEvent = lambda _: self.cand_list.hide()

        # The abbreviation for that language
        self.candidates = {
            "Auto": "auto", "Arabic": "ar", "Chinese": "zh-CN",
            "English": "en", "Esperanto": "eo", "French": "fr",
            "German": "de", "Greek": "el", "Italian": "it",
            "Japanese": "ja", "Korean": "ko", "Latin": "la",
            "Portugese": "pt-PT", "Russian": "ru", "Spanish": "es",
        }

        for candidate in self.candidates.keys():
            QtWidgets.QListWidgetItem(candidate, self.cand_list)

        self.cand_list.setGeometry(100, 100, 250, 300)
项目:DownloaderForReddit    作者:MalloyDelacroix    | 项目源码 | 文件源码
def setup_subreddit_content_list(self):
        """Sets up the subreddit content list with content that is in the currently selected subreddits directory"""
        self.subreddit_content_list.clear()
        try:
            folder_name = '%s%s/' % (self.current_sub.save_path, self.current_sub.name.lower())
            self.picture_list = self.extract_pictures(folder_name)
            if len(self.picture_list) > 0:
                for file in self.picture_list:
                    path, text = file.rsplit('/', 1)
                    item = QtWidgets.QListWidgetItem()
                    icon = QtGui.QIcon()
                    pixmap = QtGui.QPixmap(file).scaled(QtCore.QSize(500, 500), QtCore.Qt.KeepAspectRatio)
                    icon.addPixmap(pixmap)
                    item.setIcon(icon)
                    item.setText(text)
                    self.subreddit_content_list.addItem(item)
                    QtWidgets.QApplication.processEvents()

        except FileNotFoundError:
            self.subreddit_content_list.addItem('No content has been downloaded for this subreddit yet')
项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def load_extractors(self):
        self.choose_extractor.extractors.clear()

        for name, meta in extractors.items():
            item = QListWidgetItem(meta['desc'], self.choose_extractor.extractors)
            item.setData(Qt.UserRole, name)

        self.set_view(self.choose_extractor)
项目:pbtk    作者:marin-m    | 项目源码 | 文件源码
def new_endpoint(self, path):
        if not self.proto_fs.isDir(path):
            path = self.proto_fs.filePath(path)

            if not getattr(self, 'only_resp_combo', False):
                self.create_endpoint.pbRequestCombo.clear()
            self.create_endpoint.pbRespCombo.clear()

            has_msgs = False
            for name, cls in load_proto_msgs(path):
                has_msgs = True
                if not getattr(self, 'only_resp_combo', False):
                    self.create_endpoint.pbRequestCombo.addItem(name, (path, name))
                self.create_endpoint.pbRespCombo.addItem(name, (path, name))
            if not has_msgs:
                QMessageBox.warning(self.view, ' ', 'There is no message defined in this .proto.')
                return

            self.create_endpoint.reqDataSubform.hide()

            if not getattr(self, 'only_resp_combo', False):
                self.create_endpoint.endpointUrl.clear()
                self.create_endpoint.transports.clear()
                self.create_endpoint.sampleData.clear()
                self.create_endpoint.pbParamKey.clear()
                self.create_endpoint.parsePbCheckbox.setChecked(False)

                for name, meta in transports.items():
                    item = QListWidgetItem(meta['desc'], self.create_endpoint.transports)
                    item.setData(Qt.UserRole, (name, meta.get('ui_data_form')))

            elif getattr(self, 'saved_transport_choice'):
                self.create_endpoint.transports.setCurrentItem(self.saved_transport_choice)
                self.pick_transport(self.saved_transport_choice)
                self.saved_transport_choice = None

            self.only_resp_combo = False
            self.set_view(self.create_endpoint)
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __foundRepository( self, scm_type, project_path ):
        project_path = pathlib.Path( project_path )
        if project_path not in self.wizard_state.all_existing_project_paths:
            label = '%s: %s' % (scm_type, project_path)
            self.__all_labels_to_scm_info[ label ] = (scm_type, project_path)
            QtWidgets.QListWidgetItem( label, self.wc_list )

        self.__setFeedback()
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def set_listWidget(self):
        # Adding all teams from region to listWidget
        for i in range(0, self.listmodel.rowCount()):
            item = QtWidgets.QListWidgetItem()
            item.setText(self.listmodel.record(i).value('home'))
            item.setData(QtCore.Qt.UserRole, self.region)
            self.listWidget.addItem(item)

        # Selecting teams from parent listwidget
        for i in range(self.parent().listWidget.count()):
            for j in self.listWidget.findItems(self.parent().listWidget.item(i).text(), QtCore.Qt.MatchExactly):
                j.setSelected(True)
项目:OnCue    作者:featherbear    | 项目源码 | 文件源码
def playItem(self):
            """
            Plays the selected item
            """
            data = self.listItemsPrimary.currentItem().data(256)
            output.load(data)

            if data["type"] == "media":
                # Plays video
                self.mediaProgressBarThread.start()
                self.mediaProgressBarThread.setPriority(QtCore.QThread.TimeCriticalPriority)
                self.mediaControls_PLAY.click()
                self.contentControls.setCurrentIndex(2)

            elif data["type"] == "powerpoint":
                # Clear existing content in the slide preview list
                self.powerpointSlides.clear()

                # Connect to PowerPoint COM
                PPTApplication = win32com.client.Dispatch("PowerPoint.Application")
                Presentation = PPTApplication.Presentations.Open(data["path"].replace("/", "\\"),
                                                                 WithWindow=False)
                # Create slide previews
                temp = tempfile.TemporaryDirectory().name
                Presentation.Export(temp, "png")
                i = 1
                for file in glob.iglob(temp + "\\*.PNG"):
                    item = QtWidgets.QListWidgetItem()
                    item.setIcon(QtGui.QIcon(file))
                    item.setText(str(i))
                    item.setTextAlignment(QtCore.Qt.AlignCenter)
                    i += 1
                    self.powerpointSlides.addItem(item)
                self.contentControls.setCurrentIndex(1)
            else:
                # 'unknown' case - Hide controls
                self.contentControls.setCurrentIndex(0)
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def krakenMainAddFunc(self):
        if self.krakenMainList.count() == 1:
            self.error("This cannot have more than one color")
        else:
            hex_color = pick("Color")
            if hex_color is None:
                return
            color = "#" + hex_color.lower()
            actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
            if not actual:
                actual = closest
            self.krakenMainList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def krakenAlternateAddFunc(self):
        if self.krakenAlternateList.count() == 1:
            self.error("This cannot have more than one color")
        else:
            hex_color = pick("Color")
            if hex_color is None:
                return
            color = "#" + hex_color.lower()
            actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
            if not actual:
                actual = closest
            self.krakenAlternateList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def fixedAddFunc(self):
        if self.fixedList.count() == 1:
            self.error("Fixed cannot have more than one color")
        else:
            hex_color = pick("Color")
            if hex_color is None:
                return
            color = "#" + hex_color.lower()
            actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
            if not actual:
                actual = closest
            self.fixedList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def breathingAddFunc(self):
        color = "#" + pick("Color").lower()
        actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
        if not actual:
            actual = closest
        self.breathingList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def fadingAddFunc(self):
        hex_color = pick("Color")
        if hex_color is None:
            return
        color = "#" + hex_color.lower()
        actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
        if not actual:
            actual = closest
        self.fadingList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def coverMarqueeAddFunc(self):
        hex_color = pick("Color")
        if hex_color is None:
            return
        color = "#" + hex_color.lower()
        actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
        if not actual:
            actual = closest
        self.coverMarqueeList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def pulseAddFunc(self):
        color = "#" + pick("Color").lower()
        actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
        if not actual:
            actual = closest
        self.pulseList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def alternatingAddFunc(self):
        if self.alternatingList.count() == 2:
            self.error("Alternating cannot have more than two colors")
        else:
            hex_color = pick("Color")
            if hex_color is None:
                return
            color = "#" + hex_color.lower()
            actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
            if not actual:
                actual = closest
            self.alternatingList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def candleAddFunc(self):
        if self.candleList.count() == 1:
            self.error("Candle cannot have more than 1 color")
        else:
            hex_color = pick("Color")
            if hex_color is None:
                return
            color = "#" + hex_color.lower()
            actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
            if not actual:
                actual = closest
            self.candleList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def wingsAddFunc(self):
        if self.wingsList.count() == 1:
            self.error("Wings cannot have more than 1 color")
        else:
            hex_color = pick("Color")
            if hex_color is None:
                return
            color = "#" + hex_color.lower()
            actual, closest = get_colour_name(webcolors.hex_to_rgb(color))
            if not actual:
                actual = closest
            self.wingsList.addItem(QListWidgetItem(actual + "(" + color + ")"))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def profileAddFunc(self):
        hue.profile_add(self.profileName.text())
        self.profileList.addItem(QListWidgetItem(self.profileName.text()))
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
def profileListFunc(self):
        self.profileList.clear()
        if hue.profile_list():
            for p in hue.profile_list():
                self.profileList.addItem(QListWidgetItem(p))
项目:continuum    作者:zyantific    | 项目源码 | 文件源码
def update_binary_list(self, *_):
        binaries = Project.find_project_files(
            self._ui.project_path.text(),
            self._ui.file_patterns.text(),
        )

        self._ui.binary_list.clear()
        for cur_binary in binaries:
            item = QListWidgetItem(cur_binary)
            self._ui.binary_list.addItem(item)
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def __init__(self, listItem:QListWidgetItem, propertiesDockWidget:QDockWidget, sendMessageCallback, data=None):
        self.sendMessageCallback = sendMessageCallback
        self.scene = QNodeScene(ModulePickerDialog(sendMessageCallback))
        self.view = QNodeView()
        self.view.setScene(self.scene)
        self.scene.setSceneRect(-2500, -2500, 5000, 5000)   # TODO: Make this less shitty
        self.listItem = listItem
        self.id = self.listItem.data(Qt.UserRole)   # Get ID from the listitem
        self.dockWidget = propertiesDockWidget

        self.availableModules = searchModules()

        self.scene.selectionChanged.connect(self.sceneSelectionChanged)

        self.sheetMap = {}  # key: sheetid, value: sheetname   special thing for subsheets so you can pick a subsheet. FIXME: Make this less special-casey

        # --- Pass scene changes
        self.sceneUndoStackIndexChangedCallback = None
        self.scene.undostack.indexChanged.connect(self.sceneUndoStackIndexChanged)

        self.workerManagerSendNodeData = None

        if data is not None:
            self.deserialize(data)
        else:
            self.initnode = InitNode()
            self.scene.addItem(self.initnode)
            self.loopnode = LoopNode()
            self.scene.addItem(self.loopnode)
            self.loopnode.setPos(QPointF(0, 100))

            self.name = self.listItem.text()
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def loadFromFile(self, path):
        """Load project from file"""
        self.filePath = path

        with open(path, "r") as f:
            data = json.load(f)

        for sheetdata in data["sheets"]:
            newTreeItem = QListWidgetItem(sheetdata["name"], self.ui.sheetListWidget)
            newTreeItem.setData(Qt.UserRole, sheetdata["uuid"])  # Add some uniquely identifying data to make it hashable


            self.newSheet(newTreeItem, sheetdata)
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def addSheetPushButtonClicked(self, checked):
        if self.ui.addSheetLineEdit.text():     # If the text field isn't empty
            newTreeItem = QListWidgetItem(self.ui.addSheetLineEdit.text(), self.ui.sheetListWidget)
            newTreeItem.setData(Qt.UserRole, uuid.uuid4().int)  # Add some uniquely identifying data to make it hashable
            self.currentProject.newSheet(newTreeItem)
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def updateSheets(self):
        if self.sheets is not None and self.ownsheet is not None:
            self.listSheetItems = {}
            self.listWidget.clear()
            for sheetId in self.sheets:
                if not sheetId == self.ownsheet:
                    newItem = QListWidgetItem(self.sheets[sheetId])
                    newItem.setToolTip(str(sheetId))
                    newItem.setData(Qt.UserRole, sheetId)
                    self.listSheetItems[sheetId] = newItem
                    self.listWidget.addItem(newItem)

                    if sheetId == self.selectedSheet:
                        boldFont = QFont()
                        boldFont.setBold(True)
                        newItem.setFont(boldFont)
项目:PySAT    作者:USGS-Astrogeology    | 项目源码 | 文件源码
def make_listwidget(choices):
    listwidget = QtWidgets.QListWidget()
    listwidget.setItemDelegate
    for item in choices:
        item = QtWidgets.QListWidgetItem(item)
        listwidget.addItem(item)
    return listwidget
项目:BATS-Bayesian-Adaptive-Trial-Simulator    作者:ContaTP    | 项目源码 | 文件源码
def __init__(self, parent=None):

        QtWidgets.QListWidget.__init__(self, parent)
        self.parent = parent
        self.setFocusPolicy(False)
        self.horizontalScrollBar().setVisible(False)
        # Customize the list widget
        self.setIconSize(QtCore.QSize(60, 60))
        # Icon only
        self.settingItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_setting.png"), "")
        self.settingItem.setToolTip("Setting")
        self.logItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_log.png"), "")
        self.logItem.setToolTip("Log")
        self.tableItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_table.png"), "")
        self.tableItem.setToolTip("Results")
        self.plotItem = QtWidgets.QListWidgetItem(QtGui.QIcon(":/resources/result_plot.png"), "")
        self.plotItem.setToolTip("Plots")
        self.addItem(self.settingItem)
        self.addItem(self.logItem)
        self.addItem(self.tableItem)
        self.addItem(self.plotItem)

        # Hide icon
        self.settingItem.setHidden(True)
        self.logItem.setHidden(True)
        self.tableItem.setHidden(True)
        self.plotItem.setHidden(True)

        # Stylesheet
        self.setStyleSheet("QListWidget{min-width:90px; background:#f7fafc;border:none;border-left: 2px solid #e9f0f5;}QListWidget::item{background: #f7fafc;background-origin: cotent;background-clip: margin;color: #000000;margin: 0 0 0 10px;padding: 25px 0 25px 0px;}QListWidget::item:selected{background: #bac3ef;position: fixed;}QLabel{background: transparent;border: none;}")

        # Signal
        self.currentRowChanged.connect(self.viewChange)


    # Swith function
项目:DGP    作者:DynamicGravitySystems    | 项目源码 | 文件源码
def set_recent_list(self) -> None:
        recent_files = self.get_recent_files(self.recent_file)
        if not recent_files:
            no_recents = QtWidgets.QListWidgetItem("No Recent Projects", self.list_projects)
            no_recents.setFlags(QtCore.Qt.NoItemFlags)
            return None

        for name, path in recent_files.items():
            item = QtWidgets.QListWidgetItem('{name} :: {path}'.format(name=name, path=str(path)), self.list_projects)
            item.setData(QtCore.Qt.UserRole, path)
            item.setToolTip(str(path.resolve()))
        self.list_projects.setCurrentRow(0)
        return None
项目:DGP    作者:DynamicGravitySystems    | 项目源码 | 文件源码
def set_selection(self, item: QtWidgets.QListWidgetItem, *args):
        """Called when a recent item is selected"""
        self.project_path = get_project_file(item.data(QtCore.Qt.UserRole))
        if not self.project_path:
            # TODO: Fix this, when user selects item multiple time the statement is re-appended
            item.setText("{} - Project Moved or Deleted".format(item.data(QtCore.Qt.UserRole)))

        self.log.debug("Project path set to {}".format(self.project_path))
项目:TrezorSymmetricFileEncryption    作者:8go    | 项目源码 | 文件源码
def __init__(self, deviceMap):
        """
        Create dialog and fill it with labels from deviceMap

        @param deviceMap: dict device string -> device label
        """
        QDialog.__init__(self)
        self.setupUi(self)

        for deviceStr, label in deviceMap.items():
            item = QListWidgetItem(label)
            item.setData(Qt.UserRole, QVariant(deviceStr))
            self.trezorList.addItem(item)
        self.trezorList.setCurrentRow(0)
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def create_panel_list(self):
        """ Create the list of panels on the left.
        """
        self.panel_list = []
        for panel in api.panels.get():
            self.panel_list.append(QtWidgets.QListWidgetItem(
                panel["name"], self.panels))
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def accept(self):
        """ Called when "Ajouter" is clicked
        """
        if self.name_input.text():
            if not api.panels.add(self.name_input.text()):
                gui.utils.error("Erreur", "Impossible d'ajouter le panel")
            else:
                self.panel_list.append(QtWidgets.QListWidgetItem(
                    self.name_input.text(), self.panels))
            self.name_input.setText("")
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def __init__(self, parent):
        super().__init__(parent)
        super().setSortingEnabled(True)
        self.widgets = []
        for user in users.get_list():
            widget = QtWidgets.QListWidgetItem(user, self)
            self.widgets.append(widget)
        if self.widgets:
            self.widgets[0].setSelected(True)
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def refresh(self):
        """ Refesh list and add user which are not present
        """
        user_list = list(users.get_list())
        # Add added users
        for user in user_list:
            if user not in [w.text() for w in self.widgets]:
                self.widgets.append(QtWidgets.QListWidgetItem(user, self))

        # Remove deleted users
        for widget in self.widgets:
            if widget.text() not in user_list:
                item = self.takeItem(self.row(widget))
                self.widgets.pop(self.widgets.index(widget))
                del item
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def __init__(self, cid, pid, name, cat_name, prices, percentage=None):
        QtWidgets.QComboBox.__init__(self)
        BaseProduct.__init__(self, cid, pid, name, cat_name, prices)
        self.product_view = QtWidgets.QListWidget()
        self.product_view.wheelEvent = self.on_wheel
        self.setModel(self.product_view.model())
        self.widgets = []
        self.call = None
        self.should_accept_adding_products = False

        self.name_item = QtWidgets.QListWidgetItem("")
        self.name_layout = QtWidgets.QHBoxLayout()
        self.setLayout(self.name_layout)

        if percentage:
            self.name_label = QtWidgets.QLabel(f"{name} <span style=\"color: red; font-size: 7px\">{percentage} °</span>", self)
        else:
            self.name_label = QtWidgets.QLabel(name)
        self.name_label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
        self.name_layout.addWidget(self.name_label)

        self.product_view.addItem(self.name_item)
        for price in prices:
            widget = QtWidgets.QListWidgetItem(price)
            widget.setTextAlignment(QtCore.Qt.AlignHCenter |
                QtCore.Qt.AlignVCenter)
            widget.setSizeHint(QtCore.QSize(100, 35))
            self.product_view.addItem(widget)

        self.setView(self.product_view)
        self.activated.connect(self.callback)
        self.product_view.pressed.connect(self.on_click)
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def fill_store(self):
        self.materials.clear()
        print(get_materials_path())
        all_files=find_materials()
        for fl in all_files:
            text=get_ref_text(os.path.join(get_materials_path(),fl,"n.omat"),html=False)
            if text!=None:
                itm = QListWidgetItem(os.path.basename(fl)+" "+text)
                itm.setIcon(self.mat_icon)
                itm.setToolTip(text)
                self.materials.addItem(itm)
项目:Worksets    作者:DozyDolphin    | 项目源码 | 文件源码
def _populate_app_list(self):
        self.app_list.clear()
        for app in self.apps:
            item = QtWidgets.QListWidgetItem(app.name)
            self.app_list.addItem(item)
项目:Worksets    作者:DozyDolphin    | 项目源码 | 文件源码
def _app_dialog(self, item):
        if isinstance(item, QtWidgets.QListWidgetItem):
            app = next((app for app in self.apps if app.name == item.text()), None)
            app_dialog = AppDialog(self.controller, app=app, parent=self)
        else:
            app_dialog = AppDialog(self.controller, parent=self)
        app_dialog.app_changed.connect(self.add_or_update_app)
        app_dialog.exec_()
项目:Worksets    作者:DozyDolphin    | 项目源码 | 文件源码
def _populate_workset_list(self):
        self.workset_list.clear()
        self.worksets = self.controller.get_worksets()
        for workset in self.worksets:
            item = QtWidgets.QListWidgetItem(workset.name)
            self.workset_list.addItem(item)
        self.workset_list.itemDoubleClicked.connect(self.workset_dialog)
项目:Worksets    作者:DozyDolphin    | 项目源码 | 文件源码
def workset_dialog(self, item):
        if isinstance(item, QtWidgets.QListWidgetItem):
            workset = next((workset
                            for workset
                            in self.worksets
                            if workset.name == item.text()),
                           None)
            workset_dialog = WorksetDialog(self.controller, workset)
        else:
            workset_dialog = WorksetDialog(self.controller)
        workset_dialog.exec_()
项目:mindfulness-at-the-computer    作者:SunyataZero    | 项目源码 | 文件源码
def update_gui(self):
        self.updating_gui_bool = True

        self.list_widget.clear()
        for rest_action in model.RestActionsM.get_all():
            rest_action_title_cll = RestQLabel(rest_action.title_str, rest_action.id_int)
            list_item = QtWidgets.QListWidgetItem()
            self.list_widget.addItem(list_item)
            self.list_widget.setItemWidget(list_item, rest_action_title_cll)

        # self.update_gui_details()

        self.updating_gui_bool = False
项目:decentralized-chat    作者:Phil9l    | 项目源码 | 文件源码
def add_user(self, username, me=False):
        self.textBrowser.append('<i>New user in the chat: {}</i>'.format(username))
        _translate = QtCore.QCoreApplication.translate
        item = QtWidgets.QListWidgetItem()
        item.setText(_translate("MainWindow", username))

        if me:
            font = QtGui.QFont()
            font.setBold(True)
            item.setFont(font)

        self.listWidget.addItem(item)