Python PyQt5.QtGui 模块,QStandardItemModel() 实例源码

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

项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def init_widget(self):
        self.setWindowTitle("Hello World")
        widget_laytout = QBoxLayout(QBoxLayout.LeftToRight)

        group = QGroupBox()
        box = QBoxLayout(QBoxLayout.TopToBottom)
        group.setLayout(box)
        group.setTitle("Buttons")
        widget_laytout.addWidget(group)

        fruits = ["Buttons in GroupBox", "TextBox in GroupBox", "Label in GroupBox", "TextEdit"]
        view = QListView(self)
        model = QStandardItemModel()
        for f in fruits:
            model.appendRow(QStandardItem(f))
        view.setModel(model)
        box.addWidget(view)

        self.stk_w.addWidget(Widget_1())
        self.stk_w.addWidget(Widget_2())
        self.stk_w.addWidget(Widget_3())
        self.stk_w.addWidget(QTextEdit())

        widget_laytout.addWidget(self.stk_w)
        self.setLayout(widget_laytout)

        # ??? ?? ??
        view.clicked.connect(self.slot_clicked_item)
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def setupGUI(self):
        # GUI Mods
        self.model = QtGui.QStandardItemModel(self.ui.listDatenbank)
        self.ui.listDatenbank.setModel(self.model)
        self.ui.listDatenbank.doubleClicked["QModelIndex"].connect(self.listItemEvent)
        self.ui.showTalente.stateChanged.connect(self.updateGUI)
        self.ui.showVorteile.stateChanged.connect(self.updateGUI)
        self.ui.showFertigkeiten.stateChanged.connect(self.updateGUI)
        self.ui.showUebernatuerlicheFertigkeiten.stateChanged.connect(self.updateGUI)
        self.ui.showWaffen.stateChanged.connect(self.updateGUI)
        self.ui.buttonLoadDB.clicked.connect(self.loadDatenbank)
        self.ui.buttonSaveDB.clicked.connect(self.saveDatenbank)
        self.ui.buttonEditieren.clicked.connect(self.editSelected)
        self.ui.buttonLoeschen.clicked.connect(self.deleteSelected)
        self.ui.buttonHinzufuegen.clicked.connect(self.hinzufuegen)
        self.updateGUI()
项目:opcua-modeler    作者:FreeOpcUa    | 项目源码 | 文件源码
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        self.nodesets = []
        self.server_mgr = None
        self._nodeset_to_delete = None
        self.view.header().setSectionResizeMode(1)

        addNodeSetAction = QAction("Add Reference Node Set", self.model)
        addNodeSetAction.triggered.connect(self.add_nodeset)
        self.removeNodeSetAction = QAction("Remove Reference Node Set", self.model)
        self.removeNodeSetAction.triggered.connect(self.remove_nodeset)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(addNodeSetAction)
        self._contextMenu.addAction(self.removeNodeSetAction)
