This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE add font resizing hot keys and wheel
Type: enhancement Stage: patch review
Components: IDLE Versions: Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Abhishek.Kumar, Todd.Rovito, ZackerySpytz, alex.rodas, edmond.burnett, giampaolo.rodola, markroseman, python-dev, rhettinger, roger.serwy, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2013-04-06 06:06 by rhettinger, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
issue17642_patch.diff Abhishek.Kumar, 2013-04-28 20:45
ZoomInOut.patch alex.rodas, 2013-04-30 01:42 review
ZoomInOut.patch2 alex.rodas, 2013-05-13 14:45 review
Pull Requests
URL Status Linked Edit
PR 17107 open ZackerySpytz, 2019-11-11 06:57
Messages (18)
msg186118 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-04-06 06:06
Add the standard hot keys for resizing fonts (i.e. on a Mac, CMD-plus and CMD-minus).
msg186138 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-04-06 16:45
IdleX provides this with the ZoomFont.py extension. (See http://idlex.sourceforge.net/extensions.html#Misc) It is useful for showing code on a projector so that students can easily read the screen.

The implementation in ZoomFont.py does not change the font size found in IDLE's configuration. Instead it queries the font size in the text widget and scales accordingly with a relative offset. 

IDLE needs a better way to broadcast font configuration changes. Right now, the Code Context extension uses polling every second to check for font changes. I bring this point up because properly incorporating font zooming may require refactoring some code. Incorporating Line Numbers, from #17535 would likely need to rely on this font size broadcasting as well.
msg186654 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-04-12 17:27
On Windows, cntl-+. cntl--

Could we use the tk event system by defining font change events and event handlers?
msg188010 - (view) Author: Alejandro Rodas (alex.rodas) * Date: 2013-04-28 18:22
I have made a patch to zoom in and out with <Control-plus> and <Control-minus> events, respectively. I'll upload it soon since the test suite is giving me an error in test_multiprocessing, even before writing the patch.

I have taken a look at ZoomFont.py of IdleX and it also has the option to reset the font size to its original value, but I don't know if this feature was wanted to be added too. However, ZoomFont controls the size of the LineNumber extension, while this patch only changes the font of the editview's text widget.
msg188019 - (view) Author: Abhishek Kumar (Abhishek.Kumar) * Date: 2013-04-28 20:45
I have submitted a patch that is working fine on Windows and on Ubuntu. I have used ZoomFont.py of IdleX.

On pressing Ctrl+ or Ctrl- it changes the user configuration and updates the font of all open windows as there is a common user configuration for all windows. I have removed polling from CodeContext instead I set font of CodeContext on every font change.

As this is my first patch. Please review it and give your valuable feedback.
msg188030 - (view) Author: Alejandro Rodas (alex.rodas) * Date: 2013-04-28 23:08
I have uploaded my patch as well, it doesn't make use of tkfont (just vanilla Tkinter methods) and it works both in Python 2.7 and 3.4 without the need of any import.

I think the main difference with Abhishek Kumar's version is that mine does not use idleConf to retrieve and set the font size. However, the original ZoomFont.py of IdleX does not use it. Is it really necessary?
msg188031 - (view) Author: Alejandro Rodas (alex.rodas) * Date: 2013-04-28 23:17
Sorry, I submitted a patch which only works on Windows. This one has been tested on Ubuntu too.
msg188124 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-04-30 03:53
Abhishek, Alejandro, welcome to IDLE development! If you can, please sign a contributor agreement.

We have two patches to create this enhancement, both are good. I suggest that we figure out how to merge the solutions.

The zoom-out binding should also include Ctrl-Equal, so that holding shift is no longer necessary. There's also a corner case where the zooming in on the editor may cause the cursor to go outside of viewing window.

Using idleConf to query the font information is not strictly necessary since the font configuration in the text widget contains the font size already.

In the future, please be careful with licensing. The top part of the ZoomFont.py extension places it under the NCSA license. Fortunately UIUC has allowed me to relicense parts IdleX for the Python Software Foundation.
msg188128 - (view) Author: Abhishek Kumar (Abhishek.Kumar) * Date: 2013-04-30 06:14
Thanks Roger, for the feedback especially the licence part. I have least idea about licences but will take care in future.

One question: Is it right to change IdleConf on Ctrl+ and Ctrl- ? I mean to change font for all open windows?
It happens with most text editors but not with browsers.

To remove those 2 hacks for CodeContext and LineNumbers, what we can do is write a ResetFont() for each extenstion and can call it from the ResetFont() of editor window like this: 
for extension in self.extensions:
    extension.ResetFont()
so that we don't have to write seperate font-size hacks for each extension while resetting the font.
msg189141 - (view) Author: Alejandro Rodas (alex.rodas) * Date: 2013-05-13 14:45
I have merged the two patches: Now it queries the font size as I did in the original patch, and it also stores the position of the cursor based on Abhishek Kumar's modification of ZoomFont.py.
msg189195 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2013-05-14 03:38
@Abhishek: I'd rather not require extensions to have a new method for resetting font sizes. Instead, a virtual event can be bound to a callback by the extension if it needs to know about a font change.

@Alejandro: It looks like there's a bug in ZoomFont.py where the cursor can go off screen which has propagated into these patches. That's my fault.

I'll take a look at these points later this week.
msg226328 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-09-03 21:42
#21933 added font resizing hotkeys to turtle demo: Control/Command minus, underscore, equal, minus. The OS difference was handled by defining the prefix for the system.
    shortcut = 'Command' if darwin else 'Control'
    widget.bind_all('<%s-minus>' % shortcut, self._decreaseFont)

The patch also added including control-mousewheel. The discussion there revealed that Control-mousewheel up/down generates a <Control-MouseWheel> event with event.delta of +120/-120 on Windows, -1/+1 on Darwin, and <Control-Button-4>/<Control-Button-5> events on X11. 

Control-mousewheel has a tk glitch in that it also generates ordinary mousewheel (scrolling) events. For turtledemo's read-only window of relatively short files, we decided not to worry.  Moving the cursor in edit windows would be a worry.

But Saimadhave and I discovered with line-numbering that this is also a problem with font resizing even without scrolling.  Text widgets send scroll up and down and back to start position commands to the scroll bar on font-resizing. See #17535, my tkfontsize.py test file, and the discussion thereof.

Also, the fontsize needs a minimum since tk (at least on Mac) treats negative sizes as positive sizes, so that decreasing past 0 increases.

This issue is *not* easy.

From the discussion (I have not read the patches yet), I am not sure whether the hotkey is intended to affect just the one window, like Context (and probably line numbering) or all,  I think it should just be the one window.
msg273687 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-25 23:18
https://stackoverflow.com/questions/39155656/i-need-bigger-font-in-python-idle/39156068#39156068 is about getting a larger font size than 22 for classroom projection.  I think configdialog.py should be extended something as follows (about line 1000).

    self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13',
                                  '14', '16', '18', '20', '22',
                                  '25', '30', '35', '40'), fontSize )
 
