如何解决更改颜色菜单栏和画布窗口ttk
我想将菜单栏的颜色和窗口的画布更改为黑色。但是使用ttk.style
和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,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()
你有个主意吗?
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。