项目:opcua-modeler    作者:FreeOpcUa    | 项目源码 | 文件源码
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        delegate = MyDelegate(self.view, self)
        delegate.error.connect(self.error.emit)
        self.view.setItemDelegate(delegate)
        self.node = None
        self.view.header().setSectionResizeMode(1)

        self.addNamespaceAction = QAction("Add Namespace", self.model)
        self.addNamespaceAction.triggered.connect(self.add_namespace)
        self.removeNamespaceAction = QAction("Remove Namespace", self.model)
        self.removeNamespaceAction.triggered.connect(self.remove_namespace)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(self.addNamespaceAction)
        self._contextMenu.addAction(self.removeNamespaceAction)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def setupModel(self):
        self.model = QStandardItemModel(5, 3, self)
        names = ("Alice", "Bob", "Carol", "Donald", "Emma")
        addresses = ("<qt>123 Main Street<br/>Market Town</qt>",
                     "<qt>PO Box 32<br/>Mail Handling Service"
                     "<br/>Service City</qt>",
                     "<qt>The Lighthouse<br/>Remote Island</qt>",
                     "<qt>47338 Park Avenue<br/>Big City</qt>",
                     "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>")
        ages = ("20", "31", "32", "19", "26")

        for row, name in enumerate(names):
            item = QStandardItem(name)
            self.model.setItem(row, 0, item)
            item = QStandardItem(addresses[row])
            self.model.setItem(row, 1, item)
            item = QStandardItem(ages[row])
            self.model.setItem(row, 2, item)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def setupModel(self):
        items = ("Home", "Work", "Other")
        self.typeModel = QStringListModel(items, self)

        self.model = QStandardItemModel(5, 3, self)

        names = ("Alice", "Bob", "Carol", "Donald", "Emma")
        addresses = ("<qt>123 Main Street<br/>Market Town</qt>",
                     "<qt>PO Box 32<br/>Mail Handling Service"
                     "<br/>Service City</qt>",
                     "<qt>The Lighthouse<br/>Remote Island</qt>",
                     "<qt>47338 Park Avenue<br/>Big City</qt>",
                     "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>")
        types = ("0", "1", "2", "0", "2")

        for row, name in enumerate(names):
            item = QStandardItem(name)
            self.model.setItem(row, 0, item)
            item = QStandardItem(addresses[row])
            self.model.setItem(row, 1, item)
            item = QStandardItem(types[row])
            self.model.setItem(row, 2, item)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def setupModel(self):
        self.model = QStandardItemModel(5, 3, self)
        names = ("Alice", "Bob", "Carol", "Donald", "Emma")
        addresses = ("<qt>123 Main Street<br/>Market Town</qt>",
                     "<qt>PO Box 32<br/>Mail Handling Service"
                     "<br/>Service City</qt>",
                     "<qt>The Lighthouse<br/>Remote Island</qt>",
                     "<qt>47338 Park Avenue<br/>Big City</qt>",
                     "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>")
        ages = ("20", "31", "32", "19", "26")

        for row, name in enumerate(names):
            item = QStandardItem(name)
            self.model.setItem(row, 0, item)
            item = QStandardItem(addresses[row])
            self.model.setItem(row, 1, item)
            item = QStandardItem(ages[row])
            self.model.setItem(row, 2, item)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def setupModel(self):
        items = ("Home", "Work", "Other")
        self.typeModel = QStringListModel(items, self)

        self.model = QStandardItemModel(5, 3, self)

        names = ("Alice", "Bob", "Carol", "Donald", "Emma")
        addresses = ("<qt>123 Main Street<br/>Market Town</qt>",
                     "<qt>PO Box 32<br/>Mail Handling Service"
                     "<br/>Service City</qt>",
                     "<qt>The Lighthouse<br/>Remote Island</qt>",
                     "<qt>47338 Park Avenue<br/>Big City</qt>",
                     "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>")
        types = ("0", "1", "2", "0", "2")

        for row, name in enumerate(names):
            item = QStandardItem(name)
            self.model.setItem(row, 0, item)
            item = QStandardItem(addresses[row])
            self.model.setItem(row, 1, item)
            item = QStandardItem(types[row])
            self.model.setItem(row, 2, item)
项目:ETS2Autopilot    作者:BrunoTh    | 项目源码 | 文件源码
def fill_sequence_list(self):
        """
        Fill sequence_list with data.
        """
        data = Data()
        sequence_list = self.ui.sequence_list

        model = QStandardItemModel(sequence_list)
        sequences = data.get_sequence_list()
        if len(sequences) > 0:
            for sequence in sequences:
                note = ""
                if sequence[4] is not None:
                    note = " - %s" % sequence[4]
                item = QStandardItem("%s%s" % (sequence[1], note))
                item.setEditable(False)
                item.setData(str(sequence[0]), QtCore.Qt.UserRole)
                model.insertRow(0, item)
        sequence_list.setModel(model)
项目:ETS2Autopilot    作者:BrunoTh    | 项目源码 | 文件源码
def fill_image_list(self):
        """
        Fill list_image with data.
        """
        data = Data()
        list_images = self.ui.list_images

        model = QStandardItemModel(list_images)
        images = data.get_image_list(self.sequence_id)
        if len(images) > 0:
            for image in images:
                item = QStandardItem("%s - %s" % (image[1], functions.get_indicator(image[5])))
                item.setEditable(False)
                item.setData(str(image[0]), QtCore.Qt.UserRole)
                model.appendRow(item)
        list_images.setModel(model)
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def _model_builder(self, model, data, initialize=False):
            '''
            Build the function model.
            @param model: QStandardItemModel object
            '''
            if initialize:
                model.clear()  # Clear the model
                FIRSTUI.SharedObjects.make_model_headers(model)

            if not data:
                return

            model.add_data(data)

            # Add db functions to the model
            root_node = model.invisibleRootItem()
            for address, matches in data.iteritems():
                function = FIRST.Metadata.get_function(address)

                func_row = self._make_function_item(function, len(matches))
                root_node.appendRow(func_row)

                for match in matches:
                    info_list = FIRSTUI.SharedObjects.make_match_info(match)
                    func_row[0].appendRow(info_list)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def setupModel(self):
        self.model = QStandardItemModel(5, 3, self)
        names = ("Alice", "Bob", "Carol", "Donald", "Emma")
        addresses = ("<qt>123 Main Street<br/>Market Town</qt>",
                     "<qt>PO Box 32<br/>Mail Handling Service"
                     "<br/>Service City</qt>",
                     "<qt>The Lighthouse<br/>Remote Island</qt>",
                     "<qt>47338 Park Avenue<br/>Big City</qt>",
                     "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>")
        ages = ("20", "31", "32", "19", "26")

        for row, name in enumerate(names):
            item = QStandardItem(name)
            self.model.setItem(row, 0, item)
            item = QStandardItem(addresses[row])
            self.model.setItem(row, 1, item)
            item = QStandardItem(ages[row])
            self.model.setItem(row, 2, item)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def setupModel(self):
        items = ("Home", "Work", "Other")
        self.typeModel = QStringListModel(items, self)

        self.model = QStandardItemModel(5, 3, self)

        names = ("Alice", "Bob", "Carol", "Donald", "Emma")
        addresses = ("<qt>123 Main Street<br/>Market Town</qt>",
                     "<qt>PO Box 32<br/>Mail Handling Service"
                     "<br/>Service City</qt>",
                     "<qt>The Lighthouse<br/>Remote Island</qt>",
                     "<qt>47338 Park Avenue<br/>Big City</qt>",
                     "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>")
        types = ("0", "1", "2", "0", "2")

        for row, name in enumerate(names):
            item = QStandardItem(name)
            self.model.setItem(row, 0, item)
            item = QStandardItem(addresses[row])
            self.model.setItem(row, 1, item)
            item = QStandardItem(types[row])
            self.model.setItem(row, 2, item)
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def __init__(self, on_change: callable, choices: list = None, parent=None, model: QStandardItemModel = None):
        QComboBox.__init__(self, parent=parent)
        self.on_change = on_change
        if choices:
            self.addItems(choices)
        if model:
            self.setModel(model)
            # noinspection PyUnresolvedReferences
            model.modelAboutToBeReset.connect(self.begin_reset_model)
            # noinspection PyUnresolvedReferences
            model.modelReset.connect(self.end_reset_model)
        # noinspection PyUnresolvedReferences
        self.activated.connect(on_change)
        self._current_text = None
