本文整理汇总了Python中tkinter.Tk.event_add方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.event_add方法的具体用法?Python Tk.event_add怎么用?Python Tk.event_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.event_add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interface
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import event_add [as 别名]
#.........这里部分代码省略.........
self.root.bind('<<copy>>', self.editor_list.copy_event)
self.root.bind('<<paste>>', self.editor_list.paste_event)
self.root.bind('<<select-all>>', self.editor_list.select_all_event)
self.root.bind('<<find>>', self.editor_list.find_event)
self.root.bind('<<find-again>>', self.editor_list.find_again_event)
self.root.bind('<<find-selection>>',
self.editor_list.find_selection_event)
self.root.bind('<<find-in-files>>',
self.editor_list.find_in_files_event)
self.root.bind('<<replace>>', self.editor_list.replace_event)
self.root.bind('<<goto-line>>', self.editor_list.goto_line_event)
# Format
self.root.bind('<Control-i>', self.editor_list.indent_region_event)
self.root.bind('<Control-d>', self.editor_list.dedent_region_event)
self.root.bind('<<comment-region>>', self.editor_list.comment_region_event)
self.root.bind('<<uncomment-region>>', self.editor_list.uncomment_region_event)
self.root.bind('<<tabify-region>>', self.editor_list.tabify_region_event)
self.root.bind('<<untabify-region>>', self.editor_list.untabify_region_event)
self.root.bind('<<toggle-tabs>>', self.editor_list.toggle_tabs_event)
self.root.bind('<Control-plus>', self.editor_list.increase_font_size_event)
self.root.bind('<Control-minus>', self.editor_list.decrease_font_size_event)
# Code execution
self.root.bind('<<check-module>>', self.check_module)
self.root.bind('<Control-r>', self.run_module)
self.root.bind('<Control-Key-Return>', self.run_source)
# File change in notebook
self.root.bind('<<NotebookTabChanged>>', self.update_title)
# Bind the keys
if keydefs is None:
keydefs = Bindings.default_keydefs
for event, keylist in keydefs.items():
if keylist:
self.root.event_add(event, *keylist)
def update_title(self, event=None):
""" Give the title the current filename """
#print("editor list: ", self.editor_list.index("current"))
try:
new_title = self.editor_list.tab(self.editor_list.index("current"), "text")
except:
new_title = "MrPython"
self.root.title(new_title)
return
directory = ""
if self.editor_list.get_current_editor().io.filename:
directory = self.editor_list.get_current_editor().io.filename
if directory != "":
new_title += " (" + directory + ")"
new_title += " - MrPython"
self.root.title(new_title)
#def maybe_save_run(self, event=None):
def save(self, event=None):
""" Save the current file (and display it in the status bar) """
filename = self.editor_list.save()
if filename:
self.status_bar.update_save_label(filename)
self.update_title()
def change_mode(self, event=None):