Tk Source Code

View Ticket
Login
Ticket UUID: 3733b924a2c3d5df2607fbcde54eb0c3bca19cd1
Title: Window not resizing on KDE
Type: Bug Version: 8.6
Submitter: anonymous Created on: 2024-04-25 13:25:09
Subsystem: 84. Unix Build Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2024-05-05 19:48:22
Resolution: None Closed By: nobody
    Closed on:
Description:
I develop a library using tkinter and a people report me a bug with the window size on Fedora using KDE as desktop.

I tested, and the bug seems to only appear on linux distro using KDE.
As you can see in this video, the window not resizing automatically when a widget, like a Frame in this context, is resized with ``widget.config(width=..., height=...)`` function: 

https://github.com/ZetaMap/Kandinsky-Numworks/assets/56844734/e06fd90e-cd19-478d-9063-d9f59f57073b

idk how the bug works because in the video, I tested saving a file and... it works very well so idk...
Anyway, I tested all the ways to change the window size, and only the ``root.configure()`` function works to change the window size, but it's not really practical...

There is the source code of my library, if you want to test other things: https://github.com/ZetaMap/Kandinsky-Numworks
All tkinter things are in the ``src/kandinsky/util/stuff/gui.py`` file.
To install the library in local, run this command: ``git clone https://github.com/ZetaMap/Kandinsky-Numworks && cd Kandinsky-Numworks && chmod +x setup && yes | ./setup``.
To install by pypi way: ``pip3 install --pre kandinsky ion-numworks``, and you can test with the demo game by running: ``python3 -m kandinsky``

So, as i say, the bug only appears on KDE desktop, and it doesn't matter whether Wayland or X11 is used.
Also idk if we can find a temporary fix for me, this will save me from making a dependency on a new version, if it's really a bug.

So thanks for your reply, and have a nice day =).
User Comments: anonymous added on 2024-05-05 19:48:22:
so, we can do anything? this a KWin problem? I need to report this bug to his support?

erikleunissen added on 2024-05-05 07:49:58:
That's indeed the logical question, that I intended to steer towards.

Short answer:
I'd consider this case as a KWin shortcoming (possibly a bug) that is not for Tk
to address.

Long answer:
In general, different window managers may behave somewhat differently when it
comes to details, especially regarding the timing of certain notifications
(= window events). There is a tricky grey area where it's difficult to say
whether that a window manager is "wrong", but in that tricky area, there are
always multiple window managers that perform less adequately.

However, the present case doesn't qualify for such nuance IMO:
- it is really the the *ONLY* window manager standing out, when compared to all
  other window managers;
- this doesn't look like a timing issue, or a detail otherwise.