项目:git-annex-metadata-gui    作者:alpernebbi    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        self._set = {'foo', 'bar'}

        self._model = QtGui.QStandardItemModel()
        self._model.appendRow(self)
项目:mnelab    作者:cbrnr    | 项目源码 | 文件源码
def __init__(self, parent, info, title="Channel Properties"):
        super().__init__(parent)
        self.setWindowTitle(title)

        self.model = QStandardItemModel(info["nchan"], 4)
        self.model.setHorizontalHeaderLabels(["#", "Label", "Type", "Bad"])
        for index, ch in enumerate(info["chs"]):
            item = QStandardItem()
            item.setData(index, Qt.DisplayRole)
            item.setFlags(item.flags() & ~Qt.ItemIsEditable)
            self.model.setItem(index, 0, item)
            self.model.setItem(index, 1, QStandardItem(ch["ch_name"]))
            kind = channel_type(info, index).upper()
            self.model.setItem(index, 2, QStandardItem(str(kind)))
            bad = QStandardItem()
            bad.setData(ch["ch_name"] in info["bads"], Qt.UserRole)
            bad.setCheckable(True)
            bad.setEditable(False)
            checked = ch["ch_name"] in info["bads"]
            bad.setCheckState(Qt.Checked if checked else Qt.Unchecked)
            self.model.setItem(index, 3, bad)

        self.model.itemChanged.connect(bad_changed)
        self.proxymodel = MySortFilterProxyModel()
        self.proxymodel.setSourceModel(self.model)

        self.view = QTableView()
        self.view.setModel(self.proxymodel)
        self.view.setItemDelegateForColumn(2, ComboBoxDelegate(self.view))
        self.view.setEditTriggers(QAbstractItemView.AllEditTriggers)
        self.view.verticalHeader().setVisible(False)
        self.view.horizontalHeader().setStretchLastSection(True)
        self.view.setShowGrid(False)
        self.view.setSelectionMode(QAbstractItemView.NoSelection)
        self.view.setSortingEnabled(True)
        self.view.sortByColumn(0, Qt.AscendingOrder)
        self.view.resizeColumnsToContents()
        # for i in range(self.model.rowCount()):
        #         self.view.openPersistentEditor(self.model.index(i, 2))

        vbox = QVBoxLayout(self)
        vbox.addWidget(self.view)
        self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok |
                                          QDialogButtonBox.Cancel)
        vbox.addWidget(self.buttonbox)
        self.buttonbox.accepted.connect(self.accept)
        self.buttonbox.rejected.connect(self.reject)

        self.resize(400, 650)
项目:acbDecrypter    作者:Rieksee    | 项目源码 | 文件源码
def read_file(self, file):
        if file is None:
            return
        with open(file, 'r') as f:
            for line in f:
                lis = line.split(' : ')
                if len(lis) != 2:
                    continue
                key = (lis[1], lis[0])
                self.keys.append(key)
        self.ui.model = QtGui.QStandardItemModel(self.ui.listView)
        for key in self.keys:
            item = QtGui.QStandardItem(key[0].rstrip('\n'))
            self.ui.model.appendRow(item)
        self.ui.listView.setModel(self.ui.model)
