本文整理汇总了Python中PyQt5.QtWidgets.QTableView.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setEnabled方法的具体用法?Python QTableView.setEnabled怎么用?Python QTableView.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTableView
的用法示例。
在下文中一共展示了QTableView.setEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExportPanel
# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setEnabled [as 别名]
class ExportPanel(Panel):
FIELDS = []
PERSISTENT_NAME = 'exportPanel'
def __init__(self, model, mainwindow):
Panel.__init__(self, mainwindow)
self.setAttribute(Qt.WA_DeleteOnClose)
self.mainwindow = mainwindow
self._setupUi()
self.model = model
self.accountTable = ExportAccountTable(model=self.model.account_table, view=self.tableView)
self.exportTypeButtons.buttonClicked[int].connect(self.exportTypeSelected)
self.exportFormatButtons.buttonClicked[int].connect(self.exportFormatSelected)
self.buttonBox.rejected.connect(self.reject)
self.exportButton.clicked.connect(self.exportButtonClicked)
def _setupUi(self):
self.setWindowTitle(tr("Export Options"))
self.mainLayout = QVBoxLayout(self)
self.label1 = QLabel(tr("Which accounts do you want to export?"), self)
self.mainLayout.addWidget(self.label1)
self.exportTypeButtons = QButtonGroup(self)
self.exportAllButton = QRadioButton(tr("All"), self)
self.mainLayout.addWidget(self.exportAllButton)
self.exportTypeButtons.addButton(self.exportAllButton, ExportType.All)
self.exportAllButton.setChecked(True)
self.exportSelectedButton = QRadioButton(tr("Selected"), self)
self.mainLayout.addWidget(self.exportSelectedButton)
self.exportTypeButtons.addButton(self.exportSelectedButton, ExportType.Selected)
self.tableView = QTableView(self)
self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tableView.verticalHeader().setVisible(False)
self.tableView.verticalHeader().setDefaultSectionSize(18)
self.mainLayout.addWidget(self.tableView)
self.label2 = QLabel(tr("Export format:"), self)
self.mainLayout.addWidget(self.label2)
self.exportFormatButtons = QButtonGroup(self)
self.exportAsQIFButton = QRadioButton("QIF", self)
self.mainLayout.addWidget(self.exportAsQIFButton)
self.exportFormatButtons.addButton(self.exportAsQIFButton, ExportFormat.QIF)
self.exportAsQIFButton.setChecked(True)
self.exportAsCSVButton = QRadioButton("CSV", self)
self.mainLayout.addWidget(self.exportAsCSVButton)
self.exportFormatButtons.addButton(self.exportAsCSVButton, ExportFormat.CSV)
self.label3 = QLabel(tr("Export scope:"))
self.mainLayout.addWidget(self.label3)
self.dateRangeOnlyCheckbox = QCheckBox(tr("Current date range only"))
self.mainLayout.addWidget(self.dateRangeOnlyCheckbox)
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
self.exportButton = self.buttonBox.addButton(tr("Export"), QDialogButtonBox.ActionRole)
self.mainLayout.addWidget(self.buttonBox)
#--- Overrides
def _loadFields(self):
self.exportAllButton.setChecked(self.model.export_all)
self.exportAsQIFButton.setChecked(self.model.export_format == ExportFormat.QIF)
self.dateRangeOnlyCheckbox.setChecked(self.model.current_daterange_only)
def _saveFields(self):
self.model.current_daterange_only = self.dateRangeOnlyCheckbox.isChecked()
#--- Event Handlers
def exportButtonClicked(self):
title = tr("Export")
fileext = 'qif' if self.model.export_format == ExportFormat.QIF else 'csv'
filters = tr("{0} Files (*.{1})").format(fileext.upper(), fileext)
filename = 'export.{0}'.format(fileext)
docpath = str(QFileDialog.getSaveFileName(self.mainwindow, title, filename, filters))
if docpath:
self.model.export_path = docpath
self.accept()
def exportTypeSelected(self, typeId):
self.model.export_all = typeId == ExportType.All
def exportFormatSelected(self, typeId):
self.model.export_format = typeId
#--- model --> view
def set_table_enabled(self, enabled):
self.tableView.setEnabled(enabled)
def set_export_button_enabled(self, enabled):
self.exportButton.setEnabled(enabled)