I think you call the two lines before creating the instance of Tk()
, something like below:
import tkinter as tk
from tkinter import ttk
correct_style = ttk.Style()
correct_style.configure('correct.TButton',background='#39b54a')
root = tk.Tk()
...
root.mainloop()
As ttk.Style()
requires an instance of Tk()
, if there is none, it will be created implicitly for you. So there will be two instances of Tk()
.
Move the two lines after creating Tk()
:
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
correct_style = ttk.Style()
correct_style.configure('correct.TButton',background='#39b54a')
...
root.mainloop()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…