GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Tkinter text widget scrolling uncontrollably under Wayland · Issue #131029 · python/cpython

Tkinter text widget scrolling uncontrollably under Wayland #131029

New issue
Copy link
New issue
Copy link
Open
Open
Tkinter text widget scrolling uncontrollably under Wayland#131029
Copy link
Labels
OS-linuxstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@johnohagan
johnohagan
opened on Mar 10, 2025
Issue body actions

Bug report

Bug description:

On Gnome with Wayland (current Debian testing), resizing a Tk root window to increase the height causes a contained Text widget to scroll uncontrollably to the bottom of the widget. If the widget is scrolled while this is happening, it keeps scrolling back to the bottom.

Resizing the window again by decreasing the height or changing the width, or clicking inside the text widget, usually stops the issue.

This happens with both the mouse scrollwheel and the tkinter scrollbar.

This doesn't happen on Gnome using X, or on Windows 10. I haven't tested on any other systems.

Minimal example:


from tkinter import *
from random import choice
from string import ascii_letters

root = Tk()
textwidget = Text(root)

for i in range(1000):
    textwidget.insert(END, f'{choice(ascii_letters)} ')

textwidget.pack(fill=BOTH, expand=True)
mainloop()

A screen-recording is attached using the above code and showing the issue, which occurs the third time the window is resized.

Screencast.From.2025-03-10.13-20-57.mp4

I have no idea how to debug this in more depth, any suggestions welcomed.

CPython versions tested on:

3.13

Operating systems tested on:

Linux, Windows

Activity

  1. johnohagan
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 10, 2025
  2. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-tkinter
    on Mar 10, 2025
  3. johnohagan commented on Apr 6, 2025

    @johnohagan
    johnohagan
    on Apr 6, 2025
    Author
    More actions

    I found a workaround: the uncontrolled scrolling is prevented by binding the '' event of the text widget to a function that returns the string 'break', which AIUI prevents default event propagation. Hopefully this is a clue about why it is happening?

  4. terryjreedy
    added
    OS-linux
    on Apr 6, 2025
  5. terryjreedy commented on Apr 6, 2025

    @terryjreedy
    terryjreedy
    on Apr 6, 2025
    Member
    More actions

    A more minimal example would be to replace the imports and loop with something like textwidget.insert(END, 'a b c d e f '*150). Either way, the text widget ends up with 1 long line, which is wrapped by default. On Windows, I don't see any auto scrolling. Perhaps Wayland prefers showing last physical line of a single wrapped line.

    I do not understand '' event. What is the actual bind call?

    I strongly suspect that this is a bug or anomaly in the interaction of Wayland and tk, and that tkinter has nothing to do with the bahavior. Once mainloop is called, tkinter is not involved. So this should likely be closed.

  6. johnohagan commented on Apr 7, 2025

    @johnohagan
    johnohagan
    on Apr 7, 2025
    Author
    More actions

    I used a random letter sequence so that the effect of the wrapping is easier to see.

    Note that the unwanted scrolling doesn't occur on Windows for me either.

    Regarding the event, I wrote '<Leave>' but didn't realise I needed to escape the '<>' characters. My apologies. The additional code was:

    textwidget.bind('<Leave>', lambda x: 'break')

  7. ThingamabobsCoding commented on Feb 21, 2026

    @ThingamabobsCoding
    ThingamabobsCoding
    on Feb 21, 2026
    More actions

    This looks a lot like the window manager posting weird events to tkinter.
    Watching your video shows that when you stop resizing the window a "<B1-Motion>" event is performed as described in the manpage in section bindings:

    If the mouse is dragged out of the widget while button 1 is pressed, the entry will automatically scroll to make more text visible (if there is more text off-screen on the side where the mouse left the window).
    https://www.tcl-lang.org/man/tcl/TkCmd/text.html#M192

    Weirdly enough, you show how you resize the window to increase the width afterwards and no event gets posted, which also should stop this.

  8. ThingamabobsCoding commented on Mar 2, 2026

    @ThingamabobsCoding
    ThingamabobsCoding
    on Mar 2, 2026
    More actions

    Note that there is no wayland support for tk

    https://core.tcl-lang.org/tk/tktview/3f58c0871c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-linuxstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.