Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 特金特树景风格_Python_Tkinter_Treeview_Ttk_Ttkwidgets - Fatal编程技术网

Python 特金特树景风格

Python 特金特树景风格,python,tkinter,treeview,ttk,ttkwidgets,Python,Tkinter,Treeview,Ttk,Ttkwidgets,为什么我的桌子没有按照我的定义改变样式? 我尝试使用样式和地图,但没有改变任何东西。 似乎唯一有效的是主题配置。 此外,滚动条不会显示在树视图中 from tkinter import * from tkinter import ttk class Dashboard: def __init__(self, filterdDf): self.filterdDf = filterdDf root =Tk() root.title('Dashboard') r

为什么我的桌子没有按照我的定义改变样式? 我尝试使用样式和地图,但没有改变任何东西。 似乎唯一有效的是主题配置。 此外,滚动条不会显示在树视图中

from tkinter import *
from tkinter import ttk

class Dashboard:

def __init__(self, filterdDf):

    self.filterdDf = filterdDf

    root =Tk()
    root.title('Dashboard')
    root.geometry('1300x690')
    root.resizable(False, False)

    frame = Frame(root, width=1100, height=690)
    frame.configure(background="gray28")
    frame.pack(fill=BOTH, expand=True)

    rows = len(filterdDf)

    tree = ttk.Treeview(root, columns=(1, 2), height=rows, show="headings")
    tree.pack(side='left')
    tree.place(x=700, y=150)

    #Add some style:
    style = ttk.Style()

    style.theme_use("clam")

    style.configure("Treeview",
                    background="silver",
                    foreground="black",
                    rowheight=55,
                    fieldbackground="silver")

    #Change selected color:
    style.map("Treeview",
              background=[('selected', 'green')])

    tree.heading("#0", text="Label", anchor=W)
    tree.heading("#1", text="Approach", anchor=CENTER)
    tree.heading("#2", text="Recommendation", anchor=CENTER)

    tree.column("#0", width=120, minwidth=25)
    tree.column("#1", width=300, minwidth=25, anchor=W)
    tree.column("#2", width=150, minwidth=25, anchor=CENTER)

    scroll = ttk.Scrollbar(frame, orient="vertical", command=tree.yview)
    scroll.pack(side='right', fill='y')

    tree.configure(yscrollcommand=scroll.set)

    for i in range(rows):
        tree.insert(parent='', index='end', values=(filterdDf[('Approaches', 'All')].iloc[i],
                                       filterdDf[('Recommendation Level', '')].iloc[i]))

    root.mainloop()
这就是我的Treeview的样子: 2列数据。 谢谢

这就是样式配置(不同的数据但相同的配置)的外观:


我很确定问题出在框架上:
frame=frame(根,宽度=1100,高度=690)frame.configure(background=“gray28”)frame.pack(fill=BOTH,expand=True