Tkinter Treeview issue when inserting rows with tags

前端 未结 4 1210
臣服心动
臣服心动 2021-01-20 08:10

I have just switched from python 3.6 to python 3.7. I have a function which inserts rows in a Treeview tree with tags. The tags are used for giving a foreground color and a

4条回答
  •  温柔的废话
    2021-01-20 08:24

    In my app I use folloiwng approach:

    self._my_tree.tag_configure('mygray', background='#DCDCDC')
    
    for router in routers_list:
        self._my_tree.insert('', 'end', router['id'], text=str(router['id']),
                             values=(
                                 name,
                                 router['location'],
                                 router['ip'],
                                 router['model'],
                                 router['phone_num'],
                                 router['provider']
                             )
                             )
    
        self._my_tree.item(router['id'], tags='mygray')
    

    Try using tags instead of tag

提交回复
热议问题