本文整理汇总了Python中PyQt5.QtWidgets.QAction.setCheckable方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.setCheckable方法的具体用法?Python QAction.setCheckable怎么用?Python QAction.setCheckable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.setCheckable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addShowActions
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def addShowActions(self):
"""Adds a submenu giving access to the (other)
opened viewer documents"""
mds = self._actionCollection.viewer_document_select
docs = mds.viewdocs()
document_actions = {}
multi_docs = len(docs) > 1
if self._panel.widget().currentViewdoc():
current_doc_filename = self._panel.widget().currentViewdoc().filename()
m = self._menu
sm = QMenu(m)
sm.setTitle(_("Show..."))
sm.setEnabled(multi_docs)
ag = QActionGroup(m)
ag.triggered.connect(self._panel.slotShowViewdoc)
for d in docs:
action = QAction(sm)
action.setText(d.name())
action._document_filename = d.filename()
# TODO: Tooltips aren't shown by Qt (it seems)
action.setToolTip(d.filename())
action.setCheckable(True)
action.setChecked(d.filename() == current_doc_filename)
ag.addAction(action)
sm.addAction(action)
m.addSeparator()
m.addMenu(sm)
示例2: __init__
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def __init__(self):
QLabel.__init__(self)
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_NoSystemBackground)
self.setMouseTracking(True)
self.dragPosition = QPoint(0, 0)
self.mousePosition = QCursor.pos()
self.actionFaces = QActionGroup(self)
allFaceActions = []
for name in sorted(self.faces):
action = QAction(name, self.actionFaces)
action.setCheckable(True)
allFaceActions.append(action)
self.actionFaces.triggered.connect(self.actionUpdateFace)
startAction = random.choice(allFaceActions)
startAction.setChecked(True)
self.actionUpdateFace(startAction)
self.actionQuit = QAction("Quit", self)
self.actionQuit.triggered.connect(QApplication.instance().quit)
self.timer = QTimer()
self.timer.timeout.connect(self.updateFromMousePosition)
self.timer.start(self.update_interval)
self.painter = None
示例3: addDocument
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def addDocument(self, doc):
a = QAction(self)
a.setCheckable(True)
if doc is self.mainwindow().currentDocument():
a.setChecked(True)
self._acts[doc] = a
self.setDocumentStatus(doc)
示例4: add_toggle_action_to_menu
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def add_toggle_action_to_menu(self, menu, caption, checked, call):
action = QAction(caption, menu)
action.setCheckable(True)
action.setChecked(checked)
menu.addAction(action)
action.toggled.connect(call)
return action
示例5: addCustomWidget
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def addCustomWidget(self, text, widget, group=None, defaultVisibility=True):
"""
Adds a custom widget to the toolbar.
`text` is the name that will displayed on the button to switch visibility.
`widget` is the widget to control from the toolbar.
`group` is an integer (or any hashable) if the current widget should not
be displayed all the time. Call `collapsibleDockWidgets.setCurrentGroup`
to switch to that group and hide other widgets.
`defaultVisibility` is the default visibility of the item when it is added.
This allows for the widget to be added to `collapsibleDockWidgets` after
they've been created but before they are shown, and yet specify their
desired visibility. Otherwise it creates troubles, see #167 on github:
https://github.com/olivierkes/manuskript/issues/167.
"""
a = QAction(text, self)
a.setCheckable(True)
a.setChecked(defaultVisibility)
a.toggled.connect(widget.setVisible)
widget.setVisible(defaultVisibility)
# widget.installEventFilter(self)
b = verticalButton(self)
b.setDefaultAction(a)
#b.setChecked(widget.isVisible())
a2 = self.addWidget(b)
self.otherWidgets.append((b, a2, widget, group))
示例6: add_action
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def add_action(self, name, shortcut, callback, **kwargs):
"""
Ajoute une action au context menu et au widget navigation lui même.
Créer une fonction à la volé pour fournir des arguments aux fonctions
associé aux actions.
"""
action = QAction(self.tr(name), self)
if 'icon' in kwargs:
action.setIcon(kwargs['icon'])
if 'checkable' in kwargs and kwargs['checkable']:
action.setCheckable(True)
if 'checked' in kwargs:
checked = True if kwargs['checked'] == 'true' else False
action.setChecked(
checked
)
action.setShortcut(shortcut)
action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
if 'wrapped' in kwargs and kwargs['wrapped'] is False:
action.triggered.connect(callback)
else:
action.triggered.connect(self.__wrapper(callback))
self.addAction(action)
self.menu.addAction(action)
self.editor_actions[name] = action
示例7: _make_context_menu
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def _make_context_menu(self):
global _TR
m = QMenu(self)
act1 = QAction( _TR("EditViewWidget","Mark Scannos","context menu item"), m )
act1.setCheckable(True)
act1.setToolTip( _TR("EditViewWidget",
"Turn on or off marking of words from the scanno file",
"context menu tooltip") )
act1.toggled.connect(self._act_mark_scannos)
m.addAction(act1)
act2 = QAction( _TR("EditViewWidget","Mark Spelling","context menu item"), m )
act2.setCheckable(True)
act2.setToolTip( _TR("EditViewWidget",
"Turn on or off marking words that fail spellcheck",
"context menu tooltip") )
act2.toggled.connect(self._act_mark_spelling)
m.addAction(act2)
act3 = QAction( _TR("EditViewWidget","Scanno File...","context menu item"), m )
act3.setToolTip( _TR("EditViewWidget",
"Choose a file of scanno (common OCR error) words",
"context menu tooltip") )
act3.triggered.connect(self._act_choose_scanno)
m.addAction(act3)
act4 = QAction( _TR("EditViewWidget","Dictionary...","context menu item"), m )
act4.setToolTip( _TR("EditViewWidget",
"Choose the primary spelling dictionary for this book",
"context menu tooltip") )
act4.triggered.connect(self._act_choose_dict)
m.addAction(act4)
return m
示例8: addAction
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def addAction(name, checked=False):
action = QAction(name, self)
action.setText(name)
action.setCheckable(True)
action.setChecked(checked)
action.setActionGroup(self.lyricGroup)
return action
示例9: addBranch
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def addBranch(self, branch):
a = QAction(self)
a.setCheckable(True)
if branch == vcs.app_repo.current_branch():
a.setChecked(True)
a.setEnabled(False)
self._acts[branch] = a
self.setBranchStatus(branch)
示例10: generateViewMenu
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def generateViewMenu(self):
values = [
(self.tr("Nothing"), "Nothing"),
(self.tr("POV"), "POV"),
(self.tr("Label"), "Label"),
(self.tr("Progress"), "Progress"),
(self.tr("Compile"), "Compile"),
]
menus = [
(self.tr("Tree"), "Tree"),
(self.tr("Index cards"), "Cork"),
(self.tr("Outline"), "Outline")
]
submenus = {
"Tree": [
(self.tr("Icon color"), "Icon"),
(self.tr("Text color"), "Text"),
(self.tr("Background color"), "Background"),
],
"Cork": [
(self.tr("Icon"), "Icon"),
(self.tr("Text"), "Text"),
(self.tr("Background"), "Background"),
(self.tr("Border"), "Border"),
(self.tr("Corner"), "Corner"),
],
"Outline": [
(self.tr("Icon color"), "Icon"),
(self.tr("Text color"), "Text"),
(self.tr("Background color"), "Background"),
],
}
self.menuView.clear()
self.menuView.addMenu(self.menuMode)
self.menuView.addSeparator()
# print("Generating menus with", settings.viewSettings)
for mnu, mnud in menus:
m = QMenu(mnu, self.menuView)
for s, sd in submenus[mnud]:
m2 = QMenu(s, m)
agp = QActionGroup(m2)
for v, vd in values:
a = QAction(v, m)
a.setCheckable(True)
a.setData("{},{},{}".format(mnud, sd, vd))
if settings.viewSettings[mnud][sd] == vd:
a.setChecked(True)
a.triggered.connect(self.setViewSettingsAction, AUC)
agp.addAction(a)
m2.addAction(a)
m.addMenu(m2)
self.menuView.addMenu(m)
示例11: action
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def action(self):
icon = self.icon
if isinstance(icon, QStyle.StandardPixmap):
icon = self.plot.style().standardIcon(icon)
action = QAction(icon, self.text, self.plot)
action.setCheckable(True)
action.toggled.connect(self.onToggle)
self.plot.addCapture(self.mode, action.setChecked)
return action
示例12: addCustomWidget
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def addCustomWidget(self, text, widget, group=None):
a = QAction(text, self)
a.setCheckable(True)
a.setChecked(widget.isVisible())
a.toggled.connect(widget.setVisible)
# widget.installEventFilter(self)
b = verticalButton(self)
b.setDefaultAction(a)
#b.setChecked(widget.isVisible())
a2 = self.addWidget(b)
self.otherWidgets.append((b, a2, widget, group))
示例13: populate_channel_menu
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def populate_channel_menu(*args):
if sip.isdeleted(channel_button):
return
self.channel_menu.clear()
self.channel_actions = []
for ch in range(op.Input.meta.getTaggedShape()['c']):
action = QAction("Channel {}".format(ch), self.channel_menu)
action.setCheckable(True)
self.channel_menu.addAction(action)
self.channel_actions.append(action)
configure_update_handlers( action.toggled, op.ChannelSelections )
示例14: ActionSelector
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
class ActionSelector(TitledToolbar):
def __init__(self, parent):
TitledToolbar.__init__(self, parent, 'Actions')
toolbar = QToolBar(self)
toolbar.setFloatable(False)
toolbar.setMovable(False)
self.saveAction = QAction(QIcon(":/icons/file-save.png"), "Save (Ctrl-S)", toolbar)
self.saveAction.setShortcut(Qt.CTRL + Qt.Key_S);
self.saveAction.triggered.connect(parent.save)
toolbar.addAction(self.saveAction)
self.nonprintableAction = QAction(QIcon(":/icons/view-nonprintable.png"), "View nonprintable chars", toolbar)
self.nonprintableAction.setCheckable(True);
self.nonprintableAction.triggered.connect(parent.toggleNonprintable)
toolbar.addAction(self.nonprintableAction)
self.undoAction = QAction(QIcon(":/icons/edit-undo.png"), "Undo (Ctrl-Z)", toolbar)
# saveAction.setShortcut(Qt.CTRL + Qt.Key_Z);
self.undoAction.triggered.connect(parent.undo)
toolbar.addAction(self.undoAction)
self.redoAction = QAction(QIcon(":/icons/edit-redo.png"), "Redo (Ctrl-Y)", toolbar)
# saveAction.setShortcut(Qt.CTRL + Qt.Key_Y);
self.redoAction.triggered.connect(parent.redo)
toolbar.addAction(self.redoAction)
self.backAction = QAction(QIcon(":/icons/view-back.png"), "Back", toolbar)
self.backAction.setEnabled(False)
self.backAction.triggered.connect(parent.navigateBack)
toolbar.addAction(self.backAction)
self.forwardAction = QAction(QIcon(":/icons/view-forward.png"), "Forward", toolbar)
self.forwardAction.setEnabled(False)
self.forwardAction.triggered.connect(parent.navigateForward)
toolbar.addAction(self.forwardAction)
insertImageAction = QAction(QIcon(":/icons/edit-insert-image.png"), "Insert Image", toolbar)
insertImageAction.triggered.connect(parent.insertImage)
toolbar.addAction(insertImageAction)
insertFormulaAction = QAction("f(x)", toolbar)
insertFormulaAction.triggered.connect(parent.insertFormula)
toolbar.addAction(insertFormulaAction)
findInPageAction = QAction(QIcon(":/icons/edit-find.png"), "Find in page (CTRL-F)", toolbar)
findInPageAction.setShortcut(Qt.CTRL + Qt.Key_F);
findInPageAction.triggered.connect(parent.findInPage)
toolbar.addAction(findInPageAction)
self.addWidget(toolbar)
示例15: updateDevices
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import setCheckable [as 别名]
def updateDevices(self):
for action in self.deviceGroup.actions():
self.deviceGroup.removeAction(action)
self.menuDevice.removeAction(action)
for device in self.devices:
action = QAction(device.name, self.menuDevice)
action.setCheckable(True)
action.setData(device)
self.menuDevice.addAction(action)
self.deviceGroup.addAction(action)
action.setChecked(True)
self.device = device