Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77455

Re: Editing text with an external editor in Python

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Editing text with an external editor in Python
Date 2014-09-02 17:14 -0400
References (1 earlier) <mailman.13692.1409589319.18130.python-list@python.org> <5404b987$0$30001$c3e8da3$5496439d@news.astraweb.com> <mailman.13694.1409602073.18130.python-list@python.org> <zjfNv.198388$rQ.139558@fx13.am4> <CAPTjJmpPjBmtgC2dvuYmGQNc900rb=XUt5LRGHwS0--G+_xCew@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13719.1409692486.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 9/2/2014 4:45 AM, Chris Angelico wrote:
> On Tue, Sep 2, 2014 at 6:35 PM, alister
> <alister.nospam.ware@ntlworld.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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