0

I would like to display a list of about 2500 fonts with 2 columns. Column 1 with the font name and column 2 with a sample text styled with the font named in column 1 for that row.

I am trying to use tkinter treeview to do this. I saw a similar question asked here but the answer that was given only applied to column headers.

I am also open to suggestions for other widget structures to accomplish this.

juxpin
  • 3
  • 3
  • 1
    Change the [font](https://tcl.tk/man/tcl8.6/TkCmd/ttk_treeview.htm#M75) attribute by applying a tag to the column and then [configuring the tag](https://python-forum.io/thread-36550.html). – Alias Cartellano Jun 21 '22 at 19:55
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 22 '22 at 08:28

1 Answers1

0
for font_name in font_list:
    # create a tag for each font name in the list
    # the name of the font is the name of the tag
    my_treeview.tag_configure(font_name, font=font_name)
    # insert items into the treeview using the font_name tags
    my_treeview.insert(
        '',
        tk.END,
        values=(font_name, sample_text),
        tags=[font_name]
    )
    # the caveat here is that both columns will be in the new font
JRiggles
  • 4,847
  • 1
  • 12
  • 27
  • Thanks for your answer but if it doesn't give me control over individual cells it doesn't help me. – juxpin Jun 22 '22 at 20:10
  • No worries. Unfortunately I don't know if there is a way to accomplish what you're after. I suppose you could cheat and put two treeview widgets next to each other and bind them to the same scrollbar, but that's admittedly a hack. – JRiggles Jun 22 '22 at 21:53