Python Forum
[Tkinter] How to restrict a ttk.PanedWindow's sash?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to restrict a ttk.PanedWindow's sash?
#1
Here is the MRP code of the situation:
def enforce_sash_limits(self, event):
    self.main_paned_win.sashpos(0, 120)

def init_pagebrowser(self):
    self.main_paned_win = ttk.PanedWindow(self.pages_area_frame, orient=tk.HORIZONTAL) 
    self.slides_pane = tk.Frame(self.main_paned_win, bg=colorconsts.BG_COLOR)
    self.slides_pane.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
    self.main_paned_win.add(self.slides_pane, weight=3)
    self.preview_pane = tk.Frame(self.main_paned_win, bg="magenta")
    self.preview_pane.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
    self.main_paned_win.add(self.preview_pane, weight=2)
    self.main_paned_win.pack(fill=tk.BOTH, expand=True)
    self.slides_area_class = SlidesArea(self.slides_pane)
    self.slides_area_class.pack(fill=tk.BOTH, expand=True)
    self.main_paned_win.bind("\<B1-Motion\>", self.enforce_sash_limits) #<-----
I expected that everytime I drag the sash, the sash would fix itself to a specific position. But it doesnt and just lets itself be dragged into whatever it likes. How to solve this? I dont want to switch to tk.PanedWindow because I had layering issues with that one.

For that matter, is there a(nother) way to restrict sash movement? (The code above would be modified to make the GUI user not shrink the left pane too much with a minimum width if it worked)

If that's helpful, I am in Fedora Worksation 41.
Reply
#2
I don't think you can stop the handle from moving anywhere while dragging, but you can set the sash position when the button is released.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Panedwindow rfresh737 2 3,558 Apr-03-2021, 03:40 PM
Last Post: rfresh737
  [Tkinter] Need help please properly putting tabs within a PanedWindow JackMack118 2 4,493 Dec-08-2019, 03:02 PM
Last Post: balenaucigasa
  [Tkinter] How to restrict characters used in an Entry widget? Nwb 2 20,286 Jun-20-2018, 12:55 PM
Last Post: Nwb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020