更改颜色菜单栏和画布窗口ttk

问题描述

我想将菜单栏的颜色和窗口的画布更改为黑色。但是使用ttk.styleconfig,但是我找不到更改它的过程。

我想更改窗口的顶部,突出显示内容。而且我认为不可能改变这一点。我正在使用Window,我想创建我的“样式”。

    import tkinter as tk

    from tkinter import *
    from tkinter import ttk
    from tkinter import messageBox
    from datetime import *
    from tkinter import filedialog

    from ctypes import *
    from win32api import GetSystemMetrics


    try:
        windll.shcore.SetProcessDpiAwareness(c_int(1))
        Width = 1920
        Height = 1080
    except:
        print('Error display Quality')
    #----------------------------------Tkinter Principal --------------------------------------------------------------------

    class Window_main:
        def __init__(self,parent):
            amundi_color = "#00a0e3"
            myred = "#3A3A3A"
            withe = "#FCFAFA"

            # fenetre 1
            parent.title("Weekly Report")
            parent.configure(background= amundi_color)
            # parent.wm_attributes("-topmost",True)
            #Taille
            parent.minsize(600,350)
            parent.geometry("1440x810")


            self.style = ttk.Style()
            #self.style.theme_use("vista")

            self.style.theme_create( "style_amundi_black",parent="alt",settings={
            "TFrame": {
                "configure": {"background": myred } },"TLabel": {
                "configure": {"background": myred } },"TNotebook": {
                "configure": {"background": myred } },"TNotebook.Tab": {
                "configure": { "background": myred,'font':('Arial',10),"foreground":withe},"map":       {"background": [("selected",amundi_color)],"expand": [("selected",[1,1,0])] } } } )

            self.style.theme_use("style_amundi_black")

            menubar = Menu(parent)
            filemenu = Menu(menubar,tearoff=0)
            filemenu.add_command(label="Ouvrir dossier",font=("Arial",10))
            filemenu.add_command(label="Ouvrir fichier Source",10))
            filemenu.add_command(label="Ouvrir code source",10))
            menubar.add_cascade(label="Emplacement",menu=filemenu)

            modifier_source = Menu(menubar,tearoff=0)
            modifier_source.add_command(label="Modifier le fichier Source",10))
            modifier_source.add_command(label="Generer le nouveau CSV",10))
            menubar.add_cascade(label="Fichier Source",menu=modifier_source,10))

            helpmenu = Menu(menubar,tearoff=0)
            helpmenu.add_command(label="Procedure",10))
            menubar.add_cascade(label="Aide",menu=helpmenu,10))



            #self.labelframe1 = LabelFrame(parent,background='white',relief = 'sunken',labelanchor ='n')
            #self.labelframe1.pack(side=LEFT,fill="both",expand="yes",pady=20,padx = 10)


            self.my_notebook = ttk.Notebook(parent,width=1440,height=810)
            self.my_notebook.pack(expand=1)

            self.dashboard = Frame(self.my_notebook,width=100,height=100,background='White')
            self.dashboard.pack(fill='both',expand=1)
            self.my_notebook.add(self.dashboard,text='DashBoard')

            self.dashboard = Frame(self.my_notebook,text='Perf')



            parent.bind("<Configure>",self.conf)
            root.protocol('WM_DELETE_WINDOW',self.Destroy_Window)

            #Assemblage du menu
            parent.config(menu=menubar)
            parent.mainloop()

        def conf(self,event):
                print (root.winfo_width())
                print (root.winfo_height())
                #print (root.winfo_geometry())
                self.my_notebook.config(height=root.winfo_height(),width=root.winfo_width())

        def Destroy_Window(self):
            root.destroy()
            sys.exit()


    root = Tk()
    timer = Window_main(root)
    root.mainloop()

I would like to change the top of window,what's highlighted

你有个主意吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)