Back to index

python3.2  3.2.2
Classes | Functions
idlelib.WidgetRedirector Namespace Reference

Classes

class  WidgetRedirector
class  OriginalCommand

Functions

def main

Function Documentation

Definition at line 107 of file WidgetRedirector.py.

00107 
00108 def main():
00109     root = Tk()
00110     root.wm_protocol("WM_DELETE_WINDOW", root.quit)
00111     text = Text()
00112     text.pack()
00113     text.focus_set()
00114     redir = WidgetRedirector(text)
00115     global previous_tcl_fcn
00116     def my_insert(*args):
00117         print("insert", args)
00118         previous_tcl_fcn(*args)
00119     previous_tcl_fcn = redir.register("insert", my_insert)
00120     root.mainloop()
00121     redir.unregister("insert")  # runs after first 'close window'
00122     redir.close()
00123     root.mainloop()
00124     root.destroy()