我想将菜单栏的颜色和窗口的画布更改为黑色。但是使用ttk.style
and config
,但我找不到改变它的过程。
我想更改窗口的顶部,突出显示的内容。而且我认为不可能改变这一点。我正在研究 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, 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", font=("Arial",10))
filemenu.add_command(label="Ouvrir code source", font=("Arial",10))
menubar.add_cascade(label="Emplacement", menu=filemenu)
modifier_source = Menu(menubar, tearoff=0)
modifier_source.add_command(label="Modifier le fichier Source",font=("Arial",10))
modifier_source.add_command(label="Generer le nouveau CSV",font=("Arial",10))
menubar.add_cascade(label="Fichier Source", menu=modifier_source,font=("Arial",10))
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Procedure",font=("Arial",10))
menubar.add_cascade(label="Aide", menu=helpmenu,font=("Arial",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,width=100,height=100,background='White')
self.dashboard.pack(fill='both',expand=1)
self.my_notebook.add(self.dashboard,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()
你有想法吗 ?
谢谢 !