python类QListWidgetItem()的实例源码

gui.py 文件源码 项目:pbtk 作者: marin-m 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
app.py 文件源码 项目:FuME 作者: fupadev 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
FilterDialog.py 文件源码 项目:FuME 作者: fupadev 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:OnCue 作者: featherbear 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
main.py 文件源码 项目:DGP 作者: DynamicGravitySystems 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
    #####
notes_list_widget.py 文件源码 项目:Enibar 作者: ENIB 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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
breathing_phrase_list_wt.py 文件源码 项目:mindfulness-at-the-computer 作者: SunyataZero 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
experimental_list_widget.py 文件源码 项目:mindfulness-at-the-computer 作者: SunyataZero 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
window.py 文件源码 项目:gtrans-web-gui 作者: takiyu 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
SubredditSettingsDialog.py 文件源码 项目:DownloaderForReddit 作者: MalloyDelacroix 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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')
gui.py 文件源码 项目:pbtk 作者: marin-m 项目源码 文件源码 阅读 74 收藏 0 点赞 0 评论 0
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)
gui.py 文件源码 项目:pbtk 作者: marin-m 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
wb_scm_project_dialogs.py 文件源码 项目:scm-workbench 作者: barry-scott 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
FilterDialog.py 文件源码 项目:FuME 作者: fupadev 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:OnCue 作者: featherbear 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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 + ")"))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def profileAddFunc(self):
        hue.profile_add(self.profileName.text())
        self.profileList.addItem(QListWidgetItem(self.profileName.text()))
ui.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def profileListFunc(self):
        self.profileList.clear()
        if hue.profile_list():
            for p in hue.profile_list():
                self.profileList.addItem(QListWidgetItem(p))
ui.py 文件源码 项目:continuum 作者: zyantific 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)
main.py 文件源码 项目:pyree-old 作者: DrLuke 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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()
main.py 文件源码 项目:pyree-old 作者: DrLuke 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号