本文整理汇总了Python中PyQt5.QtWidgets.QActionGroup类的典型用法代码示例。如果您正苦于以下问题:Python QActionGroup类的具体用法?Python QActionGroup怎么用?Python QActionGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QActionGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_menu
def setup_menu():
u"""
Add a submenu to a view menu.
Add a submenu that lists the available extra classes to the view
menu, creating that menu when neccessary
"""
if extra_classes_list:
try:
mw.addon_view_menu
except AttributeError:
mw.addon_view_menu = QMenu(_(u"&View"), mw)
mw.form.menubar.insertMenu(
mw.form.menuTools.menuAction(), mw.addon_view_menu)
mw.extra_class_submenu = QMenu(u"Mode (e&xtra class)", mw)
mw.addon_view_menu.addMenu(mw.extra_class_submenu)
action_group = QActionGroup(mw, exclusive=True)
no_class_action = action_group.addAction(
QAction('(none/standard)', mw, checkable=True))
no_class_action.setChecked(True)
mw.extra_class_submenu.addAction(no_class_action)
mw.connect(no_class_action, SIGNAL("triggered()"),
lambda: set_extra_class(None))
for ecd in extra_classes_list:
nn_class_action = action_group.addAction(
QAction(ecd['display'], mw, checkable=True))
mw.extra_class_submenu.addAction(nn_class_action)
mw.connect(nn_class_action, SIGNAL("triggered()"),
lambda ec=ecd['class']: set_extra_class(ec))
示例2: addShowActions
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)
示例3: __init__
def __init__(self, mainwindow):
QActionGroup.__init__(self, mainwindow)
self._acts = {}
self._accels = {}
self.setExclusive(True)
for branch in vcs.app_repo.branches():
self.addBranch(branch)
self.triggered.connect(self.slotTriggered)
示例4: generateViewMenu
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)
示例5: create_size_actions
def create_size_actions(self):
"""Creates window size actions."""
group = QActionGroup(self)
group.setExclusive(True)
for num, size in enumerate(
sorted(self.sizes.keys()), 1):
width, height = size
action = self.sizes[size]
action.setActionGroup(group)
w, h = width, height+self.widgets_height
action.setText("%dX" % num)
action.setToolTip("%sx%s" % (width, height))
action.triggered.connect(lambda t, wi=w, he=h: self.resize(wi, he))
示例6: _create_actions
def _create_actions(self):
group = QActionGroup(self)
self.grid_action = QAction(
'&Grid', self, shortcut='ctrl+G', triggered=self.show_grid,
checkable=True, icon=load_icon(':/icons/show_grid.png')
)
self.grid_action.setChecked(True)
group.addAction(self.grid_action)
self.expanded_action = QAction(
'&Expanded', self, shortcut='ctrl+E', triggered=self.show_expanded,
checkable=True, icon=load_icon(':/icons/show_expanded.png')
)
group.addAction(self.expanded_action)
示例7: create_state_slots
def create_state_slots(self):
"""Creates state slot actions."""
group = QActionGroup(self)
group.setExclusive(True)
for slot in range(10):
self.slots[slot] = QAction(self)
self.slots[slot].setCheckable(True)
self.slots[slot].setText("Slot %d" % slot)
self.slots[slot].setShortcut(QKeySequence(str(slot)))
self.slots[slot].setActionGroup(group)
self.menuStateSlot.addAction(self.slots[slot])
self.slots[0].setChecked(True)
for slot, action in self.slots.items():
action.triggered.connect(lambda t, s=slot: self.worker.state_set_slot(s))
示例8: createActionGroup
def createActionGroup(parent, name=None, exclusive=False):
"""
Module function to create an action group.
@param parent parent object of the action group (QObject)
@param name name of the action group object (string)
@param exclusive flag indicating an exclusive action group (boolean)
@return reference to the created action group (QActionGroup)
"""
actGrp = QActionGroup(parent)
if name:
actGrp.setObjectName(name)
actGrp.setExclusive(exclusive)
return actGrp
示例9: __init__
def __init__(self, mainwindow):
QActionGroup.__init__(self, mainwindow)
self._acts = {}
self._accels = {}
self.setExclusive(True)
for d in app.documents:
self.addDocument(d)
app.documentCreated.connect(self.addDocument)
app.documentClosed.connect(self.removeDocument)
app.documentUrlChanged.connect(self.setDocumentStatus)
app.documentModificationChanged.connect(self.setDocumentStatus)
app.jobStarted.connect(self.setDocumentStatus)
app.jobFinished.connect(self.setDocumentStatus)
mainwindow.currentDocumentChanged.connect(self.setCurrentDocument)
engrave.engraver(mainwindow).stickyChanged.connect(self.setDocumentStatus)
self.triggered.connect(self.slotTriggered)
示例10: __init__
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
示例11: cb_backends
def cb_backends(self):
self.cb_backends = QComboBox()
self.cb_backends.addItem('Auto')
menuLyricSource = QMenu(self.ui.menuEdit)
menuLyricSource.setTitle('Lyric source')
self.lyricGroup = QActionGroup(self)
def addAction(name, checked=False):
action = QAction(name, self)
action.setText(name)
action.setCheckable(True)
action.setChecked(checked)
action.setActionGroup(self.lyricGroup)
return action
menuLyricSource.addAction(addAction('Auto', True))
menuLyricSource.addSeparator()
menuLyricSource.triggered.connect(self._menu_backend_change)
for backend in Pyrics.get_backends():
menuLyricSource.addAction(addAction(backend.__name__))
self.cb_backends.addItem(backend.__name__)
self.ui.menuEdit.addMenu(menuLyricSource)
self.ui.toolBar.addWidget(self.cb_backends)
self.cb_backends.currentIndexChanged.connect(self._cb_backend_change)
示例12: __init__
def __init__(self, **kwargs):
super(SearchOptionsButton, self).__init__(**kwargs)
self.setText(self.tr('Options'))
menu = QMenu()
self.actionCi = menu.addAction(self.tr('Case insensitive'))
menu.addSeparator()
self.actionFormat = QActionGroup(self)
self.actionPlain = menu.addAction(self.tr('Plain text'))
self.actionPlain.setEnabled(False)
self.actionRe = menu.addAction(self.tr('Regular expression'))
self.actionGlob = menu.addAction(self.tr('Glob pattern'))
self.actionGlob.setEnabled(False)
self.actionFormat.addAction(self.actionPlain)
self.actionFormat.addAction(self.actionRe)
self.actionFormat.addAction(self.actionGlob)
self.actionRoot = menu.addAction(self.tr('Search in best root dir'))
for act in [self.actionCi, self.actionRe, self.actionPlain, self.actionGlob, self.actionRoot]:
act.setCheckable(True)
self.actionRe.setChecked(True)
self.setMenu(menu)
示例13: setupMenuBar
def setupMenuBar(self):
self.fileMenu = self.menuBar().addMenu("&File")
self.dateFormatMenu = self.fileMenu.addMenu("&Date format")
self.dateFormatGroup = QActionGroup(self)
for f in self.dateFormats:
action = QAction(f, self, checkable=True,
triggered=self.changeDateFormat)
self.dateFormatGroup.addAction(action)
self.dateFormatMenu.addAction(action)
if f == self.currentDateFormat:
action.setChecked(True)
self.fileMenu.addAction(self.printAction)
self.fileMenu.addAction(self.exitAction)
self.cellMenu = self.menuBar().addMenu("&Cell")
self.cellMenu.addAction(self.cell_addAction)
self.cellMenu.addAction(self.cell_subAction)
self.cellMenu.addAction(self.cell_mulAction)
self.cellMenu.addAction(self.cell_divAction)
self.cellMenu.addAction(self.cell_sumAction)
self.cellMenu.addSeparator()
self.cellMenu.addAction(self.colorAction)
self.cellMenu.addAction(self.fontAction)
self.menuBar().addSeparator()
self.aboutMenu = self.menuBar().addMenu("&Help")
self.aboutMenu.addAction(self.aboutSpreadSheet)
示例14: init_ui
def init_ui(self):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
widget = QWidget()
layout = QHBoxLayout()
self.stackWidget = SubWindowStack(self)
self.side_bar = SideBar(self)
# self.side_bar.detach_signal.connect(self.detach_window)
layout.addWidget(self.side_bar)
layout.addWidget(self.stackWidget)
# layout.addWidget(self.sub_window)
widget.setLayout(layout)
self.setCentralWidget(widget)
# window system :
self.window_system_parent_widget = self.stackWidget
self.side_bar.window_system_controller = self
# sub_windows :
self._sub_window_action_group = QActionGroup(self)
# write window
self.write_sub_window = WritePanel(
parent=self, parent_window_system_controller=self)
self.attach_sub_window(self.write_sub_window)
self.ui.actionWrite.setProperty(
"sub_window_object_name", "write_sub_window")
self.add_action_to_window_system(self.ui.actionWrite)
self._sub_window_action_group.addAction(self.ui.actionWrite)
# binder window
self.binder_sub_window = BinderPanel(
parent=self, parent_window_system_controller=self)
self.attach_sub_window(self.binder_sub_window)
self.ui.actionBinder.setProperty(
"sub_window_object_name", "binder_sub_window")
self.add_action_to_window_system(self.ui.actionBinder)
self._sub_window_action_group.addAction(self.ui.actionBinder)
self.ui.actionWrite.trigger()
# menu bar actions
self.ui.actionOpen_test_project.triggered.connect(
self.launch_open_test_project)
self.ui.actionPreferences.triggered.connect(self.launch_preferences)
self.ui.actionStart_window.triggered.connect(self.launch_start_window)
self.ui.actionSave.triggered.connect(cfg.core.project.save)
self.ui.actionSave_as.triggered.connect(self.launch_save_as_dialog)
self.ui.actionOpen.triggered.connect(self.launch_open_dialog)
self.ui.actionClose_project.triggered.connect(self.launch_close_dialog)
self.ui.actionExit.triggered.connect(self.launch_exit_dialog)
self._enable_actions(False)
示例15: __init__
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setupUi(self)
self.splitter.setStretchFactor(0, 5)
self.splitter.setStretchFactor(1, 70)
self.listDelegate = listCompleterDelegate(self)
self.list.setItemDelegate(self.listDelegate)
self.list.itemClicked.connect(self.showDiff)
self.list.setContextMenuPolicy(Qt.CustomContextMenu)
self.list.customContextMenuRequested.connect(self.popupMenu)
self.btnDelete.setEnabled(False)
self.btnDelete.clicked.connect(self.delete)
self.btnRestore.clicked.connect(self.restore)
self.btnRestore.setEnabled(False)
# self.list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.updateTimer = QTimer()
self.updateTimer.setSingleShot(True)
self.updateTimer.setInterval(500)
self.updateTimer.timeout.connect(self.update)
self.updateTimer.stop()
self.menu = QMenu(self)
self.actGroup = QActionGroup(self)
self.actShowDiff = QAction(self.tr("Show modifications"), self.menu)
self.actShowDiff.setCheckable(True)
self.actShowDiff.setChecked(True)
self.actShowDiff.triggered.connect(self.showDiff)
self.menu.addAction(self.actShowDiff)
self.actGroup.addAction(self.actShowDiff)
self.actShowVersion = QAction(self.tr("Show ancient version"), self.menu)
self.actShowVersion.setCheckable(True)
self.actShowVersion.setChecked(False)
self.actShowVersion.triggered.connect(self.showDiff)
self.menu.addAction(self.actShowVersion)
self.actGroup.addAction(self.actShowVersion)
self.menu.addSeparator()
self.actShowSpaces = QAction(self.tr("Show spaces"), self.menu)
self.actShowSpaces.setCheckable(True)
self.actShowSpaces.setChecked(False)
self.actShowSpaces.triggered.connect(self.showDiff)
self.menu.addAction(self.actShowSpaces)
self.actDiffOnly = QAction(self.tr("Show modifications only"), self.menu)
self.actDiffOnly.setCheckable(True)
self.actDiffOnly.setChecked(True)
self.actDiffOnly.triggered.connect(self.showDiff)
self.menu.addAction(self.actDiffOnly)
self.btnOptions.setMenu(self.menu)
self._model = None
self._index = None