当前位置: 首页>>代码示例>>Python>>正文


Python QListView.model方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QListView.model方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.model方法的具体用法?Python QListView.model怎么用?Python QListView.model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QListView的用法示例。


在下文中一共展示了QListView.model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: VariableComboBox

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]
class VariableComboBox(QWidget):

    def __init__(self, id, text="Input data", default=[], model=None):
        QWidget.__init__(self)
        self.setToolTip("<p>Select input dataset</p>")
        self.id = id
        if model is None:
            self.model = TreeModel()
        else:
            self.model = model
        self.comboBox = QComboBox()
        self.treeView = QListView(self.comboBox)
        self.connect(self.comboBox, SIGNAL("currentIndexChanged(int)"), 
            self.changeSelectedText)
        self.proxyModel = SortFilterProxyModel()
        self.proxyModel.setDynamicSortFilter(True)
        self.proxyModel.setFilterKeyColumn(1)
        self.proxyModel.setSourceModel(self.model)
        regexp = QRegExp("|".join([r"%s" % i for i in default]))
        self.proxyModel.setFilterRegExp(regexp)
#        self.treeView.header().hide()
        self.currentText = QString()
        self.treeView.setModel(self.proxyModel)

        self.comboBox.setModel(self.proxyModel)
        self.comboBox.setView(self.treeView)
#        self.treeView.hideColumn(1)
#        self.treeView.hideColumn(2)
#        self.treeView.hideColumn(3)
        self.treeView.viewport().installEventFilter(self.comboBox)
        label = QLabel(text)
        hbox = HBoxLayout()
        hbox.addWidget(label)
        hbox.addWidget(self.comboBox)
        self.setLayout(hbox)
        self.changeSelectedText(None)

    def changeSelectedText(self, index):
        item = self.treeView.currentIndex()
        if not item.isValid():
            item = self.proxyModel.index(0,0, QModelIndex())
        tree = self.treeView.model().parentTree(item)
        self.currentText = tree

    def parameterValues(self):
        return {self.id:self.currentText}
开发者ID:karstenv,项目名称:manageR,代码行数:48,代码来源:plugins_dialog.py

示例2: QuickAccessWidget

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]
class QuickAccessWidget(QFrame):
    def __init__(self, parent):
        QFrame.__init__(self, parent)
        self.setFrameStyle(QFrame.Box | QFrame.Sunken)
        self.setStyleSheet("QListView {background: transparent; }")
        self.setLayout(QHBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.listView = QListView(self)
        self.layout().addWidget(self.listView)

        self.listView.setModel(self.window().quickAccessModel)
        self.listView.setMovement(QListView.Snap)
        self.listView.setFlow(QListView.LeftToRight)
        self.listView.setResizeMode(QListView.Adjust)
        gridSize = self.logicalDpiX() / 96 * 60
        self.listView.setGridSize(QSize(gridSize, gridSize))
        self.listView.setViewMode(QListView.IconMode)

        self.listView.activated.connect(self.listView.model().runShortcut)
开发者ID:OSUser,项目名称:quickpanel,代码行数:21,代码来源:quick_access.py

示例3: SortedListWidget

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]
class SortedListWidget(QWidget):
    sortingOrderChanged = Signal()

    class _MyItemDelegate(QStyledItemDelegate):

        def __init__(self, sortingModel, parent):
            QStyledItemDelegate.__init__(self, parent)
            self.sortingModel = sortingModel

        def sizeHint(self, option, index):
            size = QStyledItemDelegate.sizeHint(self, option, index)
            return QSize(size.width(), size.height() + 4)

        def createEditor(self, parent, option, index):
            cb = QComboBox(parent)
            cb.setModel(self.sortingModel)
            cb.showPopup()
            return cb

        def setEditorData(self, editor, index):
            pass  # TODO: sensible default

        def setModelData(self, editor, model, index):
            text = editor.currentText()
            model.setData(index, text)

    def __init__(self, *args):
        QWidget.__init__(self, *args)
        self.setContentsMargins(0, 0, 0, 0)
        gridLayout = QGridLayout()
        gridLayout.setContentsMargins(0, 0, 0, 0)
        gridLayout.setSpacing(1)

        model = QStandardItemModel(self)
        model.rowsInserted.connect(self.__changed)
        model.rowsRemoved.connect(self.__changed)
        model.dataChanged.connect(self.__changed)

        self._listView = QListView(self)
        self._listView.setModel(model)
