[issue46666] IDLE Add indent guide

2022-02-25 Thread Aivar Annamaa


Aivar Annamaa  added the comment:

The guides could be implemented by tagging the indentation characters in the 
Text widget with tags configured with suitable bgstipple 
(https://www.tcl.tk/man/tcl/TkCmd/text.html#M45) bitmaps.

I had some success with this in Thonny IDE, but abandoned the plan because 
bstipple is not supported on macOS (for some reason).

--
nosy: +aivarannamaa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I am guessing that N++ or its GUI framework uses a transparent overlay.  For 
tkinter, that would mean a transparent Canvas on which one could draw vertical 
dotted gray lines 1-pixel wide.  However, Serhiy Storchaka in msg213643 of 
#20920 said: "Tk supports alpha only for photo images and as an attribute of 
top-level window. It doesn't support alpha component in colors."

I searched 'tkinter transparent canvas'.

For pixel positioning, photos with transparent backgrounds can only be used on 
a canvas.  This was one of the answers to 
https://stackoverflow.com/questions/53021603/how-to-make-a-tkinter-canvas-background-transparent
More details, using pil(low) to make images, are in the following:
https://www.tutorialspoint.com/how-to-make-a-tkinter-canvas-rectangle-transparent
https://www.javaer101.com/en/article/921105.html

Another answer to the SO question, for Windows only, was to pip install pywin32 
and use various calls to make a canvas layered with a transparent colorkey.  
Perhaps the same could be done, at least on Windows, with ctypes.

A top-level background is made (partially) transparent with 
"top.attributes('-alpha', d)" where d in [0.0-1.0].  On Windows, 
'top.wm_attributes('-transparentcolor', keycolor) makes that keycolor actually 
be transparent, like the green/blue screen used in television and movies. But 
any keycolor pixel in the toplevel exposes the screen beneath the toplevel, not 
the widget in the toplevel.  This detail is not clear in the tk docs.
https://www.youtube.com/watch?v=75jbNpc8vN4
What also is not clear is whether the keycolor applies only to the one toplevel 
or all toplevels, nor what happens when one toplevel is over another.

I summarized the above so I or anyone else can find the information.  I am 
closing this issue for now, but someone can reopen if the situation changes.

--
resolution:  -> third party
stage: test needed -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-11 Thread primexx


primexx  added the comment:

very informative discussion. i'll just say that if it's not possible to do 
purely visually, and it can only be done by modifying the textual content, then 
it probably should not be done at all. preserving the code (and copy+paste 
integrity) is more important. maybe this is actually something to raise with Tk 
first?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-06 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

'│' is a bit taller that ascii bar '|'; hex(ord('│')) = '0x2502'.   It is a bit 
heavy.  In this Windows Firefox box it is slightly lighter than | but in IDLE 
with Source Code Pro, it is slightly darder.  Worse is being centered instead 
of on one edge.

We would have to check it with multiple fixed-ascii-pitch fonts on multiple 
systems before using any non-ascii char.  Does it always have the exact width 
of ascii ' ' or easier to check, ascii '|', so that is does not change the 
indent?   This is easily tested in the Settings dialog Font tab sample box.  
Paste the following
│││
|||
It passes with all but one of the Windows mono fonts I tried.

I may ask a tk/tkinter question on SO about other possible options.  Testing 
this one in code:

if a:  # Put 1st bar on 4th space.
if b:
   │if c:
   │   │pass
if d:
   │pass

if a: # Put 1st bar on 5th space.
if b:
│   if c:
│   │   pass
if d:
│   pass

if a: # Put 1st bar on 1st space.
│   if b:
│   │   if c:
│   │   │   pass
│   if d:
│   │   pass

The 2nd option looks best to me.  The 3rd would be easier to program, as 
default tab indent would always be '│   '.  In any case, copied code would not 
be runnable code.  I would add this on the Option menu between Code Context and 
Line Numbers.

I believe only updating the markers on demand would be much easier to program 
than dynamically updating them with each keystroke (checking key and whether 
whitespace in indent area).

Before merging a PR (writen by someone else), someone other than me, such as 
Raymond, must test it in real use both for correctness, usefulness, and 
aesthetics.  (I anticipate that I would fail it on the latter two.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-06 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

If this were possible, it would be really nice to have.

FWIW, the rich¹ project was able to pull this off in regular text terminal 
window:

$ python3.10 -m pip install rich
$ python3.10 -m rich.pretty
{
│   'foo': [1, 'Hello World!', 100.123, 323.232, 432324.0, {(1, 2, 3, 4), 5, 6, 
7, 8}, ...],
│   'bar': frozenset({1, 2, 3}),
│   'defaultdict': defaultdict(, {'crumble': ['apple', 'rhubarb', 
'butter', 'sugar', 'flour']}),
│   'counter': Counter({'apple': 1, 'orange': 1, 'pear': 1, 'kumquat': 2, 
'duriandurianduriandu'+580: 1}),
│   'atomic': (False, True, None),
│   'Broken': 
}


¹ https://rich.readthedocs.io/en/stable/index.html

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I loaded a .py file into N++ and see them.  Under 3 x, there are clearly 
separate minidots.  Under 10x, the dots are hardly visible.  They are not 
characters in the text (cannot be copied) but a special manipulation of the 
column of pixels 'between' spaces.  This must be a built-in feature of to the 
text widget.  I suspect it involves special subpixel manipulation, perhaps 
requiring information from the monitor.  AFAIK, Tk widgets do not have this 
feature.  Unless there is a unicode char consisting of light dots on the very 
edge, we cannot even simulate this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-06 Thread primexx


primexx  added the comment:

> Please just select the current development version.  Others can be marked if 
> and when backported

oh sorry about  that!

> Please explain exactly what you want

these dotted lines in the attached screenshot

> What you see in the editor is what is saved (including when running), so any 
> non-code additions have to be removed first.

yes, this would be a pure visual element in the editor, not modifying the 
actual code

> IDLE's code context feature (Options menu) could be considered an indent 
> guide.  In some ways, it is better.

it is very useful indeed, but not quite the same as a persistent visual 
indicator imho

thanks!

--
Added file: https://bugs.python.org/file50608/npp-indent-guide.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46666] IDLE Add indent guide

2022-02-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

[Please just select the current development version.  Others can be marked if 
and when backported.  3.8 and before only get security fixes.  Same for 3.9 
after about next May 31.]

Please explain exactly what you want and rewrite something like the following.
if a:
if b:
if c:
pass
if d:
pass

IDLE's code context feature (Options menu) could be considered an indent guide. 
 In some ways, it is better.


What you see in the editor is what is saved (including when running), so any 
non-code additions have to be removed first.

--
stage:  -> test needed
title: IDLE indent guide -> IDLE Add indent guide
type:  -> enhancement
versions:  -Python 3.10, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com