I have a app which uses ttkbootstrap and as a learning exercise wanted to turn it into a class based app. I am falling at the first hurdle so to speak as the basic window shows up as a different size.The first example is fine.
import tkinter as tk
from tkinter import *
import ttkbootstrap as tb
#root = tk.Tk()
root=tb.Window(themename="terry")
root.title("Stableford League")
root.geometry("1000x1000")
root.mainloop()
However the following produces a larger window:
import tkinter as tk
class App(tk.Tk):
def __init__(self):
super().__init__()
self.geometry("1000x1000")
if __name__ == "__main__":
app = App()
app.mainloop()
My screen resolution is 1920 x 1080 and scale is set to 150% but I cannot understand why the displayed windows are different sizes.
following your advice I arrive at the following code
import tkinter as tk
from tkinter import ttk
import ttkbootstrap as tb
from ttkbootstrap import Style
class App(tb.Window):
def __init__(self):
super().__init__()
self.title("Stableford League")
self.geometry("1000x1000")
self.style = Style(theme="terry")
if __name__ == "__main__":
app = App()
app.mainloop()
The line self.style = Style(theme = "terry") worked before inheriting from tb.Window but now throws an error.
Appclass should inherit fromtb.Window, making it equivalent torootin your first example. And @BryanOakley: given that OP's (user)name is Terry, I assume it is indeed a custom theme.ttkbootstraphandles high DPI (i.e. DPI awareness), buttkinterdoes not. To inherit fromttkbootstrap, changeclass App(tk.Tk)toclass App(tb.Window).