项目:acbDecrypter    作者:Rieksee    | 项目源码 | 文件源码
def read_file(self, file):
        with open(file, 'r') as f:
            for line in f:
                lis = line.split(' : ')
                if len(lis) != 2:
                    continue
                key = (lis[1], lis[0])
                self.keys.append(key)
        self.ui.model = QtGui.QStandardItemModel(self.ui.listView)
        for key in self.keys:
            item = QtGui.QStandardItem(key[0].rstrip('\n'))
            self.ui.model.appendRow(item)
        self.ui.listView.setModel(self.ui.model)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def buildEntitiesTree(self, entities_list):
        """
        This method populates the Entities (blocks) QTreeView with
        all the elements contained in the entities_list
        Method must be called each time a new .dxf file is loaded.
        options
        @param entities_list: list of the layers and shapes (created in the main)
        """

        self.entities_list = entities_list
        if self.entity_item_model:
            self.entity_item_model.clear()  # Remove any existing item_model
        self.entity_item_model = QStandardItemModel()
        self.entity_item_model.setHorizontalHeaderItem(0, QStandardItem(self.tr("[en]")))
        self.entity_item_model.setHorizontalHeaderItem(1, QStandardItem(self.tr("Name")))
        self.entity_item_model.setHorizontalHeaderItem(2, QStandardItem(self.tr("Nr")))
        self.entity_item_model.setHorizontalHeaderItem(3, QStandardItem(self.tr("Type")))
        self.entity_item_model.setHorizontalHeaderItem(4, QStandardItem(self.tr("Base point")))
        self.entity_item_model.setHorizontalHeaderItem(5, QStandardItem(self.tr("Scale")))
        self.entity_item_model.setHorizontalHeaderItem(6, QStandardItem(self.tr("Rotation")))
        modele_root_element = self.entity_item_model.invisibleRootItem()

        self.buildEntitiesSubTree(modele_root_element, entities_list)

        # Signal to get events when a checkbox state changes (enable or disable shapes)
        self.entity_item_model.itemChanged.connect(self.on_itemChanged)

        self.ui.entitiesTreeView.setModel(self.entity_item_model)

        self.ui.entitiesTreeView.expandToDepth(0)

        for i in range(6):
            self.ui.entitiesTreeView.resizeColumnToContents(i)
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        self.formUeber = QtWidgets.QWidget()
        self.uiUeber = CharakterUeber.Ui_Form()
        self.uiUeber.setupUi(self.formUeber)

        self.model = QtGui.QStandardItemModel(None)
        self.ui.listTalente.setModel(self.model)
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        if Wolke.Debug:
            print("Initializing FertigkeitenWrapper...")
        self.formFert = QtWidgets.QWidget()
        self.uiFert = CharakterFertigkeiten.Ui_Form()
        self.uiFert.setupUi(self.formFert)
        header = self.uiFert.tableWidget.horizontalHeader()
        header.setSectionResizeMode(0, 1)
        header.setSectionResizeMode(1, 3)
        header.setSectionResizeMode(2, 3)

        self.model = QtGui.QStandardItemModel(self.uiFert.listTalente)
        self.uiFert.listTalente.setModel(self.model)

        self.mwp = MousewheelProtector.MousewheelProtector()

        #Signals
        self.uiFert.spinFW.valueChanged.connect(lambda state : self.fwChanged(False))
        self.uiFert.tableWidget.currentItemChanged.connect(self.tableClicked)   
        self.uiFert.buttonAdd.clicked.connect(self.editTalents)

        self.availableFerts = []
        self.rowRef = {}
        self.spinRef = {}
        self.labelRef = {}
        self.layoutRef = {}
        self.buttonRef = {}
        self.widgetRef = {}

        #If there is an ability already, then we take it to display already
        try:
            self.currentFertName = Wolke.Char.fertigkeiten.__iter__().__next__()
        except StopIteration:
            self.currentFertName = ''
        self.currentlyLoading = False
        self.loadFertigkeiten()
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        if Wolke.Debug:
            print("Initializing UebernatuerlichWrapper...")
        self.formFert = QtWidgets.QWidget()
        self.uiFert = CharakterUebernatuerlich.Ui_Form()
        self.uiFert.setupUi(self.formFert)
        header = self.uiFert.tableWidget.horizontalHeader()
        header.setSectionResizeMode(0, 1)
        header.setSectionResizeMode(1, 3)
        header.setSectionResizeMode(2, 3)

        self.model = QtGui.QStandardItemModel(self.uiFert.listTalente)
        self.uiFert.listTalente.setModel(self.model)

        self.mwp = MousewheelProtector.MousewheelProtector()

        #Signals
        self.uiFert.spinFW.valueChanged.connect(lambda state : self.fwChanged(False))
        self.uiFert.tableWidget.currentItemChanged.connect(self.tableClicked)   
        self.uiFert.buttonAdd.clicked.connect(self.editTalents)

        self.availableFerts = []
        self.rowRef = {}
        self.spinRef = {}
        self.labelRef = {}
        self.layoutRef = {}
        self.buttonRef = {}
        self.widgetRef = {}

        #If there is an ability already, then we take it to display already
        try:
            self.currentFertName = Wolke.Char.übernatürlicheFertigkeiten.__iter__().__next__()
        except StopIteration:
            self.currentFertName = ''
        self.currentlyLoading = False
        self.loadFertigkeiten()
