[Idle-dev] Bug in cursor placement in IDLE editor windows

Terry Reedy tjreedy at udel.edu
Thu Nov 2 20:24:59 EDT 2017


On 11/2/2017 7:20 PM, Irv Kalb wrote:

> I use IDLE when teaching classes, and I use it to develop small programs for my lessons.  I have found a bug that has been in IDLE for a while, and I finally got frustrated enough with it to write.
> 
> I am running on a Mac using IDLE version 3.6.1:
> 
> Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

 From the date, this appears to be the binary from python.org.
Did you upgrade tcl/tk as specified at
https://www.python.org/download/mac/tcltk/ ?
What Tk version is shown by Help => About IDLE?

> running Max OS X 10.12.6 - but I also see this same problem when I am in class running Windows 10, with Python 3.6.???
I use Windows 10 and I cannot reproduce the problem you report with any 
of 2.7.14, 3.6.3, or 3.7.0a2.  I used
if a:
     if b:
         if c:
             d
             d
             f
for testing.  Please post a sample text that fails on Windows 10.  If 
you want, do what I would do and insert it into the following code.

import tkinter as tk
root = tk.Tk()
text = tk.Text(root)
sample = '''
<replace this with sample that allows reported error>
'''
text.insert('1.0', sample)
text.pack()
root.mainloop()

Then run and click in the resulting Text window and see if the behavior 
is the same or different.  Mouse clicks in the text area of an editor 
window are primarily handled by tk, not IDLE or even tkinter.  Without 
running this control experiment, there is no reason to blame IDLE.

 > One thing to point out, I always use the Tab key to indent my lines. 
However, even if I type many space characters to indent, I see the same 
(incorrect behavior).

Unless you have a particular undocumented entry in 
<HOME>/.idlerc/config-main.cfg, tabs are converted to spaces (default 4) 
before insertion into the text widget.  If the <- and -> arrow keys 
always move one character, you have spaces.

> If I have an indented line, and I click just to the left of the first real character on that line, often IDLE will place the insertion cursor at the wrong place - at one character to the right of the left edge of the window.  If I click in the same spot (Just to the left of the first real character on the line), IDLE responds by moving the insertion cursor one space to the right.  Depending on how many times the line I'm clicking on has been indented, IDLE eventually highlights a section from the last character of the previous line to just before the first real character of the line where I clicked.  If I click one more time, IDLE puts the insertion character in the correct place.

For me, a sinple click places the the cursor on the nearest 
between-character slice line, either to the left or right of where I 
click.  Two clicks that are rapid enough to be interpreted as a double 
click select a word or non-word slice.  Similarly, clicks with the bar 
overlapping two lines are pushed to the 'closer' line, either up or down.

--
Terry Jan Reedy


More information about the IDLE-dev mailing list