本文整理汇总了Python中PyQt4.QtGui.QListView.setSelectionBehavior方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.setSelectionBehavior方法的具体用法?Python QListView.setSelectionBehavior怎么用?Python QListView.setSelectionBehavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.setSelectionBehavior方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NewView
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setSelectionBehavior [as 别名]
class NewView(BaseView):
def _setup(self):
self._setupUi()
self.pluginList = ListviewModel(self.model.plugin_list, self.pluginListView)
self.pluginListView.doubleClicked.connect(self.model.open_selected_plugin)
self.networthButton.clicked.connect(self.networthButtonClicked)
self.profitButton.clicked.connect(self.profitButtonClicked)
self.transactionButton.clicked.connect(self.transactionButtonClicked)
self.gledgerButton.clicked.connect(self.gledgerButtonClicked)
self.scheduleButton.clicked.connect(self.scheduleButtonClicked)
self.budgetButton.clicked.connect(self.budgetButtonClicked)
self.docpropsButton.clicked.connect(self.docpropsButtonClicked)
self.shortcut1.activated.connect(self.networthButtonClicked)
self.shortcut2.activated.connect(self.profitButtonClicked)
self.shortcut3.activated.connect(self.transactionButtonClicked)
self.shortcut4.activated.connect(self.gledgerButtonClicked)
self.shortcut5.activated.connect(self.scheduleButtonClicked)
self.shortcut6.activated.connect(self.budgetButtonClicked)
self.shortcut7.activated.connect(self.docpropsButtonClicked)
def _setupUi(self):
self.resize(400, 300)
self.gridLayout = QGridLayout(self)
self.label = QLabel(tr("Choose a type for this tab:"))
self.label.setAlignment(Qt.AlignCenter)
self.gridLayout.addWidget(self.label, 0, 0, 1, 3)
self.gridLayout.addItem(horizontalSpacer(), 1, 0, 1, 1)
self.verticalLayout = QVBoxLayout()
self.networthButton = QPushButton(tr("1. Net Worth"))
self.networthButton.setIcon(QIcon(QPixmap(':/balance_sheet_16')))
self.verticalLayout.addWidget(self.networthButton)
self.profitButton = QPushButton(tr("2. Profit && Loss"))
self.profitButton.setIcon(QIcon(QPixmap(':/income_statement_16')))
self.verticalLayout.addWidget(self.profitButton)
self.transactionButton = QPushButton(tr("3. Transactions"))
self.transactionButton.setIcon(QIcon(QPixmap(':/transaction_table_16')))
self.verticalLayout.addWidget(self.transactionButton)
self.gledgerButton = QPushButton(tr("4. General Ledger"))
self.gledgerButton.setIcon(QIcon(QPixmap(':/gledger_16')))
self.verticalLayout.addWidget(self.gledgerButton)
self.scheduleButton = QPushButton(tr("5. Schedules"))
self.scheduleButton.setIcon(QIcon(QPixmap(':/schedules_16')))
self.verticalLayout.addWidget(self.scheduleButton)
self.budgetButton = QPushButton(tr("6. Budgets"))
self.budgetButton.setIcon(QIcon(QPixmap(':/budget_16')))
self.verticalLayout.addWidget(self.budgetButton)
self.docpropsButton = QPushButton(tr("7. Document Properties"))
self.docpropsButton.setIcon(QIcon(QPixmap(':/gledger_16')))
self.verticalLayout.addWidget(self.docpropsButton)
self.pluginLabel = QLabel(tr("Plugins (double-click to open)"))
self.pluginLabel.setAlignment(Qt.AlignCenter)
self.verticalLayout.addWidget(self.pluginLabel)
self.pluginListView = QListView()
self.pluginListView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.verticalLayout.addWidget(self.pluginListView)
self.gridLayout.addLayout(self.verticalLayout, 1, 1, 1, 1)
self.gridLayout.addItem(horizontalSpacer(), 1, 2, 1, 1)
self.gridLayout.addItem(verticalSpacer(), 2, 1, 1, 1)
for i in range(1, 8):
shortcut = QShortcut(QKeySequence(str(i)), self, None, None, Qt.WidgetShortcut)
setattr(self, 'shortcut{0}'.format(i), shortcut)
#--- Event Handlers
def networthButtonClicked(self):
self.model.select_pane_type(PaneType.NetWorth)
def profitButtonClicked(self):
self.model.select_pane_type(PaneType.Profit)
def transactionButtonClicked(self):
self.model.select_pane_type(PaneType.Transaction)
def gledgerButtonClicked(self):
self.model.select_pane_type(PaneType.GeneralLedger)
def scheduleButtonClicked(self):
self.model.select_pane_type(PaneType.Schedule)
def budgetButtonClicked(self):
self.model.select_pane_type(PaneType.Budget)
def docpropsButtonClicked(self):
self.model.select_pane_type(PaneType.DocProps)
示例2: PrioritizeDialog
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setSelectionBehavior [as 别名]
class PrioritizeDialog(QDialog):
def __init__(self, parent, app):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
self._setupUi()
self.model = PrioritizeDialogModel(app=app.model)
self.categoryList = ComboboxModel(model=self.model.category_list, view=self.categoryCombobox)
self.criteriaList = ListviewModel(model=self.model.criteria_list, view=self.criteriaListView)
self.prioritizationList = PrioritizationList(model=self.model.prioritization_list, view=self.prioritizationListView)
self.model.view = self
self.addCriteriaButton.clicked.connect(self.model.add_selected)
self.removeCriteriaButton.clicked.connect(self.model.remove_selected)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
def _setupUi(self):
self.setWindowTitle(tr("Re-Prioritize duplicates"))
self.resize(700, 400)
#widgets
msg = tr("Add criteria to the right box and click OK to send the dupes that correspond the "
"best to these criteria to their respective group's "
"reference position. Read the help file for more information.")
self.promptLabel = QLabel(msg)
self.promptLabel.setWordWrap(True)
self.categoryCombobox = QComboBox()
self.criteriaListView = QListView()
self.addCriteriaButton = QPushButton(self.style().standardIcon(QStyle.SP_ArrowRight), "")
self.removeCriteriaButton = QPushButton(self.style().standardIcon(QStyle.SP_ArrowLeft), "")
self.prioritizationListView = QListView()
self.prioritizationListView.setAcceptDrops(True)
self.prioritizationListView.setDragEnabled(True)
self.prioritizationListView.setDragDropMode(QAbstractItemView.InternalMove)
self.prioritizationListView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.buttonBox = QDialogButtonBox()
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
# layout
self.mainLayout = QVBoxLayout(self)
self.mainLayout.addWidget(self.promptLabel)
self.splitter = QSplitter()
sp = self.splitter.sizePolicy()
sp.setVerticalPolicy(QSizePolicy.Expanding)
self.splitter.setSizePolicy(sp)
self.leftSide = QWidget()
self.leftWidgetsLayout = QVBoxLayout()
self.leftWidgetsLayout.addWidget(self.categoryCombobox)
self.leftWidgetsLayout.addWidget(self.criteriaListView)
self.leftSide.setLayout(self.leftWidgetsLayout)
self.splitter.addWidget(self.leftSide)
self.rightSide = QWidget()
self.rightWidgetsLayout = QHBoxLayout()
self.addRemoveButtonsLayout = QVBoxLayout()
self.addRemoveButtonsLayout.addItem(verticalSpacer())
self.addRemoveButtonsLayout.addWidget(self.addCriteriaButton)
self.addRemoveButtonsLayout.addWidget(self.removeCriteriaButton)
self.addRemoveButtonsLayout.addItem(verticalSpacer())
self.rightWidgetsLayout.addLayout(self.addRemoveButtonsLayout)
self.rightWidgetsLayout.addWidget(self.prioritizationListView)
self.rightSide.setLayout(self.rightWidgetsLayout)
self.splitter.addWidget(self.rightSide)
self.mainLayout.addWidget(self.splitter)
self.mainLayout.addWidget(self.buttonBox)