项目:uitester    作者:IfengAutomation    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        ui_dir_path = os.path.dirname(__file__)
        ui_file_path = os.path.join(ui_dir_path, 'main.ui')
        uic.loadUi(ui_file_path, self)
        self.addBtn.clicked.connect(self.add_item)
        self.rmBtn.clicked.connect(self.rm_item)
        self.model = QStandardItemModel()
        self.listView.setModel(self.model)
项目:bubblesub    作者:rr-    | 项目源码 | 文件源码
def __init__(self, api, main_window, dictionary):
        super().__init__(main_window)
        self._main_window = main_window
        self._api = api
        self._dictionary = dictionary
        self._lines_to_spellcheck = api.subs.selected_lines

        self._mispelt_text_edit = QtWidgets.QLineEdit(self, readOnly=True)
        self._replacement_text_edit = QtWidgets.QLineEdit(self)
        self._suggestions_list_view = QtWidgets.QListView(self)
        self._suggestions_list_view.setModel(QtGui.QStandardItemModel())
        self._suggestions_list_view.clicked.connect(self._on_suggestion_click)

        box = QtWidgets.QWidget(self)
        layout = QtWidgets.QVBoxLayout(box)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(QtWidgets.QLabel('Mispelt word:', self))
        layout.addWidget(self._mispelt_text_edit)
        layout.addWidget(QtWidgets.QLabel('Replacement:', self))
        layout.addWidget(self._replacement_text_edit)
        layout.addWidget(QtWidgets.QLabel('Suggestions:', self))
        layout.addWidget(self._suggestions_list_view)

        strip = QtWidgets.QDialogButtonBox(
            self, orientation=QtCore.Qt.Vertical)
        self.add_btn = strip.addButton('Add to dictionary', strip.ActionRole)
        self.ignore_btn = strip.addButton('Ignore', strip.ActionRole)
        self.ignore_all_btn = strip.addButton('Ignore all', strip.ActionRole)
        self.replace_btn = strip.addButton('Replace', strip.ActionRole)
        strip.addButton('Cancel', strip.RejectRole)
        strip.clicked.connect(self.action)
        strip.rejected.connect(self.reject)

        layout = QtWidgets.QHBoxLayout(self, spacing=24)
        layout.addWidget(box)
        layout.addWidget(strip)

        if self._next():
            self.exec_()
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def __init__(self):
        QWidget.__init__(self, flags=Qt.Widget)
        self.setWindowTitle("ItemView QListView")
        self.setFixedHeight(100)

        fruits = ["banana", "apple", "melon", "pear"]

        view = QListView(self)
        model = QStandardItemModel()
        for f in fruits:
            model.appendRow(QStandardItem(f))
        view.setModel(model)
项目:opcua-widgets    作者:FreeOpcUa    | 项目源码 | 文件源码
def __init__(self, view, show_timestamps=True):
        QObject.__init__(self, view)
        self.view = view
        self._timestamps = show_timestamps
        delegate = MyDelegate(self.view, self)
        delegate.error.connect(self.error.emit)
        delegate.attr_written.connect(self.attr_written.emit)
        self.settings = QSettings()
        self.view.setItemDelegate(delegate)
        self.model = QStandardItemModel()
        self.model.setHorizontalHeaderLabels(['Attribute', 'Value', 'DataType'])
        state = self.settings.value("WindowState/attrs_widget_state", None)
        if state is not None:
            self.view.header().restoreState(state)
        self.view.setModel(self.model)
        self.current_node = None
        self.view.header().setSectionResizeMode(0)
        self.view.header().setStretchLastSection(True)
        self.view.expanded.connect(self._item_expanded)
        self.view.collapsed.connect(self._item_collapsed)
        self.view.setEditTriggers(QAbstractItemView.DoubleClicked)

        # Context menu
        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        copyaction = QAction("&Copy Value", self.model)
        copyaction.triggered.connect(self._copy_value)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(copyaction)
