You are not logged in.

#1 2018-12-04 16:44:14

lycos
Member
Registered: 2013-02-01
Posts: 13

[SOLVED] Python Treeview widget problem only at arch

I am writing a program with Python using tkinter for GUI and I noticed that the Treeview widget
cannot paint the rows with color. I am using Python 3.7.1 but I don't think its a python bug because
the same version works fine with Linux Mint 19 and Windows. I also tried the Python versions 3.6 and 3.5 from aur
and they also have problem with Treeview.

I am using arch with cinnamon and I tried it also with xfce  (in a virtualbox).

Is there anything to do to fix it?


I wrote a script to check it:

from tkinter import *
from tkinter import ttk

name_list = ('George', 'Maria', 'Peter', 'Nick')
surname_list = ('Lycos', 'Ntou', 'Wolf', 'Stath')
telephone_list = ('6950 123123', '6950 123456', '6951 025458', '6970 985214')
root = Tk()
root.title('Treeview')
root.configure(background='Yellow Green')

ttk.Label(root, text='There must be colors at some rows:', font=('DejaVu Sans', 11, 'bold'), background= 'yellow green').grid(row=0, column=0)
tree = ttk.Treeview(root, columns=('name', 'surname', 'telephone'))
tree.grid(row=1, column=0)
ttk.Button(root, text='Exit', command=root.destroy).grid(row=3, column=0, pady=10)
tree.heading('#0', text='Α/Α')
tree.heading('name', text='Name')
tree.heading('surname', text='Surname')
tree.heading('telephone', text='Telephone')

tree.column('#0', width=50)
tree.column('telephone', anchor='center')

for i, (name, surname, telephone) in enumerate(zip(name_list, surname_list, telephone_list), start=1):
    if i % 2 != 0:
        tree.insert(parent='', index='end', iid=str(i), text=str(i), values=(name, surname, telephone))
    else:
        tree.insert(parent='', index='end', iid=str(i), text=str(i), tags = 'paint', values=(name, surname, telephone))

tree.tag_configure(tagname='paint', background='yellow2')
root.mainloop()

The result in Linux Mint 19:
https://i.imgur.com/ovrp2yf.png

The result in arch:
https://i.imgur.com/tKXs1he.png

Last edited by lycos (2019-02-15 14:49:43)

Offline

#2 2018-12-04 16:55:27

headkase
Member
Registered: 2011-12-06
Posts: 1,840

Re: [SOLVED] Python Treeview widget problem only at arch

The problem may be Python, but it's more likely to be tk as that does the rendering.  Also, you have two imports.  One imports the wildcard * and the other imports a specific name.  Since you have the wildcard first doesn't that make the specific name redundant?

Offline

#3 2018-12-04 16:58:17

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 27,491
Website

Re: [SOLVED] Python Treeview widget problem only at arch

Read the Code of Conduct and only post thumbnails http://wiki.archlinux.org/index.php/Cod … s_and_code


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#4 2018-12-04 17:11:49

headkase
Member
Registered: 2011-12-06
Posts: 1,840

Re: [SOLVED] Python Treeview widget problem only at arch

Hey, make sure you have the *exact* same environment theme too between Mint and Arch.  If you change your Arch theme do you get different results?

Last edited by headkase (2018-12-04 17:12:37)

Offline

#5 2018-12-04 17:26:35

lycos
Member
Registered: 2013-02-01
Posts: 13

Re: [SOLVED] Python Treeview widget problem only at arch

headkase wrote:

The problem may be Python, but it's more likely to be tk as that does the rendering.  Also, you have two imports.  One imports the wildcard * and the other imports a specific name.  Since you have the wildcard first doesn't that make the specific name redundant?

The first line imports the tk widgets and the second import the ttk widgets. Most tutorials imports like this but a better and more clear way to do this is:

import tkinter as tk
from tkinter import ttk 

or even:

from tkinter import *
import tkinter.ttk as ttk

Last edited by lycos (2019-02-19 09:17:27)

Offline

#6 2018-12-04 17:29:56

lycos
Member
Registered: 2013-02-01
Posts: 13

Re: [SOLVED] Python Treeview widget problem only at arch

headkase wrote:

Hey, make sure you have the *exact* same environment theme too between Mint and Arch.  If you change your Arch theme do you get different results?

To be honest I thought that and I changed some options of my theme. But I don't have the same theme and that's the reason why I tried it also with arch xfce (with a Virtualbox). But it can be a theme problem..

Offline

#7 2018-12-04 17:30:33

lycos
Member
Registered: 2013-02-01
Posts: 13

Re: [SOLVED] Python Treeview widget problem only at arch

jasonwryan wrote:

Read the Code of Conduct and only post thumbnails http://wiki.archlinux.org/index.php/Cod … s_and_code

Sorry (and thanks for  fixing it)

Offline

#8 2019-01-03 22:50:57

Pythonista
Member
Registered: 2019-01-03
Posts: 1

Re: [SOLVED] Python Treeview widget problem only at arch

Hi, I've (sort of) found a work-around.
After comparing files in (Arch)/usr/lib/tk8.6/ with their Linux Mint counterparts in (MINT)/usr/share/tcltk/tk8.6/ (with graphical diff tool meld) I found that TreeView widget colors do work as expected when /usr/lib/tk8.6/ttk/defaults.tcl is replaced with the Ubuntu version. Of course this is just an ugly work-around until the Arch version is fixed.

Unfortunately I don't have enough time nor TCL skills to track the problem further down but I've sent an email to the Arch package maintainer.

Hope it helps.

Offline

#9 2019-02-15 14:47:21

lycos
Member
Registered: 2013-02-01
Posts: 13

Re: [SOLVED] Python Treeview widget problem only at arch

Pythonista wrote:

Hi, I've (sort of) found a work-around.
After comparing files in (Arch)/usr/lib/tk8.6/ with their Linux Mint counterparts in (MINT)/usr/share/tcltk/tk8.6/ (with graphical diff tool meld) I found that TreeView widget colors do work as expected when /usr/lib/tk8.6/ttk/defaults.tcl is replaced with the Ubuntu version. Of course this is just an ugly work-around until the Arch version is fixed.

Unfortunately I don't have enough time nor TCL skills to track the problem further down but I've sent an email to the Arch package maintainer.

Hope it helps.


You are right! Thank you. It works again!
For me your work-around is a 100% fix...

The default.tcl file differs only to the treeview part (arch one has some disable commands....)

Last edited by lycos (2019-02-15 14:51:41)

Offline

Board footer

Powered by FluxBB