I think any new key or wheel should change by 1 over a large range rather than being constrained to the values on the list.  I will try to look at the patches before 3.6.  Tests should also be added.
msg273978 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-31 00:19
New changeset f478f9b88319 by Terry Jan Reedy in branch '2.7':
Issue #17642: add larger font sizes for classroom projection.
https://hg.python.org/cpython/rev/f478f9b88319

New changeset c9d59e6cc1e4 by Terry Jan Reedy in branch 'default':
Issue #17642: add larger font sizes for classroom projection.
https://hg.python.org/cpython/rev/c9d59e6cc1e4
msg273979 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-31 00:22
I intend to backport the simple list expansion to 3.5.  Key or wheel patches will probably be 3.6 only.
msg350259 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-08-23 07:18
> Key or wheel patches will probably be 3.6 only.

I still have hopes that this will happen.

Am I correct in thinking that it wouldn't be difficult to map CMD-plus and CMD-minus (or for Windows Cntl-plus and Cntl-minus) to a function that increases or decreases the font-size without having to manually go to Preferences/FontsAndTabs?
msg350320 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-08-23 18:00
I want this too, and part of it should be simple.  Given that I have had a never empty backlog of PRs to review for 2 1/2 years, it got forgotten.  There was also a tk problem that seemed to block implementation.

