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


Python QListWidget.setViewMode方法代码示例

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


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

示例1: QtReducePreferencePane

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setViewMode [as 别名]
class QtReducePreferencePane(QDialog):
    # QtReducePreferencePane are the dialog windows for setting preferences.
    # Instances are created via menu or keyboard shortcut in QtReduceMainWindow.

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

        self.__createContents()

        self.toolBar = QtReducePreferencesToolBar(self)
        self.worksheet = QtReducePreferencesWorksheet(self)
        self.computation = QtReducePreferencesComputation(self)

        self.pagesWidget = QStackedWidget()
        self.pagesWidget.addWidget(self.toolBar)
        self.pagesWidget.addWidget(self.worksheet)
        self.pagesWidget.addWidget(self.computation)

        self.pagesWidget.setCurrentIndex(
            self.contentsWidget.row(self.contentsWidget.currentItem()))

        closeButton = QPushButton(self.tr("Close"))
        closeButton.clicked.connect(self.close)

        horizontalLayout = QHBoxLayout()
        horizontalLayout.addWidget(self.contentsWidget)
        horizontalLayout.addWidget(self.pagesWidget)

        buttonsLayout = QHBoxLayout()
        buttonsLayout.addStretch(1)
        buttonsLayout.addWidget(closeButton)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(horizontalLayout)
        mainLayout.addLayout(buttonsLayout)

        self.setLayout(mainLayout)

        self.setWindowTitle(self.tr("QReduce Preferences"))

    def changePage(self,current,previous):
        if not current:
            current = previous
        QSettings().setValue("preferences/currentitem",current.text())
        self.pagesWidget.setCurrentIndex(self.contentsWidget.row(current))

    def __createContents(self):
        self.contentsWidget = QListWidget()
        self.contentsWidget.setViewMode(QListView.ListMode)
        self.contentsWidget.setMovement(QListView.Static)

        toolBar = QListWidgetItem(self.contentsWidget)
        toolBar.setText(self.tr("Toolbar"))
        toolBar.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        worksheet = QListWidgetItem(self.contentsWidget)
        worksheet.setText(self.tr("Worksheet"))
        worksheet.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        computation = QListWidgetItem(self.contentsWidget)
        computation.setText(self.tr("Computation"))
        computation.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        currentItem = QSettings().value("preferences/currentitem",
                                        self.tr(QtReduceDefaults.CURRENTITEM))
        if currentItem == self.tr("Toolbar"):
            self.contentsWidget.setCurrentItem(toolBar)
        elif currentItem == self.tr("Worksheet"):
            self.contentsWidget.setCurrentItem(worksheet)
        elif currentItem == self.tr("Computation"):
            self.contentsWidget.setCurrentItem(computation)

        self.contentsWidget.currentItemChanged.connect(self.changePage)
开发者ID:webushka,项目名称:reduce,代码行数:75,代码来源:qrpreferences.py


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