Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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; 'expected.': 0.09; 'mercurial': 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; 'window.': 0.09; 'windows,': 0.09; 'jan': 0.12; 'wrote': 0.14; 'thread': 0.14; "(i'm": 0.16; 'abort': 0.16; 'added.': 0.16; 'backspace': 0.16; 'entry.': 0.16; 'imports': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'say.': 0.16; 'selects': 0.16; 'tab': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'app': 0.19; 'any,': 0.19; 'commit': 0.19; 'things.': 0.19; 'user.': 0.19; 'widget': 0.19; 'entered': 0.20; 'meant': 0.20; 'fit': 0.20; 'work,': 0.20; 'input': 0.22; 'select': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'text,': 0.24; 'text.': 0.24; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'leave': 0.29; 'am,': 0.29; 'patch': 0.29; 'code': 0.31; 'getting': 0.31; 'lines': 0.31; 'extending': 0.31; 'keys': 0.31; 'sep': 0.31; 'file': 0.32; 'skip:- 30': 0.32; 'run': 0.32; 'text': 0.33; 'says': 0.33; 'beginning': 0.33; 'minimal': 0.33; 'message.': 0.35; 'subject:with': 0.35; 'something': 0.35; 'done.': 0.35; 'editor': 0.35; 'test': 0.35; 'but': 0.35; 'add': 0.35; 'really': 0.36; 'entry': 0.36; 'should': 0.36; 'starting': 0.37; 'minimum': 0.38; 'window': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'extremely': 0.39; 'functional': 0.39; 'received:71': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'blank': 0.60; 'save': 0.62; 'field': 0.63; 'grab': 0.64; 'more': 0.64; 'movement': 0.65; 'here': 0.66; 'between': 0.67; 'close': 0.67; 'home': 0.69; 'saving': 0.69; 'below.': 0.71; 'cut': 0.74; '5:36': 0.84; 'again!': 0.84; 'delete,': 0.84; 'pre-load': 0.84; 'premise': 0.84; 'received:fios.verizon.net': 0.84; 'opens': 0.91 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 21:49:25 -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: 74 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409708996 news.xs4all.nl 2928 [2001:888:2000:d::a6]:51711 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77461 On 9/2/2014 5:36 PM, Chris Angelico wrote: > On Wed, Sep 3, 2014 at 7:14 AM, Terry Reedy wrote: >> 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. My mistake. See below. >> 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. 'Minimal' mean minimal, as in the minimal number of lines of code to actually work (4), as a the minimum needed to prove the concept, and a starting point for adding more things. > Err, that's not all it takes to run an editor :) File opening The opening premise of the thread was something like "Input() is good for getting a single line of text input from a user. What about getting multiple lines of text?" Opening a non-empty existing file is not relevant to the purpose of extending input(). I intentionally said 'text entry widget', not 'editor'. For editing a particular existing text, the app might pre-load the widget with that text. > saving would be kinda helpful, for a start... It is really annoying when someone clips (erases) something I said and then says that I should have said what I did say. Here it is again! >> In use, a save function would have to be added. The function does not have to be attached to menu widget. When one imports a patch into a mercurial repository, hg offers the opportunity to enter a multi-line commit message. Just the scenario this thread started with. It opens a text entry window something like tkinter.Text. It is preloaded with something like the following. -----------------------------------X| | | |===================================| |Enter commit message above the line| |or leave blank to abort commit. | |Close window when done. | ------------------------------------- Hg intercepts the window close event to grab the entered text, if any, before it disappears. > But that's what I meant when I said that a multi-line entry field is > an extremely standard widget. (I'm a bit surprised that PgUp/PgDn > don't work, My mistake. They do when I add more lines than fit in the window. -- Terry Jan Reedy