On a side note: in my experience, especially with the detailed testing of a new
edition of the package windetect (not yet published at
https://sourceforge.net/projects/tkwintrack/), KWin is "off" in several other
respects, and personally I don't judge KWin suitable as a standard for testing
Tk with, even though KDE is also my preferred desktop environment (but
definitely not for the quality of its default window manager).

fvogel added on 2024-05-04 21:23:19:
Thanks for these tests! Isn't the logical conclusion that this is not a Tk bug but a KWin bug?

erikleunissen added on 2024-05-04 21:09:57:
Just ran the minimal script in the following environments on Linux X11:

A. with these window managers:

   e16 Fluxbox fvwm IceWM KWin Metacity Openbox TWM WindowMaker Xfwm4

   All of them without desktop environment, just the window manager

B. without any window manager or desktop environment, just the raw X server

C. with the KDE desktop using openbox as the window manager (note: instead of KWin)

Only for case A. with KWin, the root window did not resize as expected.
So, it's the KWin window manager that's misbehaving, not the KDE desktop environment.

anonymous added on 2024-05-04 17:17:12:
Same, randomly working. (On Fedora Kinoite using KDE)

fvogel added on 2024-05-03 19:15:46:

Minimum script:

package require Tk
frame .f1 -bg red
frame .f2 -bg blue
pack .f1 .f2
update
.f1 configure -width 200 -height 300
.f2 configure -width 100 -height 200

Running this on Debian 11 with KDE, the . window is not the right height.

Workaround: add an 'update' just after the first line:

package require Tk
update
frame .f1 -bg red
frame .f2 -bg blue
pack .f1 .f2
update
.f1 configure -width 200 -height 300
.f2 configure -width 100 -height 200


fvogel added on 2024-05-03 18:23:15:
BTW, not random for me. Always wrong size.

fvogel added on 2024-05-03 18:22:48:
Reproduced on Linux Debian 11 running KDE, with the Tcl script provided by Emiliano. So this is not a tkinter bug.

Very strange. No clue so far.

anonymous added on 2024-05-03 16:26:05:
Issue also related to python support: https://github.com/python/cpython/issues/118554


It's same, randomly working.

emiliano added on 2024-05-03 15:44:42:

To discard something in the tkinter interface or the Tk version bundled, try escaping directly to the Tcl version with the eval method:

import tkinter

script = '''
    #THIS IS YOUR SCRIPT IN TCL
    package require Tk
    # Create things
    frame .f1
    frame .f2
    # Pack everything
    pack .f1
    pack .f2
    update
    wm resizable . 0 0
    # Set default size
    .f1 configure -width 200 -height 300
    .f2 configure -width 100 -height 200
    update
    # Sleep a little
    after 2000
    # And change the frame size
    wm resizable . 0 0
    .f1 configure -width 500 -height 100
    .f2 configure -width 300 -height 100
    update
'''
root = tkinter.Tk()
root.eval(script)
root.mainloop()

Please try and report. Also, you can copy the Tcl script to a file and run

$ tclsh script.tcl

to see whether it makes any difference.


oehhar added on 2024-05-03 15:33:19:

Yes, it is hard for the folks on this side to understand.

Normally, by setting a discrete size, you say "this size".

I suppose, the "root.resizable(0,0)" enables/disables windows decoration for resizing for the window. I suppose, your 2nd "root.resize" should have parameters (1,1).

To my experience, the fact if a window manager may change size is controlled if an explicit size is active.

Thus, after "f1.config(width=500,height=100)" there should be a command added to make resizing possible again.

AFAIK, it might be the window managers responsability to honor this or not. It is also highly platform dependent...

Take care, Harald


anonymous added on 2024-05-03 15:06:17:
mmm yea the markdown formatting doesn't work.

anonymous added on 2024-05-03 15:04:41:

O yea ok... not very practical, but anyway.

So, i made a little script for that : ```python import tkinter, time

Create things

root = tkinter.Tk() f1 = tkinter.Frame(root) f2 = tkinter.Frame(root)

Pack everything

f1.pack() f2.pack() root.update() root.resizable(0,0)

Set default size

f1.config(width=200, height=300) f2.config(width=100, height=200) root.update()

Sleep a little

time.sleep(2)

And change the frame size

root.resizable(0,0) f1.config(width=500, height=100) f2.config(width=300, height=100) root.update()

root.mainloop() ``` it will: create the main window, create frames, disable resizing by user, change the size of frames, wait a little, enable resizing by user, and change another time the frames size.

And if you test this on a linux distro using KDE, it will work randomly and sometimes, only the width axis is resized.

But i minding, this is probably not this place to report the bug. As i see, this is only about Tcl/Tk languague, not the wrapped version of python to make GUI. So idk if anyone can help me.


anonymous added on 2024-05-03 14:56:24:
mmmm how comments work....

fvogel added on 2024-05-01 15:30:07:
Spent an hour on this trying to understand the problem, look at the code and so on. The bar is a bit high I think for being able to reproduce and analyze (e.g.: I don't know Python). A short demo script in Tcl/Tk language would be needed for me to further analyze this, sorry.

oehhar added on 2024-04-25 16:03:11:

I hope, magic Wizards like Csaba will answer.

In the meanwhile some general hints from a MS-Windows only TCL/Tk user.

If a window is programmatically resized:

wm geometry . 500x200+100+100

it will try to keep this size.

If it is set to free resize, it may do so:

update
wm geometry . ""

Take care, Harald