项目:opcua-widgets    作者:FreeOpcUa    | 项目源码 | 文件源码
def __init__(self, view):
        self.view = view
        QObject.__init__(self, view)
        self.model = QStandardItemModel()

        delegate = MyDelegate(self.view, self)
        delegate.error.connect(self.error.emit)
        delegate.reference_changed.connect(self.reference_changed.emit)
        self.view.setEditTriggers(QAbstractItemView.DoubleClicked)
        self.view.setModel(self.model)
        self.view.setItemDelegate(delegate)
        self.settings = QSettings()
        self.model.setHorizontalHeaderLabels(['ReferenceType', 'NodeId', "BrowseName", "TypeDefinition"])
        state = self.settings.value("WindowState/refs_widget_state", None)
        if state is not None:
            self.view.horizontalHeader().restoreState(state)
        self.view.horizontalHeader().setSectionResizeMode(0)
        self.view.horizontalHeader().setStretchLastSection(True)
        self.node = None

        self.reloadAction = QAction("Reload", self.model)
        self.reloadAction.triggered.connect(self.reload)
        self.addRefAction = QAction("Add Reference", self.model)
        self.addRefAction.triggered.connect(self.add_ref)
        self.removeRefAction = QAction("Remove Reference", self.model)
        self.removeRefAction.triggered.connect(self.remove_ref)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(self.reloadAction)
        self._contextMenu.addSeparator()
        self._contextMenu.addAction(self.addRefAction)
        self._contextMenu.addAction(self.removeRefAction)
项目:QTodoTxt2    作者:QTodoTxt    | 项目源码 | 文件源码
def __init__(self, parent):
        QtGui.QStandardItemModel.__init__(self, parent)
        self.style = ":/white_icons"
        if str(QtCore.QSettings().value("color_schem", "")).find("dark") >= 0:
            self.style = ":/dark_icons"
        self._filterItemByFilterType = dict()
        self._filterIconByFilterType = dict()
        self._treeItemByFilterType = dict()
        self._addDefaultTreeItems()
        self._initFilterTypeMappings()
项目:QTodoTxt2    作者:QTodoTxt    | 项目源码 | 文件源码
def roleNames(self):
        roles = QtGui.QStandardItemModel.roleNames(self)
        roles[TotalCountRole] = b"totalCount"
        roles[CompletedCountRole] = b"completedCount"
        return roles
项目:QTodoTxt2    作者:QTodoTxt    | 项目源码 | 文件源码
def clear(self):
        QtGui.QStandardItemModel.clear(self)
        self._addDefaultTreeItems()
        self._initFilterTypeMappings()
项目:pyqt-sqlite    作者:mbaser    | 项目源码 | 文件源码
def __init__(self, *args):
        super(MainWindow, self).__init__(*args)

        QtCore.QCoreApplication.setOrganizationName("mbaser")
        QtCore.QCoreApplication.setOrganizationDomain("foo.org")
        QtCore.QCoreApplication.setApplicationVersion("0.0.1")
        self.current_database = QtSql.QSqlDatabase.addDatabase('QSQLITE')
        self.setupUi(self)
        self.tree_model=QtGui.QStandardItemModel()

        self.treeView.setModel(self.tree_model)
        self.settings=QtCore.QSettings()

        self.recent_files=self.settings.value('recent_files',[])
        self.update_recent_files()
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def make_model_headers(model, full=True, check_all=True):
            '''
            Set the model horizontal header data
            @param model: the QStandardItemModel which headers should be set

            When full is set to False this mean the headers are for the user
            to review metadata they've created.
            '''
            center_align = ['Rank', 'Similarity', 'i', 'Matches']
            headers = [ ('Function', 'function name'),
                        ('Rank', 'number of times metadata has been applied'),
                        ('Prototype', 'function prototype')]

            if full:
                full_headers = [headers[0]]
                if check_all:
                    full_headers.append(('Matches', 'number of unique matches'))

                full_headers += [
                            headers[1],
                            ('Similarity', 'percent of how similary the match is to the function'),
                            headers[2],
                            ('i', 'full prototype information'),
                            ('Engines', 'engines that matched on this function'),
                            ('i', 'detailed engine information'),
                            ('User', 'creator of the metadata')
                                ]

                headers = full_headers

            i = 0
            for display_name, tooltip in headers:
                item_header = QtGui.QStandardItem(display_name)
                item_header.setToolTip(tooltip)

                if display_name in center_align:
                    item_header.setTextAlignment(Qt.AlignCenter)

                model.setHorizontalHeaderItem(i, item_header)

                i += 1
