Python tkinter how do I increase label font size as a function of windows size?

python tkinter how do I increase label font size dynamically as a function of windows size? if some shrink’s the window the font size decrases and vice versa. I’ve tried to find a solution with no luck. Can anyone help?
Sample code:

import tkinter as tk

# Create the main window
root = tk.Tk()
root.geometry("400x250")  # Set window size
root.title("Welcome to My App")  # Set window title

# Create a StringVar to associate with the label
text_var = tk.StringVar()
text_var.set("Hello, World!")

# Create the label widget with all options
label = tk.Label(root, 
                 textvariable=text_var, 
                 anchor=tk.CENTER,       
                 bg="lightblue",      
                 height=3,              
                 width=30,              
                 bd=3,                  
                 font=("Arial", 16, "bold"), 
                 cursor="hand2",   
                 fg="red",             
                 padx=15,               
                 pady=15,                
                 justify=tk.CENTER,           
                )

# Pack the label into the window
label.pack(pady=20)  # Add some padding to the top


# Run the main event loop
root.mainloop()

You could set up a resize callback on the window, in which to manually recreate all the labels or all widgets containing text with the respective window width or height. I don’t think there is really another way.
In general, you don’t change the font size with the window. GUI toolkits don’t generally do that. In theory you can do it, but it may be a little cumbersome.

1 Like

Take a look at this:

It might hint you on what is and isn’t possible.

Also consider using the canvas widget, if you don’t actually need specific widgets. It can resize drawable things all at once. You may build your own custom widgets, although that wouldn’t be easy.