Siento tardar en reabrir el tema, pero me ha costado encontrar la solución.
Al parecer es un problema de actualizar tk a la version 8.6.9.
donde indican como solucionarlo. Al menos provisionalmente ya que espero que Tk los solucionen en un futuro. Mientras tanto si alguien tiene el mismo problema os dejo la solución aquí.
Código:
from tkinter import *
import tkinter as tk
from tkinter import ttk
from datetime import *
import time
import calendar
class Treeviewr:
def __init__(self):
# MAIN WINDOW
self.root = Tk()
self.root.title("PRUEBAS")
self.root.geometry()
# PANEL 1
self.caj1 = ttk.Frame(self.root)
self.caj1.grid(row=0, column=0)
# PANEL 2
self.caj2 = ttk.Frame(self.root)
self.caj2.grid(row=1, column=1)
#STYLES TREEVIEW
self.styletree= ttk.Style()
self.styletree.configure('T.Treeview')
def fixed_map(option): # Esto justo antes del Treeview y funciona todo perfectamente.
return [elm for elm in style.map('Treeview', query_opt=option) if elm[:2] != ('!disabled', '!selected')]
style = ttk.Style()
style.map('Treeview', foreground=fixed_map('foreground'), background=fixed_map('background'))
# TREEVIEW
self.info = ttk.Treeview(self.caj1, style='T.Treeview', columns=('col1', 'col2', 'col3', 'col4'))
self.info.grid(row=0, column=0, ipadx=200)
self.info.insert("", tk.END, text='Prueba0', values=('18', 'Juan'), tags=('prob',))
self.info.insert("", tk.END, text='Prueba1', values=('20', 'Adrián'), tags=('prob',))
self.info.insert("", tk.END, text='Prueba2', values=('23', 'Felipe', '3'), tags=('prob',))
self.info.tag_configure('prob', background='black', foreground='red')
self.info.heading("#0", text='COLUMNA1')
self.info.heading('col1', text='COLUMNA2')
self.info.heading('col2', text='COLUMNA3')
self.info.heading('col3', text='COLUMNA4')
self.info.heading('col4', text='COLUMNA5')
self.info.column("#0", minwidth=0, width=5)
self.info.column('col1', minwidth=25, stretch=0, anchor='center')
self.info.column('col2', minwidth=25, stretch=0, anchor='center')
self.info.column('col3', minwidth=25, stretch=0, anchor='center')
self.info.column('col4', minwidth=25, stretch=0, anchor='center')
self.root.mainloop()
def main():
my_app = Treeviewr()
if __name__ == '__main__':
main()