本文整理汇总了Python中PySide.QtGui.QAction.setShortcut方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.setShortcut方法的具体用法?Python QAction.setShortcut怎么用?Python QAction.setShortcut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QAction
的用法示例。
在下文中一共展示了QAction.setShortcut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateFileMenu
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def updateFileMenu(self):
"""
Updates the file menu dynamically, so that recent files can be shown.
"""
self.menuFile.clear()
# self.menuFile.addAction(self.actionNew) # disable for now
self.menuFile.addAction(self.actionOpen)
self.menuFile.addAction(self.actionSave)
self.menuFile.addAction(self.actionSave_as)
self.menuFile.addAction(self.actionClose_Model)
recentFiles = []
for filename in self.recentFiles:
if QFile.exists(filename):
recentFiles.append(filename)
if len(self.recentFiles) > 0:
self.menuFile.addSeparator()
for i, filename in enumerate(recentFiles):
action = QAction("&%d %s" % (i + 1, QFileInfo(filename).fileName()), self)
action.setData(filename)
action.setStatusTip("Opens recent file %s" % QFileInfo(filename).fileName())
action.setShortcut(QKeySequence(Qt.CTRL | (Qt.Key_1 + i)))
action.triggered.connect(self.load_model)
self.menuFile.addAction(action)
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionQuit)
示例2: __setupMenu
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def __setupMenu(self):
"""Defines basic top menu"""
quit_action = QAction("&Exit", self)
quit_action.setShortcut('Ctrl+Q')
quit_action.triggered.connect(self.close)
sign_out_action = QAction("Sign out", self)
sign_out_action.setShortcut('Ctrl+L')
sign_out_action.triggered.connect(lambda: (self.app.logOut(), self.hide(), self.requestCredentials()))
change_password_action = QAction("Change password", self)
change_password_action.triggered.connect(self.requestPasswordChange)
about_action = QAction("About", self)
about_action.triggered.connect(lambda: QMessageBox.about(self, "About", u'© ' + __author__ + ' 2013'))
self.file_menu = self.menuBar().addMenu("&File")
self.file_menu.addAction(quit_action)
self.account_menu = self.menuBar().addMenu("&Account")
self.account_menu.addAction(sign_out_action)
self.account_menu.addAction(change_password_action)
self.help_menu = self.menuBar().addMenu("&Help")
self.help_menu.addAction(about_action)
示例3: __init__
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def __init__(self,args,continuous):
self.continuous = continuous
gobject.GObject.__init__(self)
#start by making our app
self.app = QApplication(args)
#make a window
self.window = QMainWindow()
#give the window a name
self.window.setWindowTitle("BlatherQt")
self.window.setMaximumSize(400,200)
center = QWidget()
self.window.setCentralWidget(center)
layout = QVBoxLayout()
center.setLayout(layout)
#make a listen/stop button
self.lsbutton = QPushButton("Listen")
layout.addWidget(self.lsbutton)
#make a continuous button
self.ccheckbox = QCheckBox("Continuous Listen")
layout.addWidget(self.ccheckbox)
#connect the buttons
self.lsbutton.clicked.connect(self.lsbutton_clicked)
self.ccheckbox.clicked.connect(self.ccheckbox_clicked)
#add a label to the UI to display the last command
self.label = QLabel()
layout.addWidget(self.label)
#add the actions for quiting
quit_action = QAction(self.window)
quit_action.setShortcut('Ctrl+Q')
quit_action.triggered.connect(self.accel_quit)
self.window.addAction(quit_action)
示例4: setup_ui
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def setup_ui(self):
""" Setup the UI for the window.
"""
central_widget = QWidget()
layout = QVBoxLayout()
layout.addWidget(self.clock_view)
layout.addWidget(self.message_view)
central_widget.setLayout(layout)
self.setCentralWidget(central_widget)
menubar = self.menuBar()
file_menu = QMenu('File')
preferences_action = QAction('Preferences', file_menu)
preferences_action.triggered.connect(self.on_preferences_triggered)
quit_action = QAction('Quit', file_menu)
quit_action.triggered.connect(self.on_quit_triggered)
file_menu.addAction(preferences_action)
file_menu.addAction(quit_action)
menubar.addMenu(file_menu)
view_menu = QMenu('View')
fullscreen_action = QAction('Fullscreen', view_menu)
fullscreen_action.setCheckable(True)
fullscreen_action.setChecked(Config.get('FULLSCREEN', True))
fullscreen_action.setShortcut('Ctrl+Meta+F')
fullscreen_action.toggled.connect(self.on_fullscreen_changed)
view_menu.addAction(fullscreen_action)
menubar.addMenu(view_menu)
示例5: addExitButton
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def addExitButton(self):
""" Adds the Exit Button to the ToolBar """
exitAction = QAction(self.getQIcon('exit.png'), 'Exit the Application', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip("Exit the Application.")
exitAction.triggered.connect(QtCore.QCoreApplication.instance().quit)
self.addAction(exitAction)
示例6: testPythonStringAsQKeySequence
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def testPythonStringAsQKeySequence(self):
'''Passes a Python string to an argument expecting a QKeySequence.'''
keyseq = py3k.unicode_('Ctrl+A')
action = QAction(None)
action.setShortcut(keyseq)
shortcut = action.shortcut()
self.assert_(isinstance(shortcut, QKeySequence))
self.assertEqual(shortcut.toString(), keyseq)
示例7: addNewTransactionButton
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def addNewTransactionButton(self):
""" Adds the New Transaction Button to the ToolBar """
newIcon = self.getQIcon('money.png')
newTransactionAction = QAction(newIcon, 'New Transaction', self)
newTransactionAction.setShortcut('Ctrl+N')
newTransactionAction.setStatusTip("Create a New Transaction.")
newTransactionAction.triggered.connect(self.newTransaction)
self.addAction(newTransactionAction)
示例8: testSetShortcut
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def testSetShortcut(self):
# Somehow an exception was leaking from the constructor
# and appearing in setShortcut.
o = QWidget()
action = QAction('aaaa', o)
shortcut = 'Ctrl+N'
action.setShortcut(shortcut)
s2 = action.shortcut()
self.assertEqual(s2, shortcut)
示例9: ChatWindow
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
class ChatWindow(QMainWindow):
"""
The chat application window.
"""
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.chat_widget = ChatWidget(self)
self.setCentralWidget(self.chat_widget)
# set up all actions
self.chat_widget.message.connect(self.statusBar().showMessage)
app_menu = self.menuBar().addMenu('&Application')
self.connect_action = QAction('&Connect', self)
self.connect_action.triggered.connect(self._connect)
self.connect_action.setShortcut('Ctrl+C')
app_menu.addAction(self.connect_action)
app_menu.addSeparator()
self.quit_server_action = QAction('Quit &server', self)
self.quit_server_action.triggered.connect(self._quit_server)
self.quit_server_action.setEnabled(False)
self.quit_server_action.setShortcut('Ctrl+D')
app_menu.addAction(self.quit_server_action)
quit_action = QAction(self.style().standardIcon(
QStyle.SP_DialogCloseButton), '&Quit', self)
quit_action.triggered.connect(QApplication.instance().quit)
quit_action.setShortcut('Ctrl+Q')
app_menu.addAction(quit_action)
# attempt to connect
self._connect()
def _quit_server(self):
if self.chat_widget.connected:
self.chat_widget.send_text('quit')
def _connect(self):
# connect to a server
if not self.chat_widget.connected:
self.chat_widget.connection = QTcpSocket()
# upon connection, disable the connect action, and enable the
# quit server action
self.chat_widget.connection.connected.connect(
partial(self.quit_server_action.setEnabled, True))
self.chat_widget.connection.connected.connect(
partial(self.connect_action.setDisabled, True))
# to the reverse thing upon disconnection
self.chat_widget.connection.disconnected.connect(
partial(self.connect_action.setEnabled, True))
self.chat_widget.connection.disconnected.connect(
partial(self.quit_server_action.setDisabled, True))
# connect to the chat server
self.chat_widget.connection.connectToHost(HOST_ADDRESS, PORT)
示例10: _createAction
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def _createAction(self, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False, signal="triggered"):
action = QAction(text, self)
if icon is not None:
action.setIcon(QIcon(":/{0}.png".format(icon)))
if shortcut is not None:
action.setShortcut(shortcut)
if tip is not None:
action.setToolTip(tip)
action.setStatusTip(tip)
if slot is not None:
getattr(action, signal).connect(slot)
if checkable:
action.setCheckable(True)
return action
示例11: createactions
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def createactions(self, text, slot=None, shortcut="None", icon=None, tip=None, checkable=False,
signal="triggered()"):
action = QAction(text, self)
if icon is not None:
action.setIcon(QIcon(icon))
if shortcut is not None:
action.setShortcut(shortcut)
if tip is not None:
action.setToolTip(tip)
action.setStatusTip(tip)
if slot is not None:
self.connect(action, SIGNAL(signal), slot)
if checkable:
action.setCheckable(True)
return action
示例12: _createAction
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def _createAction(self, name, slot, shortcut=None, statusTip=None):
action = QAction(name, self)
action.triggered.connect(slot)
if shortcut is not None:
action.setShortcut(shortcut)
if statusTip is not None:
action.setStatusTip(statusTip)
key = _stripEllipsis(name)
self._actions[key] = action
return action
示例13: __init__
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def __init__(self, parent=None):
"""Create Qt widgets, connect event handlers."""
super(App, self).__init__(parent)
self.windowTitle = 'DMD | '
self.fileName = ''
self.setWindowTitle(self.windowTitle + 'Unsaved File')
exitAction = QAction('Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(self.close)
openAction = QAction('Open', self)
openAction.setShortcut('Ctrl+O')
openAction.setStatusTip('Open Markdown File')
openAction.triggered.connect(self.openFile)
newAction = QAction('New', self)
newAction.setShortcut('Ctrl+N')
newAction.setStatusTip('New Markdown File')
newAction.triggered.connect(self.newFile)
saveAction = QAction('Save', self)
saveAction.setShortcut('Ctrl+S')
saveAction.setStatusTip('Save File')
saveAction.triggered.connect(self.saveFile)
self.statusBar()
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(newAction)
fileMenu.addAction(openAction)
fileMenu.addAction(saveAction)
fileMenu.addAction(exitAction)
self.setGeometry(300, 300, 1024, 768)
self.show()
self.txtInput = QTextEdit()
self.txtInput.setTabStopWidth(20)
self.webPreview = QWebView()
self.webPreview.setHtml('Start typing...', baseUrl=QUrl('preview'))
self.txtInput.textChanged.connect(self.loadPreview)
splitter = QSplitter()
splitter.addWidget(self.txtInput)
splitter.addWidget(self.webPreview)
self.setCentralWidget(splitter)
示例14: __init__
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def __init__(self,fileName=None):
""" Constructor Function
"""
# QWidget.__init__(self)
# self.setWindowTitle("Icon Sample")
# self.setGeometry(300, 300, 200, 150)
QMainWindow.__init__(self)
self.setWindowTitle("Icon Sample")
self.setGeometry(300, 300, 200, 150)
QToolTip.setFont(QFont("Decorative", 8, QFont.Bold))
self.setToolTip('Our Main Window')
self.icon='C:\Users\Hamed\Documents\soheil sites image\imageedit__9411602959.gif'
self.textEdit = QTextEdit()
self.setCentralWidget(self.textEdit)
self.fileName = None
self.filters = "Text files (*.txt)"
openFile = QAction(QIcon('open.png'), 'Open', self)
openFile.setShortcut('Ctrl+O')
openFile.setStatusTip('Open new File')
openFile.triggered.connect(self.showDialog)
menubar = self.menuBar()
# fileMenu = menubar.addMenu('&File')
# fileMenu.addAction(openFile)
self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('Example - File Dialog')
# self.myNameLE = QLineEdit(self)
# self.myAgeLE = QLineEdit(self)
# self.myChoiceLE = QLineEdit(self)
self.statusLabel = QLabel('Showing Progress')
self.progressBar = QProgressBar()
self.progressBar.setMinimum(0)
self.progressBar.setMaximum(100)
##################@@@@@@@@@@@@@@2
self.threads = []
self.addWorker(MyWorkerThread(1))
self.addWorker(MyWorkerThread(2))
#######################@@@@@@@@@@@@@
self.show()
示例15: _parseactions
# 需要导入模块: from PySide.QtGui import QAction [as 别名]
# 或者: from PySide.QtGui.QAction import setShortcut [as 别名]
def _parseactions(self, actions):
actionlist = []
for act in actions:
atts = actions[act]
if act == "Separator":
newaction = "Separator"
else:
try:
newaction = QAction(QtGui.QIcon(atts["icon"]), atts["text"], self)
except:
newaction = QAction(atts["text"], self)
try:
newaction.setShortcut(atts["shortcut"])
except:
pass
try:
newaction.setStatusTip(atts["statustip"])
except:
pass
actionlist.append((atts["pos"], newaction, act))
actionlist = self._sortbyposition(actionlist)
return actionlist