Skip to content

Treeview with fixed column widths has extra space on right. #20

@noahblumADS

Description

@noahblumADS

I've encountered a strange issue while using your theme. I use the ttk Treeview widget as a Listbox replacement (as the Listbox does not exist in ttk) for a program I write. However, when modifying my Treeview widget to have fixed width columns, there is always an extra space on the right of the last column.

This only happens while Azure is in use, and does not happen with the default themes.

While yes, the space does disappear when stretch=True for any of the columns, I do not want my columns to stretch (due to another weird unrelated issue where Treeview columns will expand infinitely when a specific widget is rendered in another window... yeah I know).

I have included a very short code snippet that reproduces my error, and have included screenshots showing my issue.

About my PC

I am running Windows 10 with Python 3.9.9
I am using Azure version 2.0 - png based branch

If there is anything else I can do or any other information I can provide, please let me know!

I have tried many things to remove this extra space, but I'm honestly not sure what is causing it. There is always the possibility that I am wrong, and this is not an issue with your theme, in which case I would be more than happy to be pointed in the right direction.

Code

import tkinter
from tkinter.ttk import Treeview, Style

root = tkinter.Tk()

# Comment out both for default theme
# Uncomment for Azure Theme
root.tk.call('source', ".\\script\\themes\\azure.tcl")    # Obviously would need to point to theme files
root.tk.call("set_theme", "light")    # Switch to dark for same result

# Uncomment for clam theme
# root.style = Style()
# root.style.theme_use("clam")

tv = Treeview(root, columns=('1', '2', '3'))
tv.pack(padx=20, pady=20)

tv.heading('1', text="Column 1")
tv.heading('2', text="Column 2")
tv.heading('3', text='Column 3')

tv.column('#0', minwidth=0, width=0, stretch=False)
tv.column("1", minwidth=350, width=350, stretch=False)
tv.column("2", minwidth=150, width=150, stretch=False)
tv.column("3", minwidth=75, width=75, stretch=False)

root.mainloop()

With default theme

image

With clam theme

image

With Azure Theme

image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions