0

I want to create a frameless resizable window, the problem is, when there are many widgets, they glitch when the window is resized using a Sizegrip. The only solution that I found that removes this glitch effect is to update the window during the resize. Unfortunately if you keep resizing for a few seconds a recursion error will occur and I have no idea why.

Here's my code

import tkinter as tk
from tkinter.ttk import Sizegrip


root = tk.Tk()
root.overrideredirect(True)
root.geometry("500x400")


def on_resize(event):
    global root
    root.update()



tk.Label(root, text = "Use the bottom right grip to resize, try for a few seconds").pack()

sg = Sizegrip(root)
sg.pack(side = tk.BOTTOM, anchor = tk.E)

sg.bind("<B1-Motion>", on_resize)

root.mainloop()
xWourFo
  • 35
  • 4
  • You don't need `global root` if you never assign to `root` in the function. – Barmar Nov 04 '22 at 21:33
  • Calling `update` is something that should almost never be done. See [Update considered harmful](https://wiki.tcl-lang.org/page/Update+considered+harmful) – Bryan Oakley Nov 04 '22 at 21:48
  • This code doesn't seem to even attempt to resize the window. Also, what do you mean by "they glitch"? – Bryan Oakley Nov 04 '22 at 21:49

1 Answers1

0

Check if you're already resizing and don't call root.update() again.

resizing = False

def on_resize(event):
    global resizing
    if not resizing:
        resizing = True
        root.update()
        resizing = False
Barmar
  • 741,623
  • 53
  • 500
  • 612