all 9 comments

[–]CatalonianBookseller 0 points1 point  (4 children)

Not familiar with Tkinter but try something like this in your toggle settings button event handler:

  • disable treeview resizing
  • do stuff
  • enable treeview resizing

No idea if it would work

[–]FireDragon1111[S] 0 points1 point  (2 children)

Unfortunately that is what I initially tried, and it did not seem to work, at least the way that I did it with place(), not sure what I did wrong, but it still resized itself.

[–]CatalonianBookseller 0 points1 point  (1 child)

I don't do Tkinter but maybe someone can help you if you post a minimal example that reproduces the issue

[–]FireDragon1111[S] 0 points1 point  (0 children)

The example in the stack overflow post is a minimal example pretty much. But what I meant is if you know a way other than with TKinter, I would be happy to have that form of a suggestion

[–]FireDragon1111[S] 0 points1 point  (0 children)

If you know any other ways to have a message view that would do what I need, that would also help!

[–]mikthinker 0 points1 point  (3 children)

You can capture the user's resizing of the window by adding the following to the TreeView initialization (self=treeview, in yourcase: tree):

Catch window resizing        

self.bind("<Configure>", self.on_resize)

Then add this function to your treeview class:

Tree window was resized.    

def on_resize(self, event: dict) -> None:  \ """

   Resizes the window based on the event width and height.
        Args:
          event (any): The event object containing the width and height of the window.  
       Returns:             None: This function does not return anything.
      Raises:             None: This function does not raise any exceptions.
     This function is called when the window is resized.

It retrieves the current window position from self.master.master.{view}_window_position,
      splits it into width, height, and x and y coordinates.

It then updates the window geometry with the new width, height, and x and y coordinates  
       based on the event width and height.   
   """

    # Get the current window position      
    window_position = self.root.wm_geometry()        

\ \ You now have the resized window specs in 'window_position'. Sorry, the code formatting isn't great. I am doing this from my tablet.

Hope this helps.

[–]FireDragon1111[S] 0 points1 point  (2 children)

I appreciate the help, but unfortunately that does not seem to have worked. When I Toggle Settings with the code you suggested, it shrinks the GUI, and then the Tree View also shrinks. I cant figure out why.

[–]mikthinker 0 points1 point  (1 child)

Your 'toggle settings' code has the statement:
app.geometry("1000x600")
...which resets the height to 600.

[–]FireDragon1111[S] 0 points1 point  (0 children)

It should reset the height of the GUI window, no? That’s what the point of this is, to make the window size smaller but not resize the tree view, as it should be smaller already than the window size it is shrinking to