I'm making a GUI in Tkinter and want the sun valley theme (https://github.com/rdbende/Sun-Valley-ttk-theme) to effect all my windows.
When I run my code only the first window in this case the Test class has the theme, when I click the button and run my next window Main the theme isn't applied.
I've tried it with and without Test.destroy(), not using sv_ttk.use_dark_theme() in Main() and I have also tried switching the theme back and forth with no change.
Here are two screen shots of both windows afterwards is my code: Test() window Main() window
import tkinter as tk
from tkinter import ttk
import sv_ttk
class Test(tk.Tk):
def __init__(self):
super().__init__()
sv_ttk.use_dark_theme()
self.geometry('250x150')
self.title("Test")
self.resizable(0,0)
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=3)
testButton = ttk.Button(self, text="Press me!", command=lambda : self.newWindow()).grid(column=0, row=3, sticky=tk.E, padx=5, pady=5)
def newWindow(self):
self.newWindow = Main()
Test.destroy()
class Main(tk.Tk):
def __init__(self):
super().__init__()
sv_ttk.use_dark_theme()
self.geometry('1200x800')
self.title("Main")
self.resizable(0,0)
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
self.test = ttk.Checkbutton(self, text="testing", style="Toggle.TButton")
self.test.grid(column=0, row=0, sticky=tk.W, padx=5, pady=5)
if __name__ =="__main__":
Test=Test()
Test.mainloop()