Python Forum
[Tkinter] ttk-->treeview-->tag_configure() not work over Python3.6
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] ttk-->treeview-->tag_configure() not work over Python3.6
#1
Hi everyone, I am new comer of this forum.
I got a problem relate to the with the ttk treeview:
### With the Python 3.6.12 the ttk-->treeview-->tag_configure() work ok which it can change the background color expectedly.
### But with the Python3.7 or later, it not work with the same codes that work in Python3.6.12

What is the problem? who knows?
Reply
#2
Please show a code example containing the problem.
Point out the lines where colour attribute applied
Reply
#3
@Larz60+
#1, The Codes:
from tkinter import *
from tkinter import ttk

# create the app
root = Tk()
root.title("Treeview Test")

# Create pane window
panew = PanedWindow(root, bd=0, bg="#202322", sashwidth=2)
panew.pack(fill=BOTH, expand=1)

left_frame = Frame(root, bg="#383838")
tree = ttk.Treeview(left_frame)
tree["columns"] = ("first", "second")
tree.column("first", anchor="center")
tree.column("second")
tree.heading("first", text="first column")
tree.heading("second", text="second column")
tree.insert("", 0, "dir1", text="directory 1", open=True)
tree.insert("dir1", "end", "dir 1", text="file 1 1",values=("file 1 A", "file 1 B"))
id = tree.insert("", "end", "dir2", text="directory 2", open=True)
# set the tag for this item
tree.insert("dir2", "end", text="dir 2", values=("file 2 A", "file 2 B"), tags=('ttk'))
tree.insert(id, "end", text="dir 3", values=("val 1 ", "val 2"))
tree.insert("", 0, text="first line", values=("first line 1", "first line 2"))
# tag configuration
tree.tag_configure("ttk", background='yellow',foreground="red")

# Create scroller bar
ysb = ttk.Scrollbar(left_frame, orient=VERTICAL, command=tree.yview)
xsb = ttk.Scrollbar(left_frame, orient=HORIZONTAL, command=tree.xview)
tree['yscroll'] = ysb.set
tree['xscroll'] = xsb.set


root.configure(background='black')

tree.grid(in_=left_frame, row=0, column=0, sticky=NSEW)
ysb.grid(in_=left_frame, row=0, column=1, sticky=NS)
xsb.grid(in_=left_frame, row=1, column=0, sticky=EW)
left_frame.rowconfigure(0, weight=1)
left_frame.columnconfigure(0, weight=1)

panew.add(left_frame)

w = Text(panew)
panew.add(w)

ttk.Style().theme_use('clam')
print(ttk.Style().theme_names())

root.mainloop()
#2, result by "Python 3.6.12 :: Anaconda, Inc."
I don't know how to upload the screenshot.
But the result is the item with tag 'ttk' show what i expected

#2, result by "Python 3.8.3 (anaconda)"
The item with tag 'ttk' have no difference compare to other items.
Reply
#4
I'm running 3.9.1 and this script functions as written on my system. (Linux mint 20)

You should download a copy of John Shipman's tkinter reference manual here
This version from 2013 is the latest, but tkinter has changed little since then.

If you want to dig deeper (really not necessary but interesting), there's a three volume illustrated set TCP/IP illistrated (Addison-Wesley Professional Computing Series) that can be bought used on Amazon fairly inexpensively
Reply
#5
I am using Python 3.8.2 and I don't see any red or yellow when I click on items
Reply
#6
Thumbs Up 
(Jan-19-2021, 07:57 PM)deanhystad Wrote: I am using Python 3.8.2 and I don't see any red or yellow when I click on items

Yes, so I said it doesn't work over python3.6.
Actually for this example, it need not any click, when the window appear the "dir 2" should be red and yellow.
And I think its the tkinter's problem instead of python itself.
I don't know whether there guys still maintain the tkinker that integrated into the core of python. if there have, the better is to let them know the issue.
Anyway, thanks a lot.https://python-forum.io/images/icons/thumbsup.png
Reply
#7
Quote:Deanhystad wites:
I am using Python 3.8.2 and I don't see any red or yellow when I click on items

I'm using Linux Mint 20, and I see both red and yellow.
Is this perhaps OS related?

   
Reply
#8
Windows 10
Reply
#9
(Jan-20-2021, 01:10 AM)Larz60+ Wrote:
Quote:Deanhystad wites:
I am using Python 3.8.2 and I don't see any red or yellow when I click on items

I'm using Linux Mint 20, and I see both red and yellow.
Is this perhaps OS related?
I use Windows 10 + anaconda.
But as I said previous that when use python3.6 is OK, just as what your screenshot shows. but while use python 3.7 or later version, the effects gone!
Reply
#10
Sorry, failed to mention that I am running python 3.9.1 from python.org
Quote:I use Windows 10 + anaconda.
But as I said previous that when use python3.6 is OK, just as what your screenshot shows. but while use python 3.7 or later version, the effects gone!

Perhaps you should notify https://anaconda.org/contact/report.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] [split] Is there a way to embed a treeview as a row inside another treeview? CyKlop 5 3,301 Oct-20-2021, 12:14 AM
Last Post: CyKlop
  [Tkinter] Tkinter wouldn't work with python3.8.3 shay_xs 2 2,588 May-24-2020, 11:48 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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