本文整理汇总了Python中PySide2.QtGui.QKeySequence方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QKeySequence方法的具体用法?Python QtGui.QKeySequence怎么用?Python QtGui.QKeySequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide2.QtGui
的用法示例。
在下文中一共展示了QtGui.QKeySequence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def __init__(self, widget):
QMainWindow.__init__(self)
#self.setWindowFlags(QtCore.Qt.CustomizeWindowHint)
self.setWindowTitle("TileGAN")
app_icon = QtGui.QIcon()
app_icon.addFile(iconFolder + '/icon_tilegan_16x16.png', QtCore.QSize(16, 16))
app_icon.addFile(iconFolder + '/icon_tilegan_24x24.png', QtCore.QSize(24, 24))
app_icon.addFile(iconFolder + '/icon_tilegan_32x32.png', QtCore.QSize(32, 32))
app_icon.addFile(iconFolder + '/icon_tilegan_48x48.png', QtCore.QSize(48, 48))
app_icon.addFile(iconFolder + '/icon_tilegan_64x64.png', QtCore.QSize(64, 64))
self.setWindowIcon(app_icon)
## Exit Action
exit_action = QAction("Exit", self)
exit_action.setShortcut(QtGui.QKeySequence("Ctrl+Q"))#)
exit_action.triggered.connect(self.exit_app)
# Window dimensions
self.setCentralWidget(widget)
geometry = app.desktop().availableGeometry(self)
self.resize(int(geometry.height() * 0.85), int(geometry.height() * 0.75))
示例2: addShortcut
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def addShortcut(self, shortcut, slotMethod, *args):
"""Add a shortcut to a slot (event handler)
Args:
shortcut (STRING): Something like 'ALT+m'
slotMethod (STRING): Method of GuiSlots 'Slot' class
Returns:
object: QShortcut object
"""
# guislot converts to:
# self.parent.slots.slotMethod()
guislot = getattr(self.parent.slots, slotMethod)
sc = QtWidgets.QShortcut(QtGui.QKeySequence(shortcut), self.parent)
# connect shortcut to self.parent.slots(*args)
sc.activated.connect(lambda: guislot(*args))
return
示例3: qui_menu
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def qui_menu(self, action_list_str, menu_str):
# qui menu creation
# syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
if menu_str not in self.uiList.keys():
self.uiList[menu_str] = QtWidgets.QMenu()
create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
for each_creation in create_opt_list:
ui_info = [ x.strip() for x in each_creation.split(';') ]
atn_name = ui_info[0]
atn_title = ''
atn_hotkey = ''
if len(ui_info) > 1:
options = ui_info[1].split(',')
atn_title = '' if len(options) < 1 else options[0]
atn_hotkey = '' if len(options) < 2 else options[1]
if atn_name != '':
if atn_name == '_':
self.uiList[menu_str].addSeparator()
else:
if atn_name not in self.uiList.keys():
self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
if atn_hotkey != '':
self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
self.uiList[menu_str].addAction(self.uiList[atn_name])
示例4: setupMenu
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def setupMenu(self):
self.quickMenu(['file_menu;&File','setting_menu;&Setting','help_menu;&Help'])
cur_menu = self.uiList['setting_menu']
self.quickMenuAction('setParaA_atn','Set Parameter &A','A example of tip notice.','setParaA.png', cur_menu)
self.uiList['setParaA_atn'].setShortcut(QtGui.QKeySequence("Ctrl+R"))
cur_menu.addSeparator()
# for file menu
cur_menu = self.uiList['file_menu']
self.quickMenuAction('newLang_atn','&Add New Language','Add a new translation.','newLang.png', cur_menu)
self.quickMenuAction('resetLang_atn','&Reset Languages','Reset All.','resetLang.png', cur_menu)
# for info review
cur_menu = self.uiList['help_menu']
self.quickMenuAction('helpHostMode_atnNone','Host Mode - {}'.format(hostMode),'Host Running.','', cur_menu)
self.quickMenuAction('helpPyMode_atnNone','Python Mode - {}'.format(pyMode),'Python Library Running.','', cur_menu)
self.quickMenuAction('helpQtMode_atnNone','Qt Mode - {}'.format(qtModeList[qtMode]),'Qt Library Running.','', cur_menu)
self.quickMenuAction('helpTemplate_atnNone','Universal Tool Teamplate - {}'.format(tpl_ver),'based on Univeral Tool Template v{} by Shining Ying - https://github.com/shiningdesign/universal_tool_template.py'.format(tpl_ver),'', cur_menu)
cur_menu.addSeparator()
self.uiList['helpGuide_msg'] = "How to Use:\n1. Put source info in\n2. Click Process button\n3. Check result output\n4. Save memory info into a file."
self.quickMenuAction('helpGuide_atnMsg','Usage Guide','How to Usge Guide.','helpGuide.png', cur_menu)
示例5: setupMenu
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def setupMenu(self):
self.quickMenu(['file_menu;&File','setting_menu;&Setting','help_menu;&Help'])
cur_menu = self.uiList['setting_menu']
self.quickMenuAction('setParaA_atn','Set Parameter &A','A example of tip notice.','setParaA.png', cur_menu)
self.uiList['setParaA_atn'].setShortcut(QtGui.QKeySequence("Ctrl+R"))
cur_menu.addSeparator()
if 'help_menu' in self.uiList.keys():
# for info review
cur_menu = self.uiList['help_menu']
self.quickMenuAction('helpHostMode_atnNone','Host Mode - {}'.format(hostMode),'Host Running.','', cur_menu)
self.quickMenuAction('helpPyMode_atnNone','Python Mode - {}'.format(pyMode),'Python Library Running.','', cur_menu)
self.quickMenuAction('helpQtMode_atnNone','Qt Mode - {}'.format(qtModeList[qtMode]),'Qt Library Running.','', cur_menu)
self.quickMenuAction('helpTemplate_atnNone','Universal Tool Teamplate - {}'.format(tpl_ver),'based on Univeral Tool Template v{0} by Shining Ying - https://github.com/shiningdesign/universal{1}tool{1}template.py'.format(tpl_ver,'_'),'', cur_menu)
cur_menu.addSeparator()
self.uiList['helpGuide_msg'] = self.help
self.quickMenuAction('helpGuide_atnMsg','Usage Guide','How to Usge Guide.','helpGuide.png', cur_menu)
示例6: qui_menu
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def qui_menu(self, action_list_str, menu_str):
# qui menu creation
# syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
if menu_str not in self.uiList.keys():
self.uiList[menu_str] = QtWidgets.QMenu()
create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
for each_creation in create_opt_list:
ui_info = [ x.strip() for x in each_creation.split(';') ]
atn_name = ui_info[0]
atn_title = ''
atn_hotkey = ''
if len(ui_info) > 1:
options = ui_info[1].split(',')
atn_title = '' if len(options) < 1 else options[0]
atn_hotkey = '' if len(options) < 2 else options[1]
if atn_name != '':
if atn_name not in self.uiList.keys():
self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
if atn_hotkey != '':
self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
self.uiList[menu_str].addAction(self.uiList[atn_name])
示例7: _init_shortcuts
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def _init_shortcuts(self):
"""
Initialize shortcuts
:return: None
"""
center_dockable_views = self.workspace.view_manager.get_center_views()
for i in range(1, len(center_dockable_views)+1):
QShortcut(QKeySequence('Ctrl+'+str(i)), self, center_dockable_views[i-1].raise_)
# Raise the DisassemblyView after everything has initialized
center_dockable_views[0].raise_()
#
# Plugins
#
示例8: set_shortcut
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def set_shortcut(keysequence, parent, method):
shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(keysequence), parent)
shortcut.activated.connect(method)
示例9: keyPressEvent
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def keyPressEvent(self, event):
self.setText(QtGui.QKeySequence(event.key()).toString().lower())
self.textEdited.emit(self.text())
示例10: __init__
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def __init__(self, options: Dict[str, object], parent: QWidget = None, maxTabCount = 250):
super().__init__(parent)
self.maxTabCount = maxTabCount
self.setTabsClosable(True)
self.tabCloseRequested.connect(self.onTabCloseRequest)
self.log = logging.getLogger(LOGGER_NAMES.PLAYER)
self.options = options
self.closeTabShortcut = QShortcut(QKeySequence("Ctrl+W"), self, self.onCtrlW)
示例11: qui_atn
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def qui_atn(self, ui_name, title, tip=None, icon=None, parent=None, key=None):
self.uiList[ui_name] = QtWidgets.QAction(title, self)
if icon!=None:
self.uiList[ui_name].setIcon(QtGui.QIcon(icon))
if tip !=None:
self.uiList[ui_name].setStatusTip(tip)
if key != None:
self.uiList[ui_name].setShortcut(QtGui.QKeySequence(key))
if parent !=None:
if isinstance(parent, (str, unicode)) and parent in self.uiList.keys():
self.uiList[parent].addAction(self.uiList[ui_name])
elif isinstance(parent, QtWidgets.QMenu):
parent.addAction(self.uiList[ui_name])
return ui_name
示例12: qui_key
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def qui_key(self, key_name, key_combo, func):
self.hotkey[key_name] = QtWidgets.QShortcut(QtGui.QKeySequence(key_combo), self)
self.hotkey[key_name].activated.connect( func )
示例13: Establish_Connections
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def Establish_Connections(self):
super(self.__class__,self).Establish_Connections()
# custom ui response
# shortcut connection
self.hotkey = {}
# self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
# self.hotkey['my_key'].activated.connect(self.my_key_func)
# ---- user response list ----
示例14: setupMenu
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def setupMenu(self):
self.quickMenu('file_menu;&File | setting_menu;&Setting | help_menu;&Help')
cur_menu = self.uiList['setting_menu']
for info in ['export', 'import','user']:
title = info.title()
self.quickMenuAction('{0}Config_atn'.format(info),'{0} Config (&{1})'.format(title,title[0]),'{0} Setting and Configuration.'.format(title),'{0}Config.png'.format(info), cur_menu)
self.uiList['{0}Config_atn'.format(info)].setShortcut(QtGui.QKeySequence("Ctrl+{0}".format(title[0])))
cur_menu.addSeparator()
super(self.__class__,self).setupMenu()
示例15: Establish_Connections
# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QKeySequence [as 别名]
def Establish_Connections(self):
super(self.__class__,self).Establish_Connections()
# custom ui response
# shortcut connection
self.hotkey = {}
# self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
# self.hotkey['my_key'].activated.connect(self.my_key_func)