pythonのtkinterに関しての質問になります。
タブを選択しているときなど、タブの背景色を変えたいのですが、ttkを使うと、テーマに依存してしまうようです。
ほかのテーマを使用すると、下記のコードで色は変わるのですが、現在使用している(Vista)というテーマで同じ色を実装したいです。
テーマに依存せず、色変更する方法はありますでしょうか?よろしくお願いいたします。
python
1from tkinter import DISABLED,NORMAL, END, BooleanVar, StringVar, ttk, messagebox 2import tkinter 3from ttkthemes import * 4 5root = ThemedTk() 6root.title('test') 7root.geometry('1050x650') 8 9style = ttk.Style() 10style.theme_use('vista') 11style.configure('custom.TNotebook') 12style.configure('custom.TNotebook.Tab',background="gray70",foreground="black",) 13style.map('custom.TNotebook.Tab',foreground=[ 14 ('active', 'black'), 15 ('disabled', 'black'), 16 ('selected', 'black'), 17 ], 18 background=[ 19 ('active', 'gray70'), 20 ('disabled', 'black'), 21 ('selected', 'red'), 22 ],) 23 24notebook = ttk.Notebook(root,style='custom.TNotebook',height=500,width=500) 25notebook.pack(padx=10, pady=10, fill=tkinter.BOTH, expand=True) 26 27#タブ1 28tab_one = ttk.Frame(notebook, width=1100, height=650, style='custom.TFrame') 29notebook.add(tab_one, text=' タブ1 ', underline=100) 30tab_two = ttk.Frame(notebook, width=1100, height=650) 31notebook.add(tab_two, text=' タブ2 ', underline=100,) 32 33 34 35root.mainloop()
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/06/05 19:00
2022/06/06 05:06 編集