本文整理汇总了Python中PyQt5.Qt.QTableView.selectRow方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.selectRow方法的具体用法?Python QTableView.selectRow怎么用?Python QTableView.selectRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTableView
的用法示例。
在下文中一共展示了QTableView.selectRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginUpdaterDialog
# 需要导入模块: from PyQt5.Qt import QTableView [as 别名]
# 或者: from PyQt5.Qt.QTableView import selectRow [as 别名]
#.........这里部分代码省略.........
self.forum_link = display_plugin.forum_link
self.zip_url = display_plugin.zip_url
self.forum_action.setEnabled(bool(self.forum_link))
self.install_button.setEnabled(display_plugin.is_valid_to_install())
self.install_action.setEnabled(self.install_button.isEnabled())
self.uninstall_action.setEnabled(display_plugin.is_installed())
self.history_action.setEnabled(display_plugin.has_changelog)
self.configure_button.setEnabled(display_plugin.is_installed())
self.configure_action.setEnabled(self.configure_button.isEnabled())
self.toggle_enabled_action.setEnabled(display_plugin.is_installed())
self.donate_enabled_action.setEnabled(bool(display_plugin.donation_link))
else:
self.description.setText('')
self.forum_link = None
self.zip_url = None
self.forum_action.setEnabled(False)
self.install_button.setEnabled(False)
self.install_action.setEnabled(False)
self.uninstall_action.setEnabled(False)
self.history_action.setEnabled(False)
self.configure_button.setEnabled(False)
self.configure_action.setEnabled(False)
self.toggle_enabled_action.setEnabled(False)
self.donate_enabled_action.setEnabled(False)
self.update_forum_label()
def _donate_clicked(self):
plugin = self._selected_display_plugin()
if plugin and plugin.donation_link:
open_url(QUrl(plugin.donation_link))
def _select_and_focus_view(self, change_selection=True):
if change_selection and self.plugin_view.model().rowCount() > 0:
self.plugin_view.selectRow(0)
else:
idx = self.plugin_view.selectionModel().currentIndex()
self._plugin_current_changed(idx, 0)
self.plugin_view.setFocus()
def _filter_combo_changed(self, idx):
self.filter_by_name_lineedit.setText("") # clear the name filter text when a different group was selected
self.proxy_model.set_filter_criteria(idx)
if idx == FILTER_NOT_INSTALLED:
self.plugin_view.sortByColumn(5, Qt.DescendingOrder)
else:
self.plugin_view.sortByColumn(0, Qt.AscendingOrder)
self._select_and_focus_view()
def _filter_name_lineedit_changed(self, text):
self.proxy_model.set_filter_text(text) # set the filter text for filterAcceptsRow
def _forum_label_activated(self):
if self.forum_link:
open_url(QUrl(self.forum_link))
def _selected_display_plugin(self):
idx = self.plugin_view.selectionModel().currentIndex()
actual_idx = self.proxy_model.mapToSource(idx)
return self.model.display_plugins[actual_idx.row()]
def _uninstall_plugin(self, name_to_remove):
if DEBUG:
prints('Removing plugin: ', name_to_remove)
remove_plugin(name_to_remove)
# Make sure that any other plugins that required this plugin
# to be uninstalled first have the requirement removed
示例2: AnnotatedBooksDialog
# 需要导入模块: from PyQt5.Qt import QTableView [as 别名]
# 或者: from PyQt5.Qt.QTableView import selectRow [as 别名]
#.........这里部分代码省略.........
if self.show_confidence_colors:
scb_text = "Hide match status"
self.show_confidence_button = self.dialogButtonBox.addButton(scb_text, QDialogButtonBox.ActionRole)
self.show_confidence_button.setObjectName('confidence_button')
if self.show_confidence_colors:
self.show_confidence_button.setIcon(get_icon('images/matches_hide.png'))
else:
self.show_confidence_button.setIcon(get_icon('images/matches_show.png'))
self.preview_button = self.dialogButtonBox.addButton('Preview', QDialogButtonBox.ActionRole)
self.preview_button.setObjectName('preview_button')
self.dialogButtonBox.clicked.connect(self.show_annotated_books_dialog_clicked)
self.l.addWidget(self.dialogButtonBox)
# Cause our dialog size to be restored from prefs or created on first usage
self.resize_dialog()
def capture_sort_column(self, sort_column):
sort_order = self.tv.horizontalHeader().sortIndicatorOrder()
self.opts.prefs.set('annotated_books_dialog_sort_column', sort_column)
self.opts.prefs.set('annotated_books_dialog_sort_order', sort_order)
def fetch_selected_annotations(self):
'''
Invoked by 'Import annotations' button in show_annotated_books_dialog()
Populate a list of books by Reader App:
{ 'iBooks': [{'title':, 'author':, 'uuid'}, ...],
'Marvin': [{'title':, 'author':, 'uuid'}, ...] }
'''
self.selected_books = {}
for i in range(len(self.tabledata)):
self.tv.selectRow(i)
enabled = bool(self.tm.arraydata[i][self.ENABLED_COL].checkState())
if not enabled:
continue
reader_app = str(self.tm.arraydata[i][self.annotations_header.index('Reader App')].text())
if not reader_app in self.selected_books:
self.selected_books[reader_app] = []
author = str(self.tm.arraydata[i][self.annotations_header.index('Author')].text())
book_id = self.tm.arraydata[i][self.annotations_header.index('book_id')]
genre = self.tm.arraydata[i][self.annotations_header.index('genre')]
title = str(self.tm.arraydata[i][self.annotations_header.index('Title')].text())
uuid = self.tm.arraydata[i][self.annotations_header.index('uuid')]
book_mi = BookStruct()
book_mi.author = author
book_mi.book_id = book_id
book_mi.genre = genre
book_mi.reader_app = reader_app
book_mi.title = title
book_mi.uuid = uuid
self.selected_books[reader_app].append(book_mi)
def getTableRowDoubleClick(self, index):
self.preview_annotations()
def preview_annotations(self):
"""
The listed annotations are in annotations.db.
AnnotationsDB:annotations_to_HTML() needs title, book_id, reader_app
"""
i = self.tvSelectionModel.currentIndex().row()