Specification for hotkey: Cntl/Cmd - -+= decrease/increase font size within limits in the current window only.  (The current limits for turtledemo are 6 and 100.  Change this?  The keys are fixed and cannot be customized. Keys have no affect on IdleConf.  Setting font size in dialog continues to set font size for all Windows, whether individually set or not.  Should work same for editor and text (read-only) windows.

As near as I can tell, these key combinations currently do nothing.  I presume they are not bound in the built-in keysets.  Custom keysets are always subject to interference when we add new key bindings.  (I don't know that the custom key dialog checks against such fixed builtins. Another issue.  Checking custom keysets on import is likely a third issue.)

Implementation for hotkey: The desired behavior is the behavior of turtledemo, so the same implementation should work.  It is annoying that we need to add it separately for editor and text windows.  But refactoring to create a common base class would be a lot harder. 

Mousewheel: Currently, in turtledemo, control-wheel changes size on all systems.  

Raymond: Should it be cmd-wheel on Mac?

In msg226328 I reported a tk issue blocking both this and line numbers.  We now deliver 3.7.4 and 3.8.0 with tk 8.6.9.  We have line numbers because I no longer saw the glitchy behavior I remember.  Nor did I see any issue with font resizing with turtledemo.

I may include the module browser, etc, with this issue.  Dialogs would be another issue.
msg356413 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-12 06:03
#33397 add a FontSizer class to textview.py and uses it there and for the doc viewer in help.py.  It should be used for this issue also.
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61842
2019-11-17 11:41:47taleinatsetnosy: + taleinat
2019-11-14 07:38:01ZackerySpytzsetnosy: + ZackerySpytz
2019-11-12 06:03:27terry.reedysetmessages: + msg356413
2019-11-11 06:57:54ZackerySpytzsetpull_requests: + pull_request16613
2019-08-23 18:00:16terry.reedysetmessages: + msg350320
2019-08-23 07:18:27rhettingersetmessages: + msg350259
versions: + Python 3.8, Python 3.9, - Python 2.7, Python 3.5, Python 3.6
2016-08-31 00:22:53terry.reedysetmessages: + msg273979
2016-08-31 00:19:38python-devsetnosy: + python-dev
messages: + msg273978
2016-08-25 23:18:24terry.reedysetversions: + Python 3.6, - Python 3.4
title: IDLE add font resizing hot keys -> IDLE add font resizing hot keys and wheel
messages: + msg273687

assignee: roger.serwy -> terry.reedy
stage: needs patch -> patch review
2015-08-07 04:51:23markrosemansetnosy: + markroseman
2014-09-03 21:42:54terry.reedysetkeywords: - easy

messages: + msg226328
versions: + Python 3.5, - Python 3.3
2013-07-12 07:39:52rhettingersetassignee: roger.serwy
2013-05-14 03:38:24roger.serwysetmessages: + msg189195
2013-05-13 14:45:15alex.rodassetfiles: + ZoomInOut.patch2

messages: + msg189141
2013-04-30 06:14:28Abhishek.Kumarsetmessages: + msg188128
2013-04-30 03:53:10roger.serwysetmessages: + msg188124
2013-04-30 01:42:27alex.rodassetfiles: + ZoomInOut.patch
2013-04-28 23:17:29alex.rodassetmessages: + msg188031
2013-04-28 23:10:16alex.rodassetfiles: - ZoomInOut.patch
2013-04-28 23:08:47alex.rodassetfiles: + ZoomInOut.patch

messages: + msg188030
2013-04-28 20:45:29Abhishek.Kumarsetfiles: + issue17642_patch.diff

nosy: + Abhishek.Kumar
messages: + msg188019

keywords: + patch
2013-04-28 18:22:09alex.rodassetnosy: + alex.rodas
messages: + msg188010
2013-04-19 22:43:30Todd.Rovitosetnosy: + Todd.Rovito
2013-04-12 17:27:46terry.reedysetnosy: + terry.reedy

messages: + msg186654
versions: - Python 3.1, Python 3.2
2013-04-06 16:45:52roger.serwysetnosy: + roger.serwy
messages: + msg186138
2013-04-06 12:33:01giampaolo.rodolasetnosy: + giampaolo.rodola
2013-04-06 07:06:45edmond.burnettsetnosy: + edmond.burnett
2013-04-06 06:06:25rhettingercreate