本文整理汇总了Python中PyQt5.QtWidgets.QAction类的典型用法代码示例。如果您正苦于以下问题:Python QAction类的具体用法?Python QAction怎么用?Python QAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None):
super().__init__(parent)
self.zoom_in_action = QAction(self.tr("Zoom in"), self)
self.zoom_in_action.setShortcut(QKeySequence.ZoomIn)
self.zoom_in_action.triggered.connect(self.on_zoom_in_action_triggered)
self.zoom_in_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
self.zoom_in_action.setIcon(QIcon.fromTheme("zoom-in"))
self.addAction(self.zoom_in_action)
self.zoom_out_action = QAction(self.tr("Zoom out"), self)
self.zoom_out_action.setShortcut(QKeySequence.ZoomOut)
self.zoom_out_action.triggered.connect(self.on_zoom_out_action_triggered)
self.zoom_out_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
self.zoom_out_action.setIcon(QIcon.fromTheme("zoom-out"))
self.addAction(self.zoom_out_action)
self.redraw_timer = QTimer()
self.redraw_timer.setSingleShot(True)
self.redraw_timer.timeout.connect(self.redraw_view)
self.zoomed.connect(self.on_signal_zoomed)
self.scene_y_min = float("nan") # NaN = AutoDetect
self.scene_y_max = float("nan") # NaN = AutoDetect
self.scene_x_zoom_stretch = 1
示例2: MediaInfo
class MediaInfo(Plugin):
Name = 'MediaInfo'
def __init__(self):
self.app = Application()
self.actionMediaInfo = QAction(None, triggered=self.showInfo)
self.actionMediaInfo.setText("Media Info")
self.separator = self.app.layout.add_context_separator(MediaCue)
self.app.layout.add_context_item(self.actionMediaInfo, MediaCue)
def reset(self):
self.app.layout.remove_context_item(self.actionMediaInfo)
self.app.layout.remove_context_item(self.separator)
def showInfo(self, clicked):
media_uri = self.app.layout.get_context_cue().media.input_uri()
if not media_uri:
QMessageBox.critical(None, 'Error Message', 'Invalid Media!')
else:
gst_info = uri_metadata(media_uri)
info = {"Uri": unquote(gst_info.get_uri())}
# Audio streams info
for stream in gst_info.get_audio_streams():
name = stream.get_stream_type_nick().capitalize()
info[name] = {"Bitrate": str(stream.get_bitrate() // 1000) +
" Kb/s",
"Channels": str(stream.get_channels()),
"Sample rate": str(stream.get_sample_rate()) +
" Hz",
"Sample size": str(stream.get_depth()) + " bit"
}
# Video streams info
for stream in gst_info.get_video_streams():
name = stream.get_stream_type_nick().capitalize()
framerate = round(stream.get_framerate_num() /
stream.get_framerate_denom())
info[name] = {"Height": str(stream.get_height()) + " px",
"Width": str(stream.get_width()) + " px",
"Framerate": str(framerate)
}
# Media tags
info["Tags"] = {}
tags = parse_gst_tag_list(gst_info.get_tags())
for tag_name in tags:
if(not str(tags[tag_name]).startswith("<Gst")):
info["Tags"][tag_name.capitalize()] = str(tags[tag_name])
if len(info["Tags"]) == 0:
info.pop("Tags")
# Show the dialog
dialog = InfoDialog(self.app.mainWindow, info,
self.app.layout.get_context_cue()['name'])
dialog.exec_()
示例3: initUI
def initUI(self):
# 状态栏
self.statusBar().showMessage('Ready') # 状态栏是用来显示状态信息的组件
# 创建一个抽象动作行为,用于菜单栏、工具栏或自定义快捷键
exitAction = QAction(QIcon('exit.png'),'&Exit',self) # 设置图标、文本
exitAction.setShortcut('Ctrl+Q') # 设置快捷键
exitAction.setStatusTip('Exit application') # 在状态栏显示提示内容
exitAction.triggered.connect(qApp.quit) # 选中后中断应用
# 菜单栏
menubar = self.menuBar() # 创建菜单栏
fileMenu = menubar.addMenu('&File') # 创建File菜单
fileMenu.addAction(exitAction) # 增加退出动作为菜单项
# 工具栏
self.toolbar = self.addToolBar('Exit') # 创建工具栏
self.toolbar.addAction(exitAction) # 增加退出动作为工具项
# 中心组件,文本框
textEdit = QTextEdit() # 创建文本框
self.setCentralWidget(textEdit) # 设置文本框为中心组件,自动占据所有剩下的空间
# 其他设置
self.setGeometry(300,300,500,400) # 位置、尺寸
self.setWindowTitle('Menu Toolbar and Statusbar') # 标题
self.show()
示例4: __init__
def __init__(self, device_class, ipcon, device_info, override_base_name=None):
super().__init__(device_class, ipcon, device_info, override_base_name)
self.start_called = False
self.has_comcu = True
self.cbe_bootloader_mode = CallbackEmulator(self.device.get_bootloader_mode,
None,
self.cb_bootloader_mode,
self.increase_error_count)
self.status_led_off_action = QAction('Off', self)
self.status_led_off_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_OFF))
self.status_led_on_action = QAction('On', self)
self.status_led_on_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_ON))
self.status_led_show_heartbeat_action = QAction('Show Heartbeat', self)
self.status_led_show_heartbeat_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_SHOW_HEARTBEAT))
self.status_led_show_status_action = QAction('Show Status', self)
self.status_led_show_status_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_SHOW_STATUS))
self.extra_configs = [(0, 'Status LED:', [self.status_led_off_action,
self.status_led_on_action,
self.status_led_show_heartbeat_action,
self.status_led_show_status_action])]
self.reset_action = QAction('Reset', self)
self.reset_action.triggered.connect(self.remove_and_reset)
self.extra_actions = [(0, None, [self.reset_action])]
示例5: createActions
def createActions(self, parent):
self.import_any = QAction(parent)
self.import_musicxml = QAction(parent)
self.import_midi = QAction(parent)
self.import_abc = QAction(parent)
self.import_any.setIcon(icons.get("document-import"))
示例6: createActions
def createActions(self):
# action for add new
#root = QFileInfo(__file__).absoluteFilePath()
self.newAction = QAction(QIcon('icons'+ os.sep + 'appbar.page.add.png'),"&New",self)
self.newAction.setShortcut('Ctrl+N')
self.newAction.setStatusTip("Add new student detail")
self.newAction.triggered.connect(self.newEvent)
# action for update
self.updateAction = QAction(QIcon('icons'+ os.sep + 'appbar.page.edit.png'),"&Modify",self)
self.updateAction.setShortcut('Ctrl+M')
self.updateAction.setStatusTip("Modify student detail")
self.updateAction.triggered.connect(self.modifyEvent)
# action for delete
self.deleteAction = QAction(QIcon('icons'+ os.sep + 'appbar.delete.png'),"&Delete",self)
self.deleteAction.setShortcut('Ctrl+D')
self.deleteAction.setStatusTip("Delete student detail")
self.deleteAction.triggered.connect(self.deleteEvent)
# action for export
self.exportAction = QAction(QIcon('icons'+ os.sep + 'appbar.export.png'),"&Export",self)
self.exportAction.setShortcut('Ctrl+E')
self.exportAction.setStatusTip("Export to CSV")
self.exportAction.triggered.connect(self.exportEvent)
#action for exit
self.exitAction = QAction('&Exit', self)
self.exitAction.setShortcut('Ctrl+Q')
self.exitAction.setStatusTip('Exit application')
self.exitAction.triggered.connect(qApp.quit)
示例7: initUI
def initUI(self):
self.setCentralWidget(QuizWidget(self))
settings_action = QAction(QIcon(""), "Settings", self)
settings_action.setShortcut("Ctrl+S")
settings_action.setStatusTip("Settings")
settings_action.triggered.connect(self.showSettingsDialog)
# Load all the questions with all possible forms, tenses and polarities
# so we have a question to ask at startup.
settingsDialog = SettingsDialog()
initial_quiz_data = settingsDialog.getQuizData()
self.centralWidget().updateQuizData(initial_quiz_data)
exit_action = QAction(QIcon(""), "Exit", self)
exit_action.setShortcut("Ctrl+Q")
exit_action.setStatusTip("Exit Application")
exit_action.triggered.connect(qApp.exit)
menu_bar = self.menuBar()
menu_bar.setNativeMenuBar(False)
file_menu = menu_bar.addMenu("&File")
file_menu.addAction(settings_action)
file_menu.addAction(exit_action)
self.setGeometry(300, 300, 600, -1)
self.setWindowTitle("Japanese Flash Cards")
self.show()
示例8: view_menu
def view_menu(self):
"""Add a view menu to the menu bar.
The view menu houses the Playlist, Media Library, Minimalist View, and Media
Information menu items. The Playlist item toggles the playlist dock into and
out of view. The Media Library items toggles the media library dock into and
out of view. The Minimalist View item resizes the window and shows only the
menu bar and player controls. The Media Information item opens a dialog that
shows information relevant to the currently playing song.
"""
self.dock_action = self.playlist_dock.toggleViewAction()
self.dock_action.setShortcut('CTRL+ALT+P')
self.library_dock_action = self.library_dock.toggleViewAction()
self.library_dock_action.setShortcut('CTRL+ALT+L')
self.minimalist_view_action = QAction('Minimalist View', self)
self.minimalist_view_action.setShortcut('CTRL+ALT+M')
self.minimalist_view_action.setCheckable(True)
self.minimalist_view_action.triggered.connect(self.minimalist_view)
self.view_media_info_action = QAction('Media Information', self)
self.view_media_info_action.setShortcut('CTRL+SHIFT+M')
self.view_media_info_action.triggered.connect(self.media_information_dialog)
self.view.addAction(self.dock_action)
self.view.addAction(self.library_dock_action)
self.view.addSeparator()
self.view.addAction(self.minimalist_view_action)
self.view.addSeparator()
self.view.addAction(self.view_media_info_action)
示例9: 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)
示例10: media_controls
def media_controls(self):
"""Create the bottom toolbar and controls used for media playback."""
self.addToolBar(Qt.BottomToolBarArea, self.toolbar)
self.toolbar.setMovable(False)
play_icon = utilities.resource_filename('mosaic.images', 'md_play.png')
self.play_action = QAction(QIcon(play_icon), 'Play', self)
self.play_action.triggered.connect(self.player.play)
stop_icon = utilities.resource_filename('mosaic.images', 'md_stop.png')
self.stop_action = QAction(QIcon(stop_icon), 'Stop', self)
self.stop_action.triggered.connect(self.player.stop)
previous_icon = utilities.resource_filename('mosaic.images', 'md_previous.png')
self.previous_action = QAction(QIcon(previous_icon), 'Previous', self)
self.previous_action.triggered.connect(self.previous)
next_icon = utilities.resource_filename('mosaic.images', 'md_next.png')
self.next_action = QAction(QIcon(next_icon), 'Next', self)
self.next_action.triggered.connect(self.playlist.next)
repeat_icon = utilities.resource_filename('mosaic.images', 'md_repeat_none.png')
self.repeat_action = QAction(QIcon(repeat_icon), 'Repeat', self)
self.repeat_action.setShortcut('R')
self.repeat_action.triggered.connect(self.repeat_song)
self.toolbar.addAction(self.play_action)
self.toolbar.addAction(self.stop_action)
self.toolbar.addAction(self.previous_action)
self.toolbar.addAction(self.next_action)
self.toolbar.addAction(self.repeat_action)
self.toolbar.addWidget(self.slider)
self.toolbar.addWidget(self.duration_label)
示例11: playback_menu
def playback_menu(self):
"""Add a playback menu to the menu bar.
The playback menu houses
"""
self.play_playback_action = QAction('Play', self)
self.play_playback_action.setShortcut('P')
self.play_playback_action.triggered.connect(self.player.play)
self.stop_playback_action = QAction('Stop', self)
self.stop_playback_action.setShortcut('S')
self.stop_playback_action.triggered.connect(self.player.stop)
self.previous_playback_action = QAction('Previous', self)
self.previous_playback_action.setShortcut('B')
self.previous_playback_action.triggered.connect(self.previous)
self.next_playback_action = QAction('Next', self)
self.next_playback_action.setShortcut('N')
self.next_playback_action.triggered.connect(self.playlist.next)
self.playback.addAction(self.play_playback_action)
self.playback.addAction(self.stop_playback_action)
self.playback.addAction(self.previous_playback_action)
self.playback.addAction(self.next_playback_action)
示例12: __init__
def __init__(self, action: QtWidgets.QAction):
super().__init__()
button = QtWidgets.QPushButton(action.icon(), action.text())
button.clicked.connect(action.trigger)
layout = QtWidgets.QHBoxLayout(self)
layout.addWidget(button)
示例13: initUI
def initUI(self):
textEdit = QTextEdit()
self.setCentralWidget(textEdit)
lbl1 = QLabel('PyQt5', self)
lbl1.move(15,10)
lbl2 = QLabel('tutorial',self)
lbl2.move(35, 40)
lbl3 = QLabel('for Programmers', self)
lbl3.move(55, 70)
exitAction = QAction(QIcon('20070420141711640.png'), '&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(qApp.quit)
self.exittoolbar = self.addToolBar('FileExit')
self.exittoolbar.addAction(exitAction)
self.editbar = self.addToolBar('Edit')
# self.editbar.addAction(exitAction)
self.statusBar().showMessage('Ready')
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAction)
self.setGeometry(300, 300, 350, 250)
self.setWindowTitle('Menubar')
self.show()
示例14: createActions
def createActions(self):
self.openAct = QAction("&Open...", self, shortcut="Ctrl+O",
triggered=self.open)
self.printAct = QAction("&Print...", self, shortcut="Ctrl+P",
enabled=False, triggered=self.print_)
self.exitAct = QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
self.zoomInAct = QAction("Zoom &In (25%)", self, shortcut="Ctrl++",
enabled=False, triggered=self.zoomIn)
self.zoomOutAct = QAction("Zoom &Out (25%)", self, shortcut="Ctrl+-",
enabled=False, triggered=self.zoomOut)
self.normalSizeAct = QAction("&Normal Size", self, shortcut="Ctrl+S",
enabled=False, triggered=self.normalSize)
self.fitToWindowAct = QAction("&Fit to Window", self, enabled=False,
checkable=True, shortcut="Ctrl+F", triggered=self.fitToWindow)
self.aboutAct = QAction("&About", self, triggered=self.about)
self.aboutQtAct = QAction("About &Qt", self,
triggered=QApplication.instance().aboutQt)
示例15: __init__
def __init__ (self, parent):
super().__init__(parent)
self.search = SearchWidget(self)
self.search.searched.connect(self.populatelist)
self.nodelist = QListWidget(self)
self.nodelist.setSortingEnabled(True)
self.nodelist.setIconSize(QSize(*(FlGlob.mainwindow.style.boldheight,)*2))
self.nodelist.currentItemChanged.connect(self.selectnode)
self.nodelist.itemSelectionChanged.connect(self.onselectionchange)
self.nodelist.itemActivated.connect(self.activatenode)
self.nodelist.setSelectionMode(QAbstractItemView.ExtendedSelection)
remwidget = QToolBar(self)
remselected = QAction("Remove Selected", self)
remselected.setIcon(QIcon.fromTheme("edit-delete"))
remselected.setToolTip("Remove selected")
remselected.triggered.connect(self.remselected)
self.remselaction = remselected
remtrash = QAction("Remove Trash", self)
remtrash.setIcon(QIcon.fromTheme("edit-clear"))
remtrash.setToolTip("Clear all trash")
remtrash.triggered.connect(self.remtrash)
self.remtrashaction = remtrash
remwidget.addAction(remselected)
remwidget.addAction(remtrash)
layout = QVBoxLayout(self)
layout.addWidget(self.search)
layout.addWidget(self.nodelist)
layout.addWidget(remwidget)
self.view = None
self.active = False
self.setEnabled(False)