Python Forum
[Tkinter] Treeview expand button size
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Treeview expand button size
#7
I have tried by referring the example https://stackoverflow.com/questions/1652...pect-ratio
but still the expandbutton has no change in size.

This is my code
import tkinter as tk
from ttkwidgets import CheckboxTreeview
#from Tkconstants import *
r=tk.Tk()

def set_aspect(content_frame, pad_frame, aspect_ratio):
    # a function which places a frame within a containing frame, and
    # then forces the inner frame to keep a specific aspect ratio

    def enforce_aspect_ratio(event):
        # when the pad window resizes, fit the content into it,
        # either by fixing the width or the height and then
        # adjusting the height or width based on the aspect ratio.

        # start by using the width as the controlling dimension
        desired_width = event.width
        desired_height = int(event.width / aspect_ratio)

        # if the window is too tall to fit, use the height as
        # the controlling dimension
        if desired_height > event.height:
            desired_height = event.height
            desired_width = int(event.height * aspect_ratio)

        # place the window, giving it an explicit size
        content_frame.place(in_=pad_frame, x=0, y=0, 
            width=desired_width, height=desired_height)

    pad_frame.bind("<Configure>", enforce_aspect_ratio)

pad_frame = tk.Frame(borderwidth=0, background="bisque", width=200, height=200)
pad_frame.grid(row=0, column=0, sticky="nsew", padx=10, pady=20)
content_frame=tk.Frame(r,borderwidth=5,relief="groove", background="blue")
tk.Label(content_frame,text='content').pack()
set_aspect(content_frame, pad_frame, aspect_ratio=2.0/1.0) 
tree = CheckboxTreeview(content_frame, selectmode = "extended", show="tree", padding=25)
tree.pack(fill='both')
r.rowconfigure(0, weight=1)
r.columnconfigure(0, weight=1)

tree.insert("", "end", "1", text="1")
tree.insert("1", "end", "11", text="11")
tree.insert("1", "end", "12",  text="12")
tree.insert("11", "end", "111", text="111")
tree.insert("", "end", "2", text="2")

r.mainloop()
Reply


Messages In This Thread
Treeview expand button size - by shamnadinn - Mar-05-2020, 09:39 AM
RE: Treeview expand button size - by Larz60+ - Mar-05-2020, 03:58 PM
RE: Treeview expand button size - by shamnadinn - Mar-05-2020, 05:27 PM
RE: Treeview expand button size - by Larz60+ - Mar-05-2020, 09:44 PM
RE: Treeview expand button size - by shamnadinn - Mar-06-2020, 09:43 AM
RE: Treeview expand button size - by Larz60+ - Mar-06-2020, 10:33 AM
RE: Treeview expand button size - by shamnadinn - Mar-08-2020, 06:58 AM
RE: Treeview expand button size - by Larz60+ - Mar-08-2020, 09:27 AM
RE: Treeview expand button size - by shamnadinn - Mar-08-2020, 12:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Search data in treeview without search button TomasSanchexx 3 1,821 Aug-12-2023, 03:17 AM
Last Post: deanhystad
  [Tkinter] [split] Is there a way to embed a treeview as a row inside another treeview? CyKlop 5 3,550 Oct-20-2021, 12:14 AM
Last Post: CyKlop
  [Tkinter] Trying to change font size w/o changing button size python63 3 10,098 Aug-05-2020, 01:04 AM
Last Post: Larz60+
  [PyGUI] Expand last sub-node of treeview widget mart79 1 2,189 Apr-25-2020, 07:57 PM
Last Post: mart79
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,138 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] Not getting entry values on button click & treeview not updating ? swanysto 4 7,212 May-10-2019, 04:16 PM
Last Post: swanysto
  [Tkinter] Treeview automatically adjust it's size when pack inside frame Prince_Bhatia 1 28,264 Jul-25-2018, 03:24 AM
Last Post: Larz60+
  PyGtk3 why is Locale Folder Size Half of Module Size ? harun2525 1 3,720 Mar-09-2017, 03:46 AM
Last Post: Analyser

Forum Jump:

User Panel Messages

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