本文整理汇总了Python中qtpy.QtWidgets.QApplication.focusWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.focusWidget方法的具体用法?Python QApplication.focusWidget怎么用?Python QApplication.focusWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.focusWidget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: data
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import focusWidget [as 别名]
def data(self, index, role=Qt.DisplayRole):
"""Qt Override."""
row = index.row()
if not index.isValid() or not (0 <= row < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[row]
key = shortcut.key
column = index.column()
if role == Qt.DisplayRole:
if column == CONTEXT:
return to_qvariant(shortcut.context)
elif column == NAME:
color = self.text_color
if self._parent == QApplication.focusWidget():
if self.current_index().row() == row:
color = self.text_color_highlight
else:
color = self.text_color
text = self.rich_text[row]
text = '<p style="color:{0}">{1}</p>'.format(color, text)
return to_qvariant(text)
elif column == SEQUENCE:
text = QKeySequence(key).toString(QKeySequence.NativeText)
return to_qvariant(text)
elif column == SEARCH_SCORE:
# Treating search scores as a table column simplifies the
# sorting once a score for a specific string in the finder
# has been defined. This column however should always remain
# hidden.
return to_qvariant(self.scores[row])
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant()
示例2: test_change_types_in_varexp
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import focusWidget [as 别名]
def test_change_types_in_varexp(main_window, qtbot):
"""Test that variable types can't be changed in the Variable Explorer."""
# Create object
shell = main_window.ipyconsole.get_current_shellwidget()
qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
with qtbot.waitSignal(shell.executed):
shell.execute('a = 10')
# Edit object
main_window.variableexplorer.visibility_changed(True)
nsb = main_window.variableexplorer.get_focus_widget()
qtbot.waitUntil(lambda: nsb.editor.model.rowCount() > 0, timeout=EVAL_TIMEOUT)
nsb.editor.setFocus()
nsb.editor.edit_item()
# Try to change types
qtbot.keyClicks(QApplication.focusWidget(), "'s'")
qtbot.keyClick(QApplication.focusWidget(), Qt.Key_Enter)
qtbot.wait(1000)
# Assert object remains the same
assert shell.get_value('a') == 10
示例3: findinfiles_callback
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import focusWidget [as 别名]
def findinfiles_callback(self):
"""Find in files callback"""
widget = QApplication.focusWidget()
if not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.raise_()
text = ''
try:
if widget.has_selected_text():
text = widget.get_selected_text()
except AttributeError:
# This is not a text widget deriving from TextEditBaseWidget
pass
self.findinfiles.set_search_text(text)
if text:
self.findinfiles.find()
示例4: view_set_parameter
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import focusWidget [as 别名]
def view_set_parameter(self, param_name, value):
view = self.widget.view()
rect = view.getVisualRectParameterProperty(param_name)
pos = rect.center()
if self.is_multi:
pos -= QPoint(rect.width() / 5, 0)
else:
pos += QPoint(rect.width() / 4, 0)
tree = view.treeWidget().viewport()
QTest.mouseMove(tree, pos)
yield
QTest.mouseClick(tree, Qt.LeftButton, Qt.NoModifier, pos)
yield
editor = QApplication.focusWidget()
QTest.keyClicks(editor, str(value))
QTest.keyClick(editor, Qt.Key_Return)