Credits to @TheLizzard too for this.
The fix is to set cleanresize=False
in self.run()
:
self.run(cleanresize=False)
But now, the frames are not expanding vertically.
That is because, after setting cleanresize
to False
, we handle everything manually. Including the columns and the rows.
The problem was, you were not using grid_rowconfigure
, so just add this line:
self.root.grid_rowconfigure(0, weight=1)
So your final code:
import tkinter as tk
import TKinterModernThemes as TKMT
class App(TKMT.ThemedTKinterFrame):
def __init__(self, theme, mode, usecommandlineargs=True, usethemeconfigfile=True):
super().__init__("Switch", theme, mode, usecommandlineargs=usecommandlineargs, useconfigfile=usethemeconfigfile)
self.switchframe1 = self.addLabelFrame("Switch Frame 1", sticky=tk.NSEW, row=0, col=0)
self.switchvar = tk.BooleanVar()
self.switchframe1.SlideSwitch("Switch1", self.switchvar)
self.switchframe2 = self.addLabelFrame("Switch Frame 2", sticky=tk.NSEW, row=0, col=1)
self.switchvar = tk.BooleanVar()
self.switchframe2.SlideSwitch("Switch2", self.switchvar)
self.root.grid_columnconfigure(0, weight=0)
self.root.grid_columnconfigure(1, weight=1)
self.root.grid_rowconfigure(0, weight=1)
self.run(cleanresize=False)
if __name__ == "__main__":
App("park", "dark")