本文整理汇总了Python中python_qt_binding.QtGui.QApplication.keyboardModifiers方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.keyboardModifiers方法的具体用法?Python QApplication.keyboardModifiers怎么用?Python QApplication.keyboardModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QApplication
的用法示例。
在下文中一共展示了QApplication.keyboardModifiers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: expandItem
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import keyboardModifiers [as 别名]
def expandItem(self, path_item, path, item_id):
'''
Returns for the given item and path the file path if this is a file. Otherwise the
folder will be expanded and None will be returned.
@param path_item: the list item
@type path_item: C{str}
@param path: the real path of the item
@type path: C{str}
@return: path of the launch file or None
@rtype: C{str}
@raise Exception if no path to given item was found
'''
if path_item == '..':
goto_path = os.path.dirname(path)
key_mod = QApplication.keyboardModifiers()
if key_mod & Qt.ControlModifier:
goto_path = None
root_path, items = self._moveUp(goto_path)
elif os.path.isfile(path):
return path
elif item_id == LaunchItem.RECENT_FILE or item_id == LaunchItem.LAUNCH_FILE:
raise Exception("Invalid file path: %s", path)
else:
key_mod = QApplication.keyboardModifiers()
onestep = False
if key_mod & Qt.ControlModifier:
onestep = True
root_path, items = self._moveDown(path, onestep)
self._setNewList((root_path, items))
return None
示例2: on_launch_selection_activated
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import keyboardModifiers [as 别名]
def on_launch_selection_activated(self, activated):
'''
Tries to load the launch file, if one was activated.
'''
selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
for item in selected:
try:
lfile = self.launchlist_model.expandItem(item.name, item.path, item.id)
self.searchPackageLine.setText('')
if lfile is not None:
if item.isLaunchFile():
nm.settings().launch_history_add(item.path)
key_mod = QApplication.keyboardModifiers()
if key_mod & Qt.ShiftModifier:
self.load_as_default_signal.emit(item.path, None)
elif key_mod & Qt.ControlModifier:
self.launchlist_model.setPath(os.path.dirname(item.path))
else:
self.load_signal.emit(item.path, [], None)
elif item.isProfileFile():
nm.settings().launch_history_add(item.path)
key_mod = QApplication.keyboardModifiers()
if key_mod & Qt.ControlModifier:
self.launchlist_model.setPath(os.path.dirname(item.path))
else:
self.load_profile_signal.emit(item.path)
elif item.isConfigFile():
self.edit_signal.emit([lfile])
except Exception as e:
rospy.logwarn("Error while load launch file %s: %s" % (item, utf8(e)))
MessageBox.warning(self, "Load error",
'Error while load launch file:\n%s' % item.name,
"%s" % utf8(e))
示例3: keyPressEvent
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import keyboardModifiers [as 别名]
def keyPressEvent(self, event):
'''
Defines some of shortcuts for navigation/management in launch
list view or topics view.
'''
key_mod = QApplication.keyboardModifiers()
if not self.xmlFileView.state() == QAbstractItemView.EditingState:
# remove history file from list by pressing DEL
if event == QKeySequence.Delete:
selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
for item in selected:
nm.settings().launch_history_remove(item.path)
self.launchlist_model.reloadCurrentPath()
elif not key_mod and event.key() == Qt.Key_F4 and self.editXmlButton.isEnabled():
# open selected launch file in xml editor by F4
self.on_edit_xml_clicked()
elif event == QKeySequence.Find:
# set focus to filter box for packages
self.searchPackageLine.setFocus(Qt.ActiveWindowFocusReason)
elif event == QKeySequence.Paste:
# paste files from clipboard
self.launchlist_model.paste_from_clipboard()
elif event == QKeySequence.Copy:
# copy the selected items as file paths into clipboard
selected = self.xmlFileView.selectionModel().selectedIndexes()
indexes = []
for s in selected:
indexes.append(self.launchlist_proxyModel.mapToSource(s))
self.launchlist_model.copy_to_clipboard(indexes)
if self.searchPackageLine.hasFocus() and event.key() == Qt.Key_Escape:
# cancel package filtering on pressing ESC
self.launchlist_model.show_packages(False)
self.searchPackageLine.setText('')
self.xmlFileView.setFocus(Qt.ActiveWindowFocusReason)
QDockWidget.keyReleaseEvent(self, event)
示例4: on_load_as_default
# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import keyboardModifiers [as 别名]
def on_load_as_default(self):
'''
Tries to load the selected launch file as default configuration. The button
is only enabled and this method is called, if the button was enabled by
on_launch_selection_clicked()
'''
key_mod = QApplication.keyboardModifiers()
if (key_mod & Qt.ShiftModifier):
self.loadXmlAsDefaultButton.showMenu()
else:
selected = self._launchItemsFromIndexes(self.xmlFileView.selectionModel().selectedIndexes(), False)
for item in selected:
path = self.launchlist_model.expandItem(item.name, item.path, item.id)
if path is not None:
rospy.loginfo("LOAD the launch file as default: %s", path)
self.launchlist_model.add2LoadHistory(path)
self.load_as_default_signal.emit(path, None)