本文整理汇总了Python中spyderlib.qt.QtCore.QTimer.setSingleShot方法的典型用法代码示例。如果您正苦于以下问题:Python QTimer.setSingleShot方法的具体用法?Python QTimer.setSingleShot怎么用?Python QTimer.setSingleShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtCore.QTimer
的用法示例。
在下文中一共展示了QTimer.setSingleShot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FindReplace
# 需要导入模块: from spyderlib.qt.QtCore import QTimer [as 别名]
# 或者: from spyderlib.qt.QtCore.QTimer import setSingleShot [as 别名]
#.........这里部分代码省略.........
# Replace layout
replace_with = QLabel(_("Replace with:"))
self.replace_text = PatternComboBox(self, adjust_to_minimum=False,
tip=_('Replace string'))
self.replace_button = create_toolbutton(self,
text=_('Replace/find'),
icon=ima.icon('DialogApplyButton'),
triggered=self.replace_find,
text_beside_icon=True)
self.replace_button.clicked.connect(self.update_replace_combo)
self.replace_button.clicked.connect(self.update_search_combo)
self.all_check = QCheckBox(_("Replace all"))
self.replace_layout = QHBoxLayout()
widgets = [replace_with, self.replace_text, self.replace_button,
self.all_check]
for widget in widgets:
self.replace_layout.addWidget(widget)
glayout.addLayout(self.replace_layout, 1, 1)
self.widgets.extend(widgets)
self.replace_widgets = widgets
self.hide_replace()
self.search_text.setTabOrder(self.search_text, self.replace_text)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.shortcuts = self.create_shortcuts(parent)
self.highlight_timer = QTimer(self)
self.highlight_timer.setSingleShot(True)
self.highlight_timer.setInterval(1000)
self.highlight_timer.timeout.connect(self.highlight_matches)
def create_shortcuts(self, parent):
"""Create shortcuts for this widget"""
# Configurable
findnext = create_shortcut(self.find_next, context='Editor',
name='Find next', parent=parent)
findprev = create_shortcut(self.find_previous, context='Editor',
name='Find previous', parent=parent)
togglefind = create_shortcut(self.show, context='Editor',
name='Find text', parent=parent)
togglereplace = create_shortcut(self.toggle_replace_widgets,
context='Editor', name='Replace text',
parent=parent)
# Fixed
new_shortcut("Escape", self, self.hide)
return [findnext, findprev, togglefind, togglereplace]
def get_shortcut_data(self):
"""
Returns shortcut data, a list of tuples (shortcut, text, default)
shortcut (QShortcut or QAction instance)
text (string): action/shortcut description
default (string): default key sequence
"""
return [sc.data for sc in self.shortcuts]
def update_search_combo(self):
self.search_text.lineEdit().returnPressed.emit()
示例2: ShellBaseWidget
# 需要导入模块: from spyderlib.qt.QtCore import QTimer [as 别名]
# 或者: from spyderlib.qt.QtCore.QTimer import setSingleShot [as 别名]
class ShellBaseWidget(ConsoleBaseWidget):
"""
Shell base widget
"""
INITHISTORY = None
SEPARATOR = None
def __init__(self, parent, history_filename, debug=False, profile=False):
"""
parent : specifies the parent widget
"""
ConsoleBaseWidget.__init__(self, parent)
# Prompt position: tuple (line, index)
self.current_prompt_pos = None
self.new_input_line = True
# History
self.histidx = None
self.hist_wholeline = False
assert isinstance(history_filename, (str, unicode))
self.history_filename = history_filename
self.history = self.load_history()
# Session
self.historylog_filename = CONF.get('main', 'historylog_filename',
get_conf_path('history.log'))
# Context menu
self.menu = None
self.setup_context_menu()
# Debug mode
self.debug = debug
# Simple profiling test
self.profile = profile
# Buffer to increase performance of write/flush operations
self.__buffer = []
self.__timestamp = 0.0
self.__flushtimer = QTimer(self)
self.__flushtimer.setSingleShot(True)
self.connect(self.__flushtimer, SIGNAL('timeout()'), self.flush)
# Give focus to widget
self.setFocus()
# Calltips
calltip_size = CONF.get('shell_appearance', 'calltips/size')
calltip_font = get_font('shell_appearance', 'calltips')
self.setup_calltips(calltip_size, calltip_font)
# Completion
completion_size = CONF.get('shell_appearance', 'completion/size')
completion_font = get_font('shell_appearance', 'completion')
self.completion_widget.setup_appearance(completion_size,
completion_font)
# Cursor width
self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
def toggle_wrap_mode(self, enable):
"""Enable/disable wrap mode"""
self.set_wrap_mode('character' if enable else None)
def set_font(self, font):
"""Set shell styles font"""
self.set_pythonshell_font(font)
cursor = self.textCursor()
cursor.select(QTextCursor.Document)
charformat = QTextCharFormat()
charformat.setFontFamily(font.family())
charformat.setFontPointSize(font.pointSize())
cursor.mergeCharFormat(charformat)
#------ Context menu
def setup_context_menu(self):
"""Setup shell context menu"""
self.menu = QMenu(self)
self.cut_action = create_action(self, _("Cut"),
shortcut=keybinding('Cut'),
icon=get_icon('editcut.png'),
triggered=self.cut)
self.copy_action = create_action(self, _("Copy"),
shortcut=keybinding('Copy'),
icon=get_icon('editcopy.png'),
triggered=self.copy)
paste_action = create_action(self, _("Paste"),
shortcut=keybinding('Paste'),
icon=get_icon('editpaste.png'),
triggered=self.paste)
save_action = create_action(self, _("Save history log..."),
icon=get_icon('filesave.png'),
tip=_("Save current history log (i.e. all "
"inputs and outputs) in a text file"),
triggered=self.save_historylog)
self.delete_action = create_action(self, _("Delete"),
shortcut=keybinding('Delete'),
icon=get_icon('editdelete.png'),
#.........这里部分代码省略.........
示例3: ShellBaseWidget
# 需要导入模块: from spyderlib.qt.QtCore import QTimer [as 别名]
# 或者: from spyderlib.qt.QtCore.QTimer import setSingleShot [as 别名]
class ShellBaseWidget(ConsoleBaseWidget, SaveHistoryMixin):
"""
Shell base widget
"""
redirect_stdio = Signal(bool)
sig_keyboard_interrupt = Signal()
execute = Signal(str)
append_to_history = Signal(str, str)
def __init__(self, parent, history_filename, profile=False):
"""
parent : specifies the parent widget
"""
ConsoleBaseWidget.__init__(self, parent)
SaveHistoryMixin.__init__(self)
# Prompt position: tuple (line, index)
self.current_prompt_pos = None
self.new_input_line = True
# History
self.histidx = None
self.hist_wholeline = False
assert is_text_string(history_filename)
self.history_filename = history_filename
self.history = self.load_history()
# Session
self.historylog_filename = CONF.get('main', 'historylog_filename',
get_conf_path('history.log'))
# Context menu
self.menu = None
self.setup_context_menu()
# Simple profiling test
self.profile = profile
# Buffer to increase performance of write/flush operations
self.__buffer = []
self.__timestamp = 0.0
self.__flushtimer = QTimer(self)
self.__flushtimer.setSingleShot(True)
self.__flushtimer.timeout.connect(self.flush)
# Give focus to widget
self.setFocus()
# Completion
completion_size = CONF.get('shell_appearance', 'completion/size')
completion_font = get_font('console')
self.completion_widget.setup_appearance(completion_size,
completion_font)
# Cursor width
self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
def toggle_wrap_mode(self, enable):
"""Enable/disable wrap mode"""
self.set_wrap_mode('character' if enable else None)
def set_font(self, font):
"""Set shell styles font"""
self.setFont(font)
self.set_pythonshell_font(font)
cursor = self.textCursor()
cursor.select(QTextCursor.Document)
charformat = QTextCharFormat()
charformat.setFontFamily(font.family())
charformat.setFontPointSize(font.pointSize())
cursor.mergeCharFormat(charformat)
#------ Context menu
def setup_context_menu(self):
"""Setup shell context menu"""
self.menu = QMenu(self)
self.cut_action = create_action(self, _("Cut"),
shortcut=keybinding('Cut'),
icon=ima.icon('editcut'),
triggered=self.cut)
self.copy_action = create_action(self, _("Copy"),
shortcut=keybinding('Copy'),
icon=ima.icon('editcopy'),
triggered=self.copy)
paste_action = create_action(self, _("Paste"),
shortcut=keybinding('Paste'),
icon=ima.icon('editpaste'),
triggered=self.paste)
save_action = create_action(self, _("Save history log..."),
icon=ima.icon('filesave'),
tip=_("Save current history log (i.e. all "
"inputs and outputs) in a text file"),
triggered=self.save_historylog)
self.delete_action = create_action(self, _("Delete"),
shortcut=keybinding('Delete'),
icon=ima.icon('editdelete'),
triggered=self.delete)
selectall_action = create_action(self, _("Select All"),
shortcut=keybinding('SelectAll'),
#.........这里部分代码省略.........
示例4: FindReplace
# 需要导入模块: from spyderlib.qt.QtCore import QTimer [as 别名]
# 或者: from spyderlib.qt.QtCore.QTimer import setSingleShot [as 别名]
#.........这里部分代码省略.........
text_beside_icon=True,
)
self.connect(self.replace_button, SIGNAL("clicked()"), self.update_replace_combo)
self.connect(self.replace_button, SIGNAL("clicked()"), self.update_search_combo)
self.all_check = QCheckBox(_("Replace all"))
self.replace_layout = QHBoxLayout()
widgets = [replace_with, self.replace_text, self.replace_button, self.all_check]
for widget in widgets:
self.replace_layout.addWidget(widget)
glayout.addLayout(self.replace_layout, 1, 1)
self.widgets.extend(widgets)
self.replace_widgets = widgets
self.hide_replace()
self.search_text.setTabOrder(self.search_text, self.replace_text)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.findnext_sc = QShortcut(QKeySequence("F3"), parent, self.find_next)
self.findnext_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.findprev_sc = QShortcut(QKeySequence("Shift+F3"), parent, self.find_previous)
self.findprev_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.togglefind_sc = QShortcut(QKeySequence("Ctrl+F"), parent, self.show)
self.togglefind_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.togglereplace_sc = QShortcut(QKeySequence("Ctrl+H"), parent, self.toggle_replace_widgets)
self.togglereplace_sc.setContext(Qt.WidgetWithChildrenShortcut)
escape_sc = QShortcut(QKeySequence("Escape"), parent, self.hide)
escape_sc.setContext(Qt.WidgetWithChildrenShortcut)
self.highlight_timer = QTimer(self)
self.highlight_timer.setSingleShot(True)
self.highlight_timer.setInterval(1000)
self.connect(self.highlight_timer, SIGNAL("timeout()"), self.highlight_matches)
def get_shortcut_data(self):
"""
Returns shortcut data, a list of tuples (shortcut, text, default)
shortcut (QShortcut or QAction instance)
text (string): action/shortcut description
default (string): default key sequence
"""
return [
(self.findnext_sc, "Find next", "F3"),
(self.findprev_sc, "Find previous", "Shift+F3"),
(self.togglefind_sc, "Find text", "Ctrl+F"),
(self.togglereplace_sc, "Replace text", "Ctrl+H"),
]
def update_search_combo(self):
self.search_text.lineEdit().emit(SIGNAL("returnPressed()"))
def update_replace_combo(self):
self.replace_text.lineEdit().emit(SIGNAL("returnPressed()"))
def toggle_replace_widgets(self):
if self.enable_replace:
# Toggle replace widgets
if self.replace_widgets[0].isVisible():
self.hide_replace()
self.hide()
else:
self.show_replace()
self.replace_text.setFocus()