Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDLE add font resizing hot keys and wheel #61842

Open
rhettinger opened this issue Apr 6, 2013 · 18 comments
Open

IDLE add font resizing hot keys and wheel #61842

rhettinger opened this issue Apr 6, 2013 · 18 comments
Assignees
Labels
topic-IDLE type-feature A feature request or enhancement

Comments

@rhettinger
Copy link
Contributor

BPO 17642
Nosy @rhettinger, @terryjreedy, @taleinat, @giampaolo, @serwy, @roseman, @rovitotv, @ZackerySpytz
PRs
  • gh-61842: Add hotkeys to resize IDLE's font #17107
  • Files
  • issue17642_patch.diff
  • ZoomInOut.patch
  • ZoomInOut.patch2
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = None
    created_at = <Date 2013-04-06.06:06:25.800>
    labels = ['expert-IDLE', 'type-feature', '3.8', '3.9']
    title = 'IDLE add font resizing hot keys and wheel'
    updated_at = <Date 2019-11-17.11:41:47.679>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2019-11-17.11:41:47.679>
    actor = 'taleinat'
    assignee = 'terry.reedy'
    closed = False
    closed_date = None
    closer = None
    components = ['IDLE']
    creation = <Date 2013-04-06.06:06:25.800>
    creator = 'rhettinger'
    dependencies = []
    files = ['30051', '30074', '30251']
    hgrepos = []
    issue_num = 17642
    keywords = ['patch']
    message_count = 18.0
    messages = ['186118', '186138', '186654', '188010', '188019', '188030', '188031', '188124', '188128', '189141', '189195', '226328', '273687', '273978', '273979', '350259', '350320', '356413']
    nosy_count = 12.0
    nosy_names = ['rhettinger', 'terry.reedy', 'taleinat', 'giampaolo.rodola', 'roger.serwy', 'markroseman', 'Todd.Rovito', 'python-dev', 'edmond.burnett', 'alex.rodas', 'Abhishek.Kumar', 'ZackerySpytz']
    pr_nums = ['17107']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue17642'
    versions = ['Python 3.8', 'Python 3.9']

    @rhettinger
    Copy link
    Contributor Author

    Add the standard hot keys for resizing fonts (i.e. on a Mac, CMD-plus and CMD-minus).

    @rhettinger rhettinger added easy topic-IDLE type-feature A feature request or enhancement labels Apr 6, 2013
    @serwy
    Copy link
    Mannequin

    serwy mannequin commented Apr 6, 2013

    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 bpo-17535 would likely need to rely on this font size broadcasting as well.

    @terryjreedy
    Copy link
    Member

    On Windows, cntl-+. cntl--

    Could we use the tk event system by defining font change events and event handlers?

    @alexrodas
    Copy link
    Mannequin

    alexrodas mannequin commented Apr 28, 2013

    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.

    @AbhishekKumar
    Copy link
    Mannequin

    AbhishekKumar mannequin commented Apr 28, 2013

    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.

    @alexrodas
    Copy link
    Mannequin

    alexrodas mannequin commented Apr 28, 2013

    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?

    @alexrodas
    Copy link
    Mannequin

    alexrodas mannequin commented Apr 28, 2013

    Sorry, I submitted a patch which only works on Windows. This one has been tested on Ubuntu too.

    @serwy
    Copy link
    Mannequin

    serwy mannequin commented Apr 30, 2013

    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.

    @AbhishekKumar
    Copy link
    Mannequin

    AbhishekKumar mannequin commented Apr 30, 2013

    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.

    @alexrodas
    Copy link
    Mannequin

    alexrodas mannequin commented May 13, 2013

    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.

    @serwy
    Copy link
    Mannequin

    serwy mannequin commented May 14, 2013

    @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.

    @terryjreedy
    Copy link
    Member

    python/issues-test-cpython#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 bpo-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.

    @terryjreedy terryjreedy removed the easy label Sep 3, 2014
    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy terryjreedy changed the title IDLE add font resizing hot keys IDLE add font resizing hot keys and wheel Aug 25, 2016
    @terryjreedy terryjreedy assigned terryjreedy and unassigned serwy Aug 25, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 31, 2016

    New changeset f478f9b88319 by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-17642: add larger font sizes for classroom projection.
    https://hg.python.org/cpython/rev/c9d59e6cc1e4

    @terryjreedy
    Copy link
    Member

    I intend to backport the simple list expansion to 3.5. Key or wheel patches will probably be 3.6 only.

    @rhettinger
    Copy link
    Contributor Author

    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?

    @rhettinger rhettinger added 3.8 only security fixes 3.9 only security fixes labels Aug 23, 2019
    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    bpo-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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @erlend-aasland erlend-aasland removed 3.9 only security fixes 3.8 only security fixes labels Mar 3, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-IDLE type-feature A feature request or enhancement
    Projects
    Status: In Progress
    Development

    No branches or pull requests

    3 participants