Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77461
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Editing text with an external editor in Python |
| Date | 2014-09-02 21:49 -0400 |
| References | (3 earlier) <mailman.13694.1409602073.18130.python-list@python.org> <zjfNv.198388$rQ.139558@fx13.am4> <CAPTjJmpPjBmtgC2dvuYmGQNc900rb=XUt5LRGHwS0--G+_xCew@mail.gmail.com> <lu5bvo$q9$1@ger.gmane.org> <CAPTjJmorxvVLgDWEi5b7vntR+wtf0aYXswX-2sTM24ed_+i=_w@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13722.1409708996.18130.python-list@python.org> (permalink) |
On 9/2/2014 5:36 PM, Chris Angelico wrote: > On Wed, Sep 3, 2014 at 7:14 AM, Terry Reedy <tjreedy@udel.edu> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Editing text with an external editor in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-02 02:11 +1000
Re: Editing text with an external editor in Python Chris Angelico <rosuav@gmail.com> - 2014-09-02 02:35 +1000
Re: Editing text with an external editor in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-02 04:23 +1000
Re: Editing text with an external editor in Python Tim Chase <python.list@tim.thechases.com> - 2014-09-01 15:06 -0500
Re: Editing text with an external editor in Python alister <alister.nospam.ware@ntlworld.com> - 2014-09-02 08:35 +0000
Re: Editing text with an external editor in Python Chris Angelico <rosuav@gmail.com> - 2014-09-02 18:45 +1000
Re: Editing text with an external editor in Python alister <alister.nospam.ware@ntlworld.com> - 2014-09-03 08:06 +0000
Re: Editing text with an external editor in Python Terry Reedy <tjreedy@udel.edu> - 2014-09-02 17:14 -0400
Re: Editing text with an external editor in Python Chris Angelico <rosuav@gmail.com> - 2014-09-03 07:36 +1000
Re: Editing text with an external editor in Python Terry Reedy <tjreedy@udel.edu> - 2014-09-02 21:49 -0400
Re: Editing text with an external editor in Python Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-09-02 22:03 -0500
Re: Editing text with an external editor in Python Chris Angelico <rosuav@gmail.com> - 2014-09-02 08:30 +1000
Re: Editing text with an external editor in Python Roy Smith <roy@panix.com> - 2014-09-01 13:06 -0400
Re: Editing text with an external editor in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-02 04:02 +1000
Re: Editing text with an external editor in Python Cameron Simpson <cs@zip.com.au> - 2014-09-02 08:14 +1000
Re: Editing text with an external editor in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-02 13:18 +1000
Re: Editing text with an external editor in Python Chris Angelico <rosuav@gmail.com> - 2014-09-02 08:25 +1000
Re: Editing text with an external editor in Python gschemenauer3@gmail.com - 2014-09-01 19:24 -0700
csiph-web