How do I make this Python extension work on windows (clear IDLE)? -


http://bugs.python.org/issue6143

i know similar has been asked thousand times, me indicates issue being addressed designers.

i have searched , searched , found solution looks viable (see link above), complete beginner python , need how make work. i've tried adding code in comments section config-extensions.def file, , running file idle, no "clear screen" option appears on menu, nor ctrl+l keyboard shortcut. btw i'm using python 3.4 on windows.

i'm surprised , shocked functionality not included standard reason: python recommended beginners' language , beginners (including me , students intend teach language once i've learned it) overwhelmed lots of not-understood text on screen (syntax errors etc.) need 1 of important features kind of "panic button" clear away mess , let try again blank slate. closing application re-opening serious overkill can't fathom why hasn't been considered. if knows contact changed think is worth emphasizing importance of issue, since deal breaker in choosing language educational purposes.

however, main concern here making work can on , have fun programming! appreciated.

ok, found answer (and took 2 computer literate people while work out):

put following code comments section of clearwindow.py config-extensions.def (c:\python34\lib\idlelib...)

[clearwindow] enable=1 enable_editor=0 enable_shell=1 [clearwindow_cfgbindings] clear-window=<control-key-l> 

next, in same folder (c:\python34\lib\idlelib) put whole clearwindow.py file. ta da! file pasted below convenience:

"""  clear window extension version: 0.2  author: roger d. serwy         roger.serwy@gmail.com  date: 2009-06-14  provides "clear shell window" under "options" ability undo.  add these lines config-extensions.def  [clearwindow] enable=1 enable_editor=0 enable_shell=1 [clearwindow_cfgbindings] clear-window=<control-key-l>   """  class clearwindow:      menudefs = [         ('options', [none,                ('clear shell window', '<<clear-window>>'),        ]),]      def __init__(self, editwin):         self.editwin = editwin         self.text = self.editwin.text         self.text.bind("<<clear-window>>", self.clear_window2)          self.text.bind("<<undo>>", self.undo_event)  # add="+" doesn't work      def undo_event(self, event):         text = self.text          text.mark_set("iomark2", "iomark")         text.mark_set("insert2", "insert")         self.editwin.undo.undo_event(event)          # fix iomark , insert         text.mark_set("iomark", "iomark2")         text.mark_set("insert", "insert2")         text.mark_unset("iomark2")         text.mark_unset("insert2")       def clear_window2(self, event): # alternative method         # work around modifiedundodelegator         text = self.text         text.undo_block_start()         text.mark_set("iomark2", "iomark")         text.mark_set("iomark", 1.0)         text.delete(1.0, "iomark2 linestart")         text.mark_set("iomark", "iomark2")         text.mark_unset("iomark2")         text.undo_block_stop()         if self.text.compare('insert', '<', 'iomark'):             self.text.mark_set('insert', 'end-1c')         self.editwin.set_line_and_column()      def clear_window(self, event):         # remove undo delegator         undo = self.editwin.undo         self.editwin.per.removefilter(undo)          # clear window, preserve current command         self.text.delete(1.0, "iomark linestart")         if self.text.compare('insert', '<', 'iomark'):             self.text.mark_set('insert', 'end-1c')         self.editwin.set_line_and_column()          # restore undo delegator         self.editwin.per.insertfilter(undo) 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -