本文整理汇总了Python中PyQt4.QtGui.QActionGroup类的典型用法代码示例。如果您正苦于以下问题:Python QActionGroup类的具体用法?Python QActionGroup怎么用?Python QActionGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QActionGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: device_discovery
def device_discovery(self, devs):
group = QActionGroup(self._menu_devices, exclusive=True)
for d in devs:
node = QAction(d["name"], self._menu_devices, checkable=True)
node.toggled.connect(self._inputdevice_selected)
group.addAction(node)
self._menu_devices.addAction(node)
if (d["name"] == GuiConfig().get("input_device")):
self._active_device = d["name"]
if (len(self._active_device) == 0):
self._active_device = self._menu_devices.actions()[0].text()
device_config_mapping = GuiConfig().get("device_config_mapping")
if (device_config_mapping):
if (self._active_device in device_config_mapping.keys()):
self._current_input_config = device_config_mapping[
str(self._active_device)]
else:
self._current_input_config = self._menu_mappings.actions()[0].text()
else:
self._current_input_config = self._menu_mappings.actions()[0].text()
# Now we know what device to use and what mapping, trigger the events
# to change the menus and start the input
for c in self._menu_mappings.actions():
c.setEnabled(True)
if (c.text() == self._current_input_config):
c.setChecked(True)
for c in self._menu_devices.actions():
if (c.text() == self._active_device):
c.setChecked(True)
示例2: createActionGroup
def createActionGroup(parent):
group = QActionGroup(parent)
for enc, region in _ENCODINGNAMES:
a = group.addAction('%s (%s)' % (region, enc))
a.setCheckable(True)
a.setData(enc)
return group
示例3: FloatingToolBar
class FloatingToolBar(QToolBar):
"""
A floating QToolBar with no border and is offset under its parent
"""
def __init__(self, name, parent):
"""
parent: The parent of this toolbar. Should be another toolbar
"""
QToolBar.__init__(self, name, parent)
self.setMovable(False)
self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint)
self.setAllowedAreas(Qt.NoToolBarArea)
self.actiongroup = QActionGroup(self)
def addToActionGroup(self, action):
self.actiongroup.addAction(action)
def showToolbar(self, parentaction, defaultaction, toggled):
if toggled:
self.show()
if defaultaction:
defaultaction.toggle()
widget = self.parent().widgetForAction(parentaction)
x = self.parent().mapToGlobal(widget.pos()).x()
y = self.parent().mapToGlobal(widget.pos()).y()
newpoint = QPoint(x, y + self.parent().rect().height())
# if self.orientation() == Qt.Vertical:
# newpoint = QPoint(x, y + self.parent().rect().width())
self.move(newpoint)
else:
action = self.actiongroup.checkedAction()
if action:
action.toggle()
self.hide()
示例4: __init__
def __init__(self, iface):
self.iface = iface
self.actions = []
self.panels= []
self.navtoolbar = self.iface.mapNavToolToolBar()
self.mainwindow = self.iface.mainWindow()
self.iface.projectRead.connect(self.projectOpened)
self.iface.initializationCompleted.connect(self.setupUI)
self.actionGroup = QActionGroup(self.mainwindow)
self.actionGroup.setExclusive(True)
self.menuGroup = QActionGroup(self.mainwindow)
self.menuGroup.setExclusive(True)
self.movetool = MoveTool(self.iface.mapCanvas(), [])
self.infotool = InfoTool(self.iface.mapCanvas())
self.infotool.infoResults.connect(self.showInfoResults)
self.report = PopDownReport(self.iface.messageBar())
self.dialogprovider = DialogProvider(iface.mapCanvas(), iface)
self.dialogprovider.accepted.connect(self.clearToolRubberBand)
self.dialogprovider.rejected.connect(self.clearToolRubberBand)
self.edittool = EditTool(self.iface.mapCanvas(),[])
self.edittool.finished.connect(self.openForm)
self.edittool.featuresfound.connect(self.showFeatureSelection)
self.infodock = InfoDock(self.iface.mainWindow())
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.infodock)
self.infodock.hide()
self.band = QgsRubberBand(self.iface.mapCanvas())
self.band.setIconSize(20)
self.band.setWidth(10)
self.band.setColor(QColor(186, 93, 212, 76))
示例5: setupUi
def setupUi(self):
super(MainWindow, self).setupUi(self)
self.search_box.shortcut = QShortcut(self.search_box)
self.search_box.shortcut.setKey('Ctrl+F')
self.output_devices_group = QActionGroup(self)
self.input_devices_group = QActionGroup(self)
self.alert_devices_group = QActionGroup(self)
self.video_devices_group = QActionGroup(self)
self.request_screen_action = QAction('Request screen', self, triggered=self._AH_RequestScreenActionTriggered)
self.share_my_screen_action = QAction('Share my screen', self, triggered=self._AH_ShareMyScreenActionTriggered)
self.screen_sharing_button.addAction(self.request_screen_action)
self.screen_sharing_button.addAction(self.share_my_screen_action)
# adjust search box height depending on theme as the value set in designer isn't suited for all themes
search_box = self.search_box
option = QStyleOptionFrameV2()
search_box.initStyleOption(option)
frame_width = search_box.style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, search_box)
if frame_width < 4:
search_box.setMinimumHeight(20 + 2*frame_width)
# adjust the combo boxes for themes with too much padding (like the default theme on Ubuntu 10.04)
option = QStyleOptionComboBox()
self.identity.initStyleOption(option)
wide_padding = self.identity.style().subControlRect(QStyle.CC_ComboBox, option, QStyle.SC_ComboBoxEditField, self.identity).height() < 10
self.identity.setStyleSheet("""QComboBox { padding: 0px 4px 0px 4px; }""" if wide_padding else "")
示例6: _set_up_tools_connections
def _set_up_tools_connections(self):
""" Set up all connections for view menu. """
self.connect(self.actionUnselect_All, SIGNAL("triggered()"),
self.canvas.clear_all_selected_cells)
self.connect(self.actionCreate_Pattern_Repeat,
SIGNAL("triggered()"),
self.canvas.add_pattern_repeat)
self.connect(self.actionCreate_Row_Repeat,
SIGNAL("triggered()"),
self.canvas.add_row_repeat)
self.connect(self.actionApply_Color_to_Selection,
SIGNAL("triggered()"),
self.canvas.apply_color_to_selection)
self.connect(self.actionAdd_Text, SIGNAL("triggered()"),
self.canvas.add_text_item)
modeGroup = QActionGroup(self)
modeGroup.addAction(self.actionHide_Selected_Cells)
modeGroup.addAction(self.actionShow_Selected_Cells)
modeGroup.addAction(self.actionCreate_Chart)
self.connect(self.actionHide_Selected_Cells, SIGNAL("triggered()"),
partial(self.canvas.select_mode, canvas.HIDE_MODE))
self.connect(self.actionShow_Selected_Cells, SIGNAL("triggered()"),
partial(self.canvas.select_mode, canvas.UNHIDE_MODE))
self.connect(self.actionCreate_Chart, SIGNAL("triggered()"),
partial(self.canvas.select_mode, canvas.SELECTION_MODE))
示例7: 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))
示例8: create_menu
def create_menu(self, menu_name, menu_actions):
""" Creates a menu. Groups them so you can only select one at a time. """
menu_action_group = QActionGroup(self)
menu_action_group.setExclusive(True)
menubar = self.menuBar()
menu = menubar.addMenu(menu_name)
for action in menu_actions:
menu_action_group.addAction(action)
menu.addAction(action)
示例9: __init__
def __init__(self, snapLayer, parent=None):
super(LayerSnappingAction, self).__init__(snapLayer, parent)
self._toleranceAction = None # LayerSnappingToleranceAction()
self._avoidAction = None # LayerSnappingAvoidIntersectionsAction()
self._vertexAction = LayerSnappingTypeAction(snapLayer, Snapping.Vertex, self)
self._segmentAction = LayerSnappingTypeAction(snapLayer, Snapping.Segment, self)
self._vertexSegmentAction = LayerSnappingTypeAction(snapLayer, Snapping.VertexAndSegment, self)
self._snappingTypeActionGroup = QActionGroup(self)
self._snappingTypeActionGroup.addAction(self._vertexAction)
self._snappingTypeActionGroup.addAction(self._segmentAction)
self._snappingTypeActionGroup.addAction(self._vertexSegmentAction)
self._toleranceAction = LayerSnappingToleranceAction(snapLayer, parent)
self._pixelUnitsAction = LayerSnappingUnitAction(snapLayer, Snapping.Pixels, self)
self._layerUnitsAction = LayerSnappingUnitAction(snapLayer, Snapping.LayerUnits, self)
self._projectUnitsAction = LayerSnappingUnitAction(snapLayer, Snapping.ProjectUnits, self)
self._unitTypeActionGroup = QActionGroup(self)
self._unitTypeActionGroup.addAction(self._pixelUnitsAction)
self._unitTypeActionGroup.addAction(self._layerUnitsAction)
self._unitTypeActionGroup.addAction(self._projectUnitsAction)
menu = ControlMenu(parent)
menu.addActions(self._snappingTypeActionGroup.actions())
menu.addSeparator()
menu.addAction(self._toleranceAction)
menu.addActions(self._unitTypeActionGroup.actions())
if (isinstance(snapLayer, QgisInterface)
or (isinstance(snapLayer, QgsVectorLayer) and snapLayer.geometryType() == QGis.Polygon)):
self._avoidAction = LayerSnappingAvoidIntersectionsAction(snapLayer, self)
menu.addSeparator()
menu.addAction(self._avoidAction)
self.setMenu(menu)
self._refreshAction()
# Make sure we catch changes in the main snapping dialog
QgsProject.instance().snapSettingsChanged.connect(self._refreshAction)
# If using current layer, make sure we update when it changes
if self._iface:
self._iface.legendInterface().currentLayerChanged.connect(self._refreshAction)
# If any of the settings change then signal, but don't tell project as actions already have
self.snappingEnabledChanged.connect(self.snapSettingsChanged)
self._vertexAction.snappingTypeChanged.connect(self.snapSettingsChanged)
self._segmentAction.snappingTypeChanged.connect(self.snapSettingsChanged)
self._vertexSegmentAction.snappingTypeChanged.connect(self.snapSettingsChanged)
self._toleranceAction.snappingToleranceChanged.connect(self.snapSettingsChanged)
self._pixelUnitsAction.snappingUnitChanged.connect(self.snapSettingsChanged)
self._layerUnitsAction.snappingUnitChanged.connect(self.snapSettingsChanged)
self._projectUnitsAction.snappingUnitChanged.connect(self.snapSettingsChanged)
if self._avoidAction:
self._avoidAction.avoidIntersectionsChanged.connect(self.snapSettingsChanged)
示例10: add_stations
def add_stations(self):
self.stations = {}
group = QActionGroup(self)
group.setExclusive(True)
for name in sorted(self.parent.stations.map.keys()):
url = self.parent.stations.map[name]
self.stations[name] = QAction(str(name), self)
self.stations[name].setCheckable(True)
self.stations[name].setActionGroup(group)
self.stations[name].triggered.connect(
lambda _=0, st=(name, url):
self.parent.station_changed.emit(st))
self.stations_menu.addAction(self.stations[name])
示例11: createMenuBar
def createMenuBar(self):
# set menu bar model
self.mActionsModel = pActionsModel( self )
self.menuBar().setModel( self.mActionsModel )
# create menus and sub menus
self.mActionsModel.addMenu( "mFile", self.tr( "&File" ) )
self.mActionsModel.addMenu( "mEdit", self.tr( "&Edit" ) )
self.mActionsModel.addMenu( "mView", self.tr( "&View" ) )
self.mActionsModel.addMenu( "mView/mStyle", self.tr( "&Style" ) )
self.mActionsModel.addMenu( "mView/mMode", self.tr( "&Mode" ) )
self.mActionsModel.addMenu( "mView/mDockToolBarManager", self.tr( "&Dock ToolBar Manager" ) )
self.mActionsModel.addMenu( "mView/mDockWidgets", self.tr( "Dock &Widgets" ) )
# create actions
aQuit = self.mActionsModel.addAction( "mFile/aQuit", self.tr( "&Quit" ) )
aClassic = self.mActionsModel.addAction(
"mView/mMode/aShowClassic", self.tr( "Classic" ) )
aClassic.setCheckable( True )
aModern = self.mActionsModel.addAction(
"mView/mMode/aShowModern", self.tr( "Modern" ) )
aModern.setCheckable( True )
# style actions
self.agStyles = pStylesActionGroup( self )
self.agStyles.installInMenuBar( self.menuBar(), "mView/mStyle" )
# action group
agDockToolBarManagerMode = QActionGroup( self )
agDockToolBarManagerMode.addAction( aClassic )
agDockToolBarManagerMode.addAction( aModern )
# add dock toolbar manager actions
for dockToolBar in self.dockToolBarManager().dockToolBars():
action = dockToolBar.toggleViewAction()
self.mActionsModel.addAction(
"mView/mDockToolBarManager/%s" % action.objectName() , action )
action = dockToolBar.toggleExclusiveAction()
self.mActionsModel.addAction(
"mView/mDockToolBarManager/%s" % action.objectName(), action )
# connections
aQuit.triggered.connect(self.close)
self.agStyles.styleSelected.connect(self.setCurrentStyle)
self.dockToolBarManager().modeChanged.connect(
self.dockToolBarManagerModeChanged)
aClassic.triggered.connect(self.dockToolBarManagerClassic)
aModern.triggered.connect(self.dockToolBarManagerModern)
示例12: MainWindow
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self._create_actions()
self._create_toolbar()
self._canvas = Canvas()
self._canvas.scale(16, 16)
self.setCentralWidget(self._canvas)
def _create_actions(self):
self._delete_action = QAction("Delete", None)
self._delete_action.setShortcuts(QKeySequence.Delete)
self._delete_action.triggered.connect(self._delete)
self._select_action = QAction("Select", None)
self._select_action.setCheckable(True)
self._select_action.triggered.connect(self._use_select_tool)
self._pen_action = QAction("Pen", None)
self._pen_action.setCheckable(True)
self._pen_action.setChecked(True)
self._pen_action.triggered.connect(self._use_pen_tool)
self._new_shape_action = QAction("New Shape", None)
self._new_shape_action.triggered.connect(self._new_shape)
self._tool_group = QActionGroup(None)
self._tool_group.addAction(self._select_action)
self._tool_group.addAction(self._pen_action)
def _create_toolbar(self):
toolbar = self.addToolBar("Tools")
toolbar.addAction(self._delete_action)
toolbar.addAction(self._select_action)
toolbar.addAction(self._pen_action)
toolbar.addAction(self._new_shape_action)
def _use_select_tool(self):
self._canvas.use_tool(SelectTool)
def _use_pen_tool(self):
self._canvas.use_tool(PenTool)
def _new_shape(self):
self._canvas.new_shape()
def _delete(self):
self._canvas.delete_selection()
示例13: set_menu_items
def set_menu_items(self, db, tag, names):
"""Some of the menus change their content dynamically in runtime.
This method updates menu specified by 'tag' with the items
given in 'names'.
"""
menu, fb = self.dynamic_menus[tag]
group = QActionGroup(self, exclusive=True)
menu.clear()
for name in names:
action = QAction(name, self, checkable=True)
action.setStatusTip('Select item')
action.triggered.connect(partial(fb, self, db, name))
a = group.addAction(action)
menu.addAction(a)
if db.selection[tag] == name:
a.toggle()
示例14: initModeMenu
def initModeMenu(self):
self.modeGroup = QActionGroup(self)
self.modeGroup.setExclusive(True)
self.modeGroup.selected.connect(self.parent.setMode)
self.action_Squirrel = QAction(Icons.nut, 'Squ', self.modeGroup)
self.action_Squirrel.setCheckable(True)
self.action_Emo = QAction(Icons.emo, 'Emo', self.modeGroup)
self.action_Emo.setCheckable(True)
self.action_And = QAction(Icons.android, 'Android', self.modeGroup)
self.action_And.setCheckable(True)
self.action_Ios = QAction(Icons.ios, 'ios', self.modeGroup)
self.action_Ios.setCheckable(True)
self.modeGroup.addAction(self.action_Squirrel)
self.modeGroup.addAction(self.action_Emo)
self.modeGroup.addAction(self.action_And)
self.modeGroup.addAction(self.action_Ios)
self.addActions(self.modeGroup.actions())
if(config.mode() == 0):
self.action_Squirrel.setChecked(True)
self.action_Build.setEnabled(False)
self.action_Run.setEnabled(False)
elif(config.mode() == 1):
self.action_Emo.setChecked(True)
self.action_Build.setEnabled(True)
self.action_Run.setEnabled(True)
elif(config.mode() == 2):
self.action_And.setChecked(True)
self.action_Build.setEnabled(True)
self.action_Run.setEnabled(True)
elif(config.mode() == 3):
self.action_Ios.setChecked(True)
self.action_Build.setEnabled(False)
self.action_Run.setEnabled(False)
示例15: 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)