Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'root': 0.05; 'subject:text': 0.05; 'subject:Python': 0.06; 'tkinter': 0.07; 'cursor': 0.09; 'deploy': 0.09; 'editor.': 0.09; 'expected.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:editor': 0.09; 'windows,': 0.09; 'python': 0.11; 'gui': 0.12; 'jan': 0.12; 'wrote': 0.14; 'added.': 0.16; 'backspace': 0.16; 'entry.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'selects': 0.16; 'tab': 0.16; 'wrote:': 0.18; 'widget': 0.19; 'select': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'script.': 0.24; "shouldn't": 0.24; 'text.': 0.24; 'least': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'quickly': 0.29; 'adequate': 0.31; 'keys': 0.31; 'sep': 0.31; 'this.': 0.32; 'option': 0.32; 'text': 0.33; 'beginning': 0.33; 'minimal': 0.33; 'not.': 0.33; 'subject:with': 0.35; 'info': 0.35; 'test': 0.35; 'entry': 0.36; 'too': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'functional': 0.39; 'received:71': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'easy': 0.60; 'most': 0.60; 'save': 0.62; 'movement': 0.65; 'between': 0.67; 'home': 0.69; 'cut': 0.74; 'delete,': 0.84; 'received:fios.verizon.net': 0.84; 'absolutely': 0.87 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Editing text with an external editor in Python Date: Tue, 02 Sep 2014 17:14:28 -0400 References: <54049ab7$0$29972$c3e8da3$5496439d@news.astraweb.com> <5404b987$0$30001$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409692486 news.xs4all.nl 2958 [2001:888:2000:d::a6]:59762 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77455 On 9/2/2014 4:45 AM, Chris Angelico wrote: > On Tue, Sep 2, 2014 at 6:35 PM, alister > wrote: >> if edlin is your only option then it would be better to spend you time >> writhing your own text editor! > > Heh! > > Considering how easy it is to deploy a multi-line edit widget in any > GUI toolkit, it shouldn't be too hard to write a GUI text editor. Most Python installations have tkinter available. I quickly wrote an absolutely minimal script. import tkinter as tk root = tk.Tk() text = tk.Text() text.pack() root.mainloop() I tested tested the functions and wrote the following. This is a test text entry. Enter and Tab work as expected. The Arrow (Cursor) keys work as expected. CntL-Left and Cntl-Right move a word at time. Home and End move to beginning and end of the line. Cntl-Home and Cntl-Up move to the beginning of the text. Cntl-End and Cntl-Donw move to the end of the text. Shift + cursor movement selects between the begin and end slice positions. PageUp and PageDown are inoperative. Delete and Backspace work as expected. At least on Windows, I can select text and delete, or cut or copy to Clipboard. I can also paste from the clipboard. In otherwords, this is a functional minimal text entry widget. I did not even know about Shift-movement selecting until I tried it. Notepad has this. Thunderbird's text entry does not. I think the above is adequate for most multi-line text entry. In use, a save function would have to be added. A help text with the above info would be good too (Idle needs this). -- Terry Jan Reedy