I have a tkinter PanedWindow containing some widgets and I want the user to be able to drag each separator to a certain position and when they let go of the mouse button, the separator should "snap" to the nearest position in a list of positions / proportions I give the program. For example, let's say I have a PanedWindow containing two buttons, and I want the user to be able to resize the buttons such that they can be in the proportions 1/4:3/4, 1/2:1/2 or 3/4:1/4 not just any width the user chooses. Is there a way I can do this? Code for PanedWindow with two buttons:
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.geometry("400x400")
pw = tk.PanedWindow(root)
buttons = [ttk.Button(text=message) for message in ["goose", "duck"]]
for button in buttons:
pw.add(button)
pw.pack(expand=True, fill="both")
root.mainloop()
Is there a way to specify the proportions the separators can snap to?
Allowed positions:
The buttons should snap to the nearest of these positions when resized.


