本文整理汇总了Python中PyQt4.Qt.QTableView.setContextMenuPolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setContextMenuPolicy方法的具体用法?Python QTableView.setContextMenuPolicy怎么用?Python QTableView.setContextMenuPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTableView
的用法示例。
在下文中一共展示了QTableView.setContextMenuPolicy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginUpdaterDialog
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setContextMenuPolicy [as 别名]
#.........这里部分代码省略.........
forum_label = self.forum_label = QLabel('')
forum_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard)
forum_label.linkActivated.connect(self._forum_label_activated)
details_layout.addWidget(QLabel(_('Description')+':', self), 0, Qt.AlignLeft)
details_layout.addWidget(forum_label, 1, Qt.AlignRight)
self.description = QLabel(self)
self.description.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.description.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.description.setMinimumHeight(40)
self.description.setWordWrap(True)
layout.addWidget(self.description)
self.button_box = QDialogButtonBox(QDialogButtonBox.Close)
self.button_box.rejected.connect(self.reject)
self.finished.connect(self._finished)
self.install_button = self.button_box.addButton(_('&Install'), QDialogButtonBox.AcceptRole)
self.install_button.setToolTip(_('Install the selected plugin'))
self.install_button.clicked.connect(self._install_clicked)
self.install_button.setEnabled(False)
self.configure_button = self.button_box.addButton(' '+_('&Customize plugin ')+' ', QDialogButtonBox.ResetRole)
self.configure_button.setToolTip(_('Customize the options for this plugin'))
self.configure_button.clicked.connect(self._configure_clicked)
self.configure_button.setEnabled(False)
layout.addWidget(self.button_box)
def update_forum_label(self):
txt = ''
if self.forum_link:
txt = '<a href="%s">%s</a>' % (self.forum_link, self.forum_label_text)
self.forum_label.setText(txt)
def _create_context_menu(self):
self.plugin_view.setContextMenuPolicy(Qt.ActionsContextMenu)
self.install_action = QAction(QIcon(I('plugins/plugin_upgrade_ok.png')), _('&Install'), self)
self.install_action.setToolTip(_('Install the selected plugin'))
self.install_action.triggered.connect(self._install_clicked)
self.install_action.setEnabled(False)
self.plugin_view.addAction(self.install_action)
self.history_action = QAction(QIcon(I('chapters.png')), _('Version &History'), self)
self.history_action.setToolTip(_('Show history of changes to this plugin'))
self.history_action.triggered.connect(self._history_clicked)
self.history_action.setEnabled(False)
self.plugin_view.addAction(self.history_action)
self.forum_action = QAction(QIcon(I('plugins/mobileread.png')), _('Plugin &Forum Thread'), self)
self.forum_action.triggered.connect(self._forum_label_activated)
self.forum_action.setEnabled(False)
self.plugin_view.addAction(self.forum_action)
sep1 = QAction(self)
sep1.setSeparator(True)
self.plugin_view.addAction(sep1)
self.toggle_enabled_action = QAction(_('Enable/&Disable plugin'), self)
self.toggle_enabled_action.setToolTip(_('Enable or disable this plugin'))
self.toggle_enabled_action.triggered.connect(self._toggle_enabled_clicked)
self.toggle_enabled_action.setEnabled(False)
self.plugin_view.addAction(self.toggle_enabled_action)
self.uninstall_action = QAction(_('&Remove plugin'), self)
self.uninstall_action.setToolTip(_('Uninstall the selected plugin'))
self.uninstall_action.triggered.connect(self._uninstall_clicked)
self.uninstall_action.setEnabled(False)
self.plugin_view.addAction(self.uninstall_action)
sep2 = QAction(self)
sep2.setSeparator(True)
示例2: PluginObject
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setContextMenuPolicy [as 别名]
#.........这里部分代码省略.........
privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
signedTx = PyCreateAndSignTx(utxiList,
[],
privKeyMap, SIGHASH_NONE|SIGHASH_ANYONECANPAY )
print "-------------"
print binary_to_hex(signedTx.serialize())
# sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
# sock.send(signedTx.serialize())
# sock.send(b'\n')
# sock.close()
except socket.error as err:
QMessageBox.critical(self.main, tr('Negative Value'), tr("""
Failed to connect to dust-b-gone server: %s""" % err.strerror), QMessageBox.Ok)
except NegativeValueError:
QMessageBox.critical(self.main, tr('Negative Value'), tr("""
You must enter a positive value of at least 0.0000 0001
and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
except TooMuchPrecisionError:
QMessageBox.critical(self.main.main, tr('Too much precision'), tr("""
Bitcoins can only be specified down to 8 decimal places.
The smallest unit of a Groestlcoin is 0.0000 0001 GRS.
Please enter a dust limit of at least 0.0000 0001 and less than %s.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
finally:
for scraddr in privKeyMap:
privKeyMap[scraddr].destroy()
self.main = main
self.lblHeader = QRichLabel(tr("""<b>Dust Outputs for Wallet: None Selected</b>"""), doWrap=False)
self.beGoneDustButton = QPushButton("Remove Dust")
self.beGoneDustButton.setEnabled(False)
self.main.connect(self.beGoneDustButton, SIGNAL('clicked()'), sendDust)
topRow = makeHorizFrame([self.lblHeader,'stretch'])
secondRow = makeHorizFrame([self.beGoneDustButton, 'stretch'])
self.dustLimitLabel = QLabel("Max Dust Value (GRS): ")
self.dustLimitText = QLineEdit()
self.dustLimitText.setFont(GETFONT('Fixed'))
self.dustLimitText.setMinimumWidth(tightSizeNChar(self.dustLimitText, 6)[0])
self.dustLimitText.setMaximumWidth(tightSizeNChar(self.dustLimitText, 12)[0])
self.dustLimitText.setAlignment(Qt.AlignRight)
self.dustLimitText.setText(coin2str(DEFAULT_DUST_LIMIT))
self.main.connect(self.dustLimitText, SIGNAL('textChanged(QString)'), updateDustLimit)
limitPanel = makeHorizFrame([self.dustLimitLabel, self.dustLimitText, 'stretch'])
self.dustTableModel = DustDisplayModel()
self.dustTableView = QTableView()
self.dustTableView.setModel(self.dustTableModel)
self.dustTableView.setSelectionMode(QTableView.NoSelection)
self.dustTableView.verticalHeader().setDefaultSectionSize(20)
self.dustTableView.verticalHeader().hide()
h = tightSizeNChar(self.dustTableView, 1)[1]
self.dustTableView.setMinimumHeight(2 * (1.3 * h))
self.dustTableView.setMaximumHeight(10 * (1.3 * h))
initialColResize(self.dustTableView, [100, .7, .3])
self.dustTableView.setContextMenuPolicy(Qt.CustomContextMenu)
self.lblTxioInfo = QRichLabel('')
self.lblTxioInfo.setMinimumWidth(tightSizeNChar(self.lblTxioInfo, 30)[0])
self.main.connect(self.main.walletsView, SIGNAL('clicked(QModelIndex)'),
updateDustLimit)
self.dustBGoneFrame = makeVertFrame([topRow, secondRow, limitPanel, self.dustTableView, 'stretch'])
# Now set the scrollarea widget to the layout
self.tabToDisplay = QScrollArea()
self.tabToDisplay.setWidgetResizable(True)
self.tabToDisplay.setWidget(self.dustBGoneFrame)
def getSelectedWlt(self):
wlt = None
selectedWltList = self.main.walletsView.selectedIndexes()
if len(selectedWltList)>0:
row = selectedWltList[0].row()
wltID = str(self.main.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
wlt = self.main.walletMap[wltID]
return wlt
#############################################################################
def getTabToDisplay(self):
return self.tabToDisplay
def injectShutdownFunc(self):
try:
self.main.writeSetting('DustLedgerCols', saveTableView(self.dustTableView))
except:
LOGEXCEPT('Strange error during shutdown')
示例3: PluginObject
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setContextMenuPolicy [as 别名]
#.........这里部分代码省略.........
self.segOrdStrSet.add(str(dlgSpecifyOrdering.parseOrderingList()).strip('[]'))
self.updateOrderingListBox()
else:
QMessageBox.warning(self.main, tr('Not Ready'), tr("""
No segments have been entered. You must enter some segments before you can order them."""), QMessageBox.Ok)
self.main = main
self.segDefList = []
self.segOrdStrSet = set()
segmentHeader = QRichLabel(tr("""<b>Build segments for pass phrase search: </b>"""), doWrap=False)
self.knownButton = QPushButton("Add Known Segment")
self.unknownCaseButton = QPushButton("Add Unknown Case Segment")
self.unknownOrderButton = QPushButton("Add Unknown Order Segment")
self.main.connect(self.knownButton, SIGNAL('clicked()'), addKnownSegment)
self.main.connect(self.unknownCaseButton, SIGNAL('clicked()'), addUnknownCaseSegment)
self.main.connect(self.unknownOrderButton, SIGNAL('clicked()'), addUnknownOrderSegment)
topRow = makeHorizFrame([segmentHeader, self.knownButton, self.unknownCaseButton, self.unknownOrderButton, 'stretch'])
self.segDefTableModel = SegDefDisplayModel()
self.segDefTableView = QTableView()
self.segDefTableView.setModel(self.segDefTableModel)
self.segDefTableView.setSelectionBehavior(QTableView.SelectRows)
self.segDefTableView.setSelectionMode(QTableView.SingleSelection)
self.segDefTableView.verticalHeader().setDefaultSectionSize(20)
self.segDefTableView.verticalHeader().hide()
h = tightSizeNChar(self.segDefTableView, 1)[1]
self.segDefTableView.setMinimumHeight(2 * (1.3 * h))
self.segDefTableView.setMaximumHeight(10 * (1.3 * h))
initialColResize(self.segDefTableView, [.1, .2, .4, .1, .1, .1])
self.segDefTableView.customContextMenuRequested.connect(self.showSegContextMenu)
self.segDefTableView.setContextMenuPolicy(Qt.CustomContextMenu)
segmentOrderingsHeader = QRichLabel(tr("""<b>Specify orderings for pass phrase search: </b>"""), doWrap=False)
self.addOrderingButton = QPushButton("Add Ordering")
self.main.connect(self.addOrderingButton, SIGNAL('clicked()'), addOrdering)
orderingButtonPanel = makeHorizFrame([segmentOrderingsHeader, self.addOrderingButton, 'stretch'])
self.segOrdListBox = QListWidget()
self.segOrdListBox.customContextMenuRequested.connect(self.showOrdContextMenu)
self.segOrdListBox.setContextMenuPolicy(Qt.CustomContextMenu)
self.searchButton = QPushButton("Search")
self.main.connect(self.searchButton, SIGNAL('clicked()'), searchForPassphrase)
self.stopButton = QPushButton("Stop Searching")
self.stopButton.setEnabled(False)
self.main.connect(self.stopButton, SIGNAL('clicked()'), endSearch)
totalSearchLabel = QRichLabel(tr("""<b>Total Passphrase Tries To Search: </b>"""), doWrap=False)
self.totalSearchTriesDisplay = QLineEdit()
self.totalSearchTriesDisplay.setReadOnly(True)
self.totalSearchTriesDisplay.setText(QString('0'))
self.totalSearchTriesDisplay.setFont(GETFONT('Fixed'))
self.totalSearchTriesDisplay.setMinimumWidth(tightSizeNChar(self.totalSearchTriesDisplay, 6)[0])
self.totalSearchTriesDisplay.setMaximumWidth(tightSizeNChar(self.totalSearchTriesDisplay, 12)[0])
searchButtonPanel = makeHorizFrame([self.searchButton, self.stopButton, 'stretch', totalSearchLabel, self.totalSearchTriesDisplay])
self.resultsDisplay = QTextEdit()
self.resultsDisplay.setReadOnly(True)
self.resultsDisplay.setFont(GETFONT('Fixed'))
self.resultsDisplay.setMinimumHeight(100)
示例4: PluginUpdaterDialog
# 需要导入模块: from PyQt4.Qt import QTableView [as 别名]
# 或者: from PyQt4.Qt.QTableView import setContextMenuPolicy [as 别名]
class PluginUpdaterDialog(SizePersistedDialog):
initial_extra_size = QSize(350, 100)
def __init__(self, gui, initial_filter=FILTER_UPDATE_AVAILABLE):
SizePersistedDialog.__init__(self, gui, "Plugin Updater plugin:plugin updater dialog")
self.gui = gui
self.forum_link = None
self.model = None
self.do_restart = False
self._initialize_controls()
self._create_context_menu()
display_plugins = read_available_plugins()
if display_plugins:
self.model = DisplayPluginModel(display_plugins)
self.proxy_model = DisplayPluginSortFilterModel(self)
self.proxy_model.setSourceModel(self.model)
self.plugin_view.setModel(self.proxy_model)
self.plugin_view.resizeColumnsToContents()
self.plugin_view.selectionModel().currentRowChanged.connect(self._plugin_current_changed)
self.plugin_view.doubleClicked.connect(self.install_button.click)
self.filter_combo.setCurrentIndex(initial_filter)
self._select_and_focus_view()
else:
error_dialog(
self.gui,
_("Update Check Failed"),
_("Unable to reach the MobileRead plugins forum index page."),
det_msg=MR_INDEX_URL,
show=True,
)
self.filter_combo.setEnabled(False)
# Cause our dialog size to be restored from prefs or created on first usage
self.resize_dialog()
def _initialize_controls(self):
self.setWindowTitle(_("User plugins"))
self.setWindowIcon(QIcon(I("plugins/plugin_updater.png")))
layout = QVBoxLayout(self)
self.setLayout(layout)
title_layout = ImageTitleLayout(self, "plugins/plugin_updater.png", _("User Plugins"))
layout.addLayout(title_layout)
header_layout = QHBoxLayout()
layout.addLayout(header_layout)
self.filter_combo = PluginFilterComboBox(self)
self.filter_combo.setMinimumContentsLength(20)
self.filter_combo.currentIndexChanged[int].connect(self._filter_combo_changed)
header_layout.addWidget(QLabel(_("Filter list of plugins") + ":", self))
header_layout.addWidget(self.filter_combo)
header_layout.addStretch(10)
self.plugin_view = QTableView(self)
self.plugin_view.horizontalHeader().setStretchLastSection(True)
self.plugin_view.setSelectionBehavior(QAbstractItemView.SelectRows)
self.plugin_view.setSelectionMode(QAbstractItemView.SingleSelection)
self.plugin_view.setAlternatingRowColors(True)
self.plugin_view.setSortingEnabled(True)
self.plugin_view.setIconSize(QSize(28, 28))
layout.addWidget(self.plugin_view)
details_layout = QHBoxLayout()
layout.addLayout(details_layout)
forum_label = QLabel('<a href="http://www.foo.com/">Plugin Forum Thread</a>', self)
forum_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard)
forum_label.linkActivated.connect(self._forum_label_activated)
details_layout.addWidget(QLabel(_("Description") + ":", self), 0, Qt.AlignLeft)
details_layout.addWidget(forum_label, 1, Qt.AlignRight)
self.description = QLabel(self)
self.description.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.description.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.description.setMinimumHeight(40)
self.description.setWordWrap(True)
layout.addWidget(self.description)
self.button_box = QDialogButtonBox(QDialogButtonBox.Close)
self.button_box.rejected.connect(self.reject)
self.finished.connect(self._finished)
self.install_button = self.button_box.addButton(_("&Install"), QDialogButtonBox.AcceptRole)
self.install_button.setToolTip(_("Install the selected plugin"))
self.install_button.clicked.connect(self._install_clicked)
self.install_button.setEnabled(False)
self.configure_button = self.button_box.addButton(
" " + _("&Customize plugin ") + " ", QDialogButtonBox.ResetRole
)
self.configure_button.setToolTip(_("Customize the options for this plugin"))
self.configure_button.clicked.connect(self._configure_clicked)
self.configure_button.setEnabled(False)
layout.addWidget(self.button_box)
def _create_context_menu(self):
self.plugin_view.setContextMenuPolicy(Qt.ActionsContextMenu)
self.install_action = QAction(QIcon(I("plugins/plugin_upgrade_ok.png")), _("&Install"), self)
self.install_action.setToolTip(_("Install the selected plugin"))
self.install_action.triggered.connect(self._install_clicked)
self.install_action.setEnabled(False)
self.plugin_view.addAction(self.install_action)
#.........这里部分代码省略.........