#        self._listView.setDragEnabled(True)
        self._listView.setDropIndicatorShown(True)
        self._listView.setDragDropMode(QListView.InternalMove)
        self._listView.viewport().setAcceptDrops(True)
        self._listView.setMinimumHeight(100)

        gridLayout.addWidget(self._listView, 0, 0, 2, 2)

        vButtonLayout = QVBoxLayout()

        self._upAction = QAction(
            "\u2191", self, toolTip="Move up")

        self._upButton = QToolButton(self)
        self._upButton.setDefaultAction(self._upAction)
        self._upButton.setSizePolicy(
            QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)

        self._downAction = QAction(
            "\u2193", self, toolTip="Move down")

        self._downButton = QToolButton(self)
        self._downButton.setDefaultAction(self._downAction)
        self._downButton.setSizePolicy(
            QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)

        vButtonLayout.addWidget(self._upButton)
        vButtonLayout.addWidget(self._downButton)

        gridLayout.addLayout(vButtonLayout, 0, 2, 2, 1)

        hButtonLayout = QHBoxLayout()

        self._addAction = QAction("+", self)
        self._addButton = QToolButton(self)
        self._addButton.setDefaultAction(self._addAction)

        self._removeAction = QAction("-", self)
        self._removeButton = QToolButton(self)
        self._removeButton.setDefaultAction(self._removeAction)
        hButtonLayout.addWidget(self._addButton)
        hButtonLayout.addWidget(self._removeButton)
        hButtonLayout.addStretch(10)
        gridLayout.addLayout(hButtonLayout, 2, 0, 1, 2)

        self.setLayout(gridLayout)
        self._addAction.triggered.connect(self._onAddAction)
        self._removeAction.triggered.connect(self._onRemoveAction)
        self._upAction.triggered.connect(self._onUpAction)
        self._downAction.triggered.connect(self._onDownAction)

    def sizeHint(self):
        size = QWidget.sizeHint(self)
        return QSize(size.width(), 100)

    def _onAddAction(self):
        item = QStandardItem("")
        item.setFlags(item.flags() ^ Qt.ItemIsDropEnabled)
        self._listView.model().appendRow(item)
        self._listView.setCurrentIndex(item.index())
#.........这里部分代码省略.........
开发者ID:nagyistoce,项目名称:orange-bio,代码行数:103,代码来源:OWPIPAx.py

示例4: OWQualityControl

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]
class OWQualityControl(widget.OWWidget):
    name = "Quality Control"
    description = "Experiment quality control"
    icon = "../widgets/icons/QualityControl.svg"
    priority = 5000

    inputs = [("Experiment Data", Orange.data.Table, "set_data")]
    outputs = []

    DISTANCE_FUNCTIONS = [("Distance from Pearson correlation",
                           dist_pcorr),
                          ("Euclidean distance",
                           dist_eucl),
                          ("Distance from Spearman correlation",
                           dist_spearman)]

    settingsHandler = SetContextHandler()

    split_by_labels = settings.ContextSetting({})
    sort_by_labels = settings.ContextSetting({})

    selected_distance_index = settings.Setting(0)

    def __init__(self, parent=None):
        super().__init__(parent)

        ## Attributes
        self.data = None
        self.distances = None
        self.groups = None
        self.unique_pos = None
        self.base_group_index = 0

        ## GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.info_box = gui.widgetLabel(box, "\n")

        ## Separate By box
        box = gui.widgetBox(self.controlArea, "Separate By")
        self.split_by_model = itemmodels.PyListModel(parent=self)
        self.split_by_view = QListView()
        self.split_by_view.setSelectionMode(QListView.ExtendedSelection)
        self.split_by_view.setModel(self.split_by_model)
        box.layout().addWidget(self.split_by_view)

        self.split_by_view.selectionModel().selectionChanged.connect(
            self.on_split_key_changed)

        ## Sort By box
        box = gui.widgetBox(self.controlArea, "Sort By")
        self.sort_by_model = itemmodels.PyListModel(parent=self)
        self.sort_by_view = QListView()
        self.sort_by_view.setSelectionMode(QListView.ExtendedSelection)
        self.sort_by_view.setModel(self.sort_by_model)
        box.layout().addWidget(self.sort_by_view)

        self.sort_by_view.selectionModel().selectionChanged.connect(
            self.on_sort_key_changed)

        ## Distance box
        box = gui.widgetBox(self.controlArea, "Distance Measure")
        gui.comboBox(box, self, "selected_distance_index",
                     items=[name for name, _ in self.DISTANCE_FUNCTIONS],
                     callback=self.on_distance_measure_changed)

        self.scene = QGraphicsScene()
        self.scene_view = QGraphicsView(self.scene)
        self.scene_view.setRenderHints(QPainter.Antialiasing)
        self.scene_view.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.mainArea.layout().addWidget(self.scene_view)

        self.scene_view.installEventFilter(self)

        self._disable_updates = False
        self._cached_distances = {}
        self._base_index_hints = {}
        self.main_widget = None

        self.resize(800, 600)

    def clear(self):
        """Clear the widget state."""
        self.data = None
        self.distances = None
        self.groups = None
        self.unique_pos = None

        with disable_updates(self):
            self.split_by_model[:] = []
            self.sort_by_model[:] = []

        self.main_widget = None
        self.scene.clear()
        self.info_box.setText("\n")
        self._cached_distances = {}

    def set_data(self, data=None):
        """Set input experiment data."""
        self.closeContext()
        self.clear()