项目:DGP    作者:DynamicGravitySystems    | 项目源码 | 文件源码
def generate_model(self) -> Tuple[QStandardItemModel, QModelIndex]:
        """Generate a Qt Model based on the project structure."""
        model = QStandardItemModel()
        root = model.invisibleRootItem()

        # TODO: Add these icon resources to library or something so they are not loaded every time
        dgs_ico = QIcon('ui/assets/DGSIcon.xpm')
        flt_ico = QIcon('ui/assets/flight_icon.png')

        prj_header = QStandardItem(dgs_ico, "{name}: {path}".format(name=self.name, path=self.projectdir))
        prj_header.setEditable(False)
        fli_header = QStandardItem(flt_ico, "Flights")
        fli_header.setEditable(False)
        # TODO: Add a human readable identifier to flights
        first_flight = None
        for uid, flight in self.flights.items():
            fli_item = QStandardItem(flt_ico, "Flight: {}".format(flight.name))
            if first_flight is None:
                first_flight = fli_item
            fli_item.setToolTip("UUID: {}".format(uid))
            fli_item.setEditable(False)
            fli_item.setData(flight, QtCore.Qt.UserRole)

            gps_path, gps_uid = flight.gps_file
            gps = QStandardItem("GPS: {}".format(gps_uid))
            gps.setToolTip("File Path: {}".format(gps_path))
            gps.setEditable(False)
            gps.setData(gps_uid)  # For future use

            grav_path, grav_uid = flight.gravity_file
            if grav_path is not None:
                _, grav_fname = os.path.split(grav_path)
            else:
                grav_fname = '<None>'
            grav = QStandardItem("Gravity: {}".format(grav_fname))
            grav.setToolTip("File Path: {}".format(grav_path))
            grav.setEditable(False)
            grav.setData(grav_uid)  # For future use

            fli_item.appendRow(gps)
            fli_item.appendRow(grav)

            for line in flight:
                line_item = QStandardItem("Line {}:{}".format(line.start, line.end))
                line_item.setEditable(False)
                fli_item.appendRow(line_item)
            fli_header.appendRow(fli_item)
        prj_header.appendRow(fli_header)

        root.appendRow(prj_header)
        self.log.debug("Tree Model generated")
        first_index = model.indexFromItem(first_flight)
        return model, first_index
项目:DicomBrowser    作者:ericspod    | 项目源码 | 文件源码
def fillTagModel(model,dcm,regex=None):
    '''Fill a QStandardItemModel object `model' with a tree derived from tags in `dcm', filtering by pattern `regex'.'''
    try:
        regex=re.compile(str(regex),re.DOTALL)
    except:
        regex='' # no regex or bad pattern

    def _datasetToItem(parent,d):
        '''Add every element in `d' to the QStandardItem object `parent', this will be recursive for list elements.'''
        for elem in d:
            value=_elemToValue(elem)
            tag='(%04x, %04x)'%(elem.tag.group,elem.tag.elem)
            parent1 = QtGui.QStandardItem(str(elem.name))
            tagitem = QtGui.QStandardItem(tag)

            if isinstance(value,str):
                try:
                    value=value.decode('ascii')
                    if '\n' in value or '\r' in value: # multiline text data should be shown as repr
                        value=repr(value)
                except:
                    value=repr(value)

                if not regex or re.search(regex,str(elem.name)+tag+value) is not None:
                    parent.appendRow([parent1,tagitem,QtGui.QStandardItem(value)])

            elif value is not None and len(value)>0:
                parent.appendRow([parent1,tagitem])
                for v in value:
                    parent1.appendRow(v)

    def _elemToValue(elem):
        '''Return the value in `elem', which will be a string or a list of QStandardItem objects if elem.VR=='SQ'.'''
        value=None
        if elem.VR=='SQ':
            value=[]
            for i,item in enumerate(elem):
                parent1 = QtGui.QStandardItem('%s %i'%(elem.name,i))
                _datasetToItem(parent1,item)
                if not regex or parent1.hasChildren(): # discard sequences whose children have been filtered out
                    value.append(parent1)
        elif elem.name!='Pixel Data':
            value=str(elem.value)

        return value        

    _datasetToItem(model,dcm)
项目:DicomBrowser    作者:ericspod    | 项目源码 | 文件源码
def __init__(self,args,parent=None):
        QtGui.QMainWindow.__init__(self,parent)

        self.srclist=[] # list of source directories
        self.imageIndex=0 # index of selected image
        self.seriesMap=OrderedDict() # maps series table row tuples to DicomSeries object it was generated from
        self.seriesColumns=list(seriesListColumns) # keywords for columns
        self.selectedRow=-1 # selected series row
        self.lastDir='.' # last loaded directory root
        self.filterRegex='' # regular expression to filter tags by

        # create the directory queue and loading thread objects
        self.dirQueue=Queue() # queue of directories to load
        self.loadDirThread=threading.Thread(target=self._loadDirsThread)
        self.loadDirThread.daemon=True # clean shutdown possible with daemon threads
        self.loadDirThread.start() # start the thread now, it will wait until something is put on self.dirQueue

        # setup ui
        self.setupUi(self) # create UI elements based on the loaded .ui file
        self.setWindowTitle('DicomBrowser v%s (FOR RESEARCH ONLY)'%(__version__))
        self.setStatus('')

        # connect signals
        self.importButton.clicked.connect(self._openDirDialog)
        self.statusSignal.connect(self.setStatus)
        self.updateSignal.connect(self._updateSeriesTable)
        self.filterLine.textChanged.connect(self._setFilterString)
        self.imageSlider.valueChanged.connect(self.setSeriesImage)
        self.seriesView.clicked.connect(self._seriesTableClicked)

        # setup the list and table models
        self.srcmodel=QStringListModel()
        self.seriesmodel=SeriesTableModel(self.seriesColumns)
        self.seriesmodel.layoutChanged.connect(self._seriesTableResize)
        self.tagmodel=QtGui.QStandardItemModel()

        # assign models to views
        self.sourceListView.setModel(self.srcmodel)
        self.seriesView.setModel(self.seriesmodel)
        self.tagView.setModel(self.tagmodel)

        # create the pyqtgraph object for viewing images
        self.imageview=pg.ImageView()
        layout=QtGui.QGridLayout(self.view2DGroup)
        layout.addWidget(self.imageview)

        # load the empty image placeholder into a ndarray
        qimg=QtGui.QImage(':/icons/noimage.png')
        bytedata=qimg.constBits().asstring(qimg.width()*qimg.height())
        self.noimg=np.ndarray((qimg.width(),qimg.height()),dtype=np.ubyte,buffer=bytedata)

        # add the directories passed as arguments to the directory queue to start loading
        for i in args:
            if os.path.isdir(i):
                self.addSourceDir(i)