#.........这里部分代码省略.........
开发者ID:astaric,项目名称:orange-bio,代码行数:103,代码来源:OWQualityControl.py

示例5: OWGenotypeDistances

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]

#.........这里部分代码省略.........
        two unique values in the data.

        """
        attrs = [attr.attributes.items() for attr in data.domain.attributes]
        attrs = reduce(operator.iadd, attrs, [])
        # in case someone put non string values in attributes dict
        attrs = [(str(key), str(value)) for key, value in attrs]
        attrs = set(attrs)
        values = defaultdict(set)
        for key, value in attrs:
            values[key].add(value)
        keys = [key for key in values if len(values[key]) > 1]
        return keys

    def set_data(self, data=None):
        """Set the input data table.
        """
        self.closeContext()
        self.clear()
        self.error(0)
        self.warning(0)
        if data and not self.get_suitable_keys(data):
            self.error(0, "Data has no suitable attribute labels.")
            data = None

        self.data = data

        if data:
            self.info_box.setText("{0} genes\n{1} experiments"
                                  .format(len(data), len(data.domain)))
            self.update_control()
            self.split_data()
        else:
            self.separate_view.setModel(itemmodels.PyListModel([]))
            self.relevant_view.setModel(itemmodels.PyListModel([]))
            self.groups_scroll_area.setWidget(QWidget())
            self.info_box.setText("No data on input.\n")
        self.commit()

    def update_control(self):
        """Update the control area of the widget. Populate the list
        views with keys from attribute labels.
        """
        keys = self.get_suitable_keys(self.data)

        model = itemmodels.PyListModel(keys)
        self.separate_view.setModel(model)
        self.separate_view.selectionModel().selectionChanged.connect(
            self.on_separate_key_changed)

        model = itemmodels.PyListModel(keys)
        self.relevant_view.setModel(model)
        self.relevant_view.selectionModel().selectionChanged.connect(
            self.on_relevant_key_changed)

        self.openContext(keys)

        # Get the selected keys from the open context
        separate_keys = self.separate_keys
        relevant_keys = self.relevant_keys

        def select(model, selection_model, selected_items):
            all_items = list(model)
            try:
                indices = [all_items.index(item) for item in selected_items]
            except:
开发者ID:r0b1n1983liu,项目名称:o3env,代码行数:70,代码来源:OWGenotypeDistances.py

示例6: OrderSelectorView

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]
class OrderSelectorView(QObject):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parentWidget,
                 label_text_NotSelected, label_text_Selected,
                 model):
        """Constructor"""

        QObject.__init__(self)

        self.model = model

        self.gridLayout = QGridLayout(parentWidget)

        self.verticalLayout_left_list = QVBoxLayout()
        self.label_NotSelected = QLabel(parentWidget)
        self.label_NotSelected.setText(label_text_NotSelected)
        self.verticalLayout_left_list.addWidget(self.label_NotSelected)
        self.listView_NotSelected = QListView(parentWidget)
        self.verticalLayout_left_list.addWidget(self.listView_NotSelected)
        self.gridLayout.addLayout(self.verticalLayout_left_list, 0, 0, 1, 2)

        self.verticalLayout_right_left = QVBoxLayout()
        spacerItem = QSpacerItem(20,178,QSizePolicy.Minimum,QSizePolicy.Expanding)
        self.verticalLayout_right_left.addItem(spacerItem)
        self.pushButton_right_arrow = QPushButton(parentWidget)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalPolicy(0)
        sizePolicy.setHeightForWidth(
            self.pushButton_right_arrow.sizePolicy().hasHeightForWidth())
        self.pushButton_right_arrow.setSizePolicy(sizePolicy)
        self.pushButton_right_arrow.setMinimumSize(QSize(50,50))
        self.pushButton_right_arrow.setMaximumSize(QSize(50,50))
        self.pushButton_right_arrow.setIcon(QIcon(':/right_arrow.png'))
        self.pushButton_right_arrow.setIconSize(QSize(50,50))
        self.pushButton_right_arrow.setText('')
        self.verticalLayout_right_left.addWidget(self.pushButton_right_arrow)
        self.pushButton_left_arrow = QPushButton(parentWidget)
        sizePolicy.setHeightForWidth(
            self.pushButton_left_arrow.sizePolicy().hasHeightForWidth())
        self.pushButton_left_arrow.setSizePolicy(sizePolicy)
        self.pushButton_left_arrow.setMinimumSize(QSize(50,50))
        self.pushButton_left_arrow.setMaximumSize(QSize(50,50))
        self.pushButton_left_arrow.setIcon(QIcon(':/left_arrow.png'))
        self.pushButton_left_arrow.setIconSize(QSize(50,50))
        self.pushButton_left_arrow.setText('')
        self.verticalLayout_right_left.addWidget(self.pushButton_left_arrow)
        spacerItem = QSpacerItem(20,178,QSizePolicy.Minimum,QSizePolicy.Expanding)
        self.verticalLayout_right_left.addItem(spacerItem)
        self.gridLayout.addLayout(self.verticalLayout_right_left, 0, 2, 1, 1)

        self.verticalLayout_right_list = QVBoxLayout()
        self.label_Selected = QLabel(parentWidget)
        self.label_Selected.setText(label_text_Selected)
        self.verticalLayout_right_list.addWidget(self.label_Selected)
        self.listView_Selected = QListView(parentWidget)
        self.verticalLayout_right_list.addWidget(self.listView_Selected)
        self.gridLayout.addLayout(self.verticalLayout_right_list, 0, 3, 1, 2)

        self.verticalLayout_up_down = QVBoxLayout()
        spacerItem = QSpacerItem(20,178,QSizePolicy.Minimum,QSizePolicy.Expanding)
        self.verticalLayout_up_down.addItem(spacerItem)
        self.pushButton_up_arrow = QPushButton(parentWidget)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalPolicy(0)
        sizePolicy.setHeightForWidth(
            self.pushButton_up_arrow.sizePolicy().hasHeightForWidth())
        self.pushButton_up_arrow.setSizePolicy(sizePolicy)
        self.pushButton_up_arrow.setMinimumSize(QSize(50,50))
        self.pushButton_up_arrow.setMaximumSize(QSize(50,50))
        self.pushButton_up_arrow.setIcon(QIcon(':/up_arrow.png'))
        self.pushButton_up_arrow.setIconSize(QSize(50,50))
        self.pushButton_up_arrow.setText('')
        self.verticalLayout_up_down.addWidget(self.pushButton_up_arrow)
        self.pushButton_down_arrow = QPushButton(parentWidget)
        sizePolicy.setHeightForWidth(
            self.pushButton_down_arrow.sizePolicy().hasHeightForWidth())
        self.pushButton_down_arrow.setSizePolicy(sizePolicy)
        self.pushButton_down_arrow.setMinimumSize(QSize(50,50))
        self.pushButton_down_arrow.setMaximumSize(QSize(50,50))
        self.pushButton_down_arrow.setIcon(QIcon(':/down_arrow.png'))
        self.pushButton_down_arrow.setIconSize(QSize(50,50))
        self.pushButton_down_arrow.setText('')
        self.verticalLayout_up_down.addWidget(self.pushButton_down_arrow)
        spacerItem = QSpacerItem(20,178,QSizePolicy.Minimum,QSizePolicy.Expanding)
        self.verticalLayout_up_down.addItem(spacerItem)
        self.gridLayout.addLayout(self.verticalLayout_up_down, 0, 5, 1, 1)

        self.listView_NotSelected.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.listView_Selected.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.listView_NotSelected.setModel(self.model.model_NotSelected)
        self.listView_Selected.setModel(self.model.model_Selected)



    #----------------------------------------------------------------------
#.........这里部分代码省略.........
开发者ID:ChannelFinder,项目名称:hla,代码行数:103,代码来源:orderselector.py

示例7: RunDialog

# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import model [as 别名]
class RunDialog(QDialog):

    def __init__(self, run_model, parent):
        QDialog.__init__(self, parent)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint)
        self.setModal(True)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowTitle("Simulations")

        assert isinstance(run_model, BaseRunModel)
        self._run_model = run_model

        layout = QVBoxLayout()
        layout.setSizeConstraint(QLayout.SetFixedSize)

        self.simulations_tracker = SimulationsTracker()
        states = self.simulations_tracker.getStates()

        self.total_progress = SimpleProgress()
        layout.addWidget(self.total_progress)

        status_layout = QHBoxLayout()
        status_layout.addStretch()
        self.__status_label = QLabel()
        status_layout.addWidget(self.__status_label)
        status_layout.addStretch()
        layout.addLayout(status_layout)

        self.progress = Progress()
        self.progress.setIndeterminateColor(self.total_progress.color)
        for state in states:
            self.progress.addState(state.state, QColor(*state.color), 100.0 * state.count / state.total_count)

        layout.addWidget(self.progress)

        self.detailed_progress = None

        legend_layout = QHBoxLayout()
        self.legends = {}
        for state in states:
            self.legends[state] = Legend("%s (%d/%d)", QColor(*state.color))
            self.legends[state].updateLegend(state.name, 0, 0)
            legend_layout.addWidget(self.legends[state])

        layout.addLayout(legend_layout)

        self.running_time = QLabel("")

        ert = None
        if isinstance(run_model, BaseRunModel):
            ert = run_model.ert()

        self.plot_tool = PlotTool()
        self.plot_tool.setParent(None)
        self.plot_button = QPushButton(self.plot_tool.getName())
        self.plot_button.clicked.connect(self.plot_tool.trigger)
        self.plot_button.setEnabled(ert is not None)

        self.kill_button = QPushButton("Kill simulations")
        self.done_button = QPushButton("Done")
        self.done_button.setHidden(True)
        self.restart_button = QPushButton("Restart")
        self.restart_button.setHidden(True)
        self.show_details_button = QPushButton("Details")

        self.realizations_view = QListView()
        self.realizations_view.setModel(QStandardItemModel(self.realizations_view))
        self.realizations_view.setVisible(False)

        button_layout = QHBoxLayout()

        size = 20
        spin_movie = resourceMovie("ide/loading.gif")
        spin_movie.setSpeed(60)
        spin_movie.setScaledSize(QSize(size, size))
        spin_movie.start()

        self.processing_animation = QLabel()
        self.processing_animation.setMaximumSize(QSize(size, size))
        self.processing_animation.setMinimumSize(QSize(size, size))
        self.processing_animation.setMovie(spin_movie)

        button_layout.addWidget(self.processing_animation)
        button_layout.addWidget(self.running_time)
        button_layout.addStretch()
        button_layout.addWidget(self.show_details_button)
        button_layout.addWidget(self.plot_button)
        button_layout.addWidget(self.kill_button)
        button_layout.addWidget(self.done_button)
        button_layout.addWidget(self.restart_button)

        layout.addStretch()
        layout.addLayout(button_layout)

        layout.addWidget(self.realizations_view)

        self.setLayout(layout)

        self.kill_button.clicked.connect(self.killJobs)
#.........这里部分代码省略.........
开发者ID:berland,项目名称:ert,代码行数:103,代码来源:run_dialog.py


注:本文中的PyQt4.QtGui.QListView.model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。