项目:LoL-Expert    作者:Mioced    | 项目源码 | 文件源码
def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "%s v%s" % (_APPNAME, _VERSION)))
        self.label.setText(_translate("MainWindow", "Summoner Name:"))
        self.comboRegion.setToolTip(_translate("MainWindow", "EU > NA 4Head"))
        self.comboRegion.setItemText(6, _translate("MainWindow", "North America (NA)"))
        self.comboRegion.setItemText(2, _translate("MainWindow", "Europe West (EUW)"))
        self.comboRegion.setItemText(1, _translate("MainWindow", "Europe Nordic East (EUNE)"))
        self.comboRegion.setItemText(3, _translate("MainWindow", "Korea (KR)"))
        self.comboRegion.setItemText(4, _translate("MainWindow", "Latin America North (LAN)"))
        self.comboRegion.setItemText(5, _translate("MainWindow", "Latin America South (LAS)"))
        self.comboRegion.setItemText(7, _translate("MainWindow", "Oceania (OCE)"))
        self.comboRegion.setItemText(8, _translate("MainWindow", "Russia (RU)"))
        self.comboRegion.setItemText(9, _translate("MainWindow", "Turkey (TR)"))
        self.comboRegion.setItemText(10, _translate("MainWindow", "Japan (JP)"))
        self.comboRegion.setItemText(0, _translate("MainWindow", "Brazil (BR)"))
        self.tabWidgetLeague.setTabText(self.tabWidgetLeague.indexOf(self.tabChallenger), _translate("MainWindow", "Challenger"))
        self.tabWidgetLeague.setTabText(self.tabWidgetLeague.indexOf(self.tabMaster), _translate("MainWindow", "Master"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabLeague), _translate("MainWindow", "League"))
        self.tabWidget.setTabToolTip(self.tabWidget.indexOf(self.tabLeague), _translate("MainWindow", "Leaderboard of the current selected region."))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabServers), _translate("MainWindow", "Servers"))
        self.tabWidget.setTabToolTip(self.tabWidget.indexOf(self.tabServers), _translate("MainWindow", "Check the current state of servers and what\'s online and offline."))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabLogs), _translate("MainWindow", "Logs"))
        self.tabWidget.setTabToolTip(self.tabWidget.indexOf(self.tabLogs), _translate("MainWindow", "See what\'s going on while things working and doing their jobs."))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabAbout), _translate("MainWindow", "About"))
        self.tabWidget.setTabToolTip(self.tabWidget.indexOf(self.tabAbout), _translate("MainWindow", "What do you think is this?"))
        self.txtSummonerName.setToolTip(_translate("MainWindow", "Most be at least 3 characters long and no more than 16 characters long."))
        self.GETButton.setToolTip(_translate("MainWindow", "Getting all the summoner\'s data. Including Stats, Runes, Masteries..."))
        self.GETButton.setText(_translate("MainWindow", "&Go"))
        self.btnSaveLogs.setText(_translate("MainWindow", "&Save Logs as A File..."))
        self.btnClearLogs.setText(_translate("MainWindow", "&Clear and &Reset Logs"))

        self.aboutLabel.setHtml(ABOUT())


        #################################################################################################################

        self.current_API = None

        self.status_model = QtGui.QStandardItemModel(self.serversView)
        self.serversView.setModel(self.status_model)

        self.challenger_model = QtGui.QStandardItemModel(self.challengerView)
        self.challengerView.setModel(self.challenger_model)

        self.master_model = QtGui.QStandardItemModel(self.masterView)
        self.masterView.setModel(self.master_model)

        self.GETButton.clicked.connect(self.Get_Summoner_Data)
        self.btnSaveLogs.clicked.connect(self.SaveLogs)
        self.btnClearLogs.clicked.connect(self.ClearLogs)