For my current Python project, I usually work at college on an x sized monitor, however when I want to work on it at home I have a much smaller screen. The majority of my widgets are currently sized with height and width parameters, and so when I work at home, my Tkinter frames that had been adjusted to fit my work monitor are then too big for the home screen, and only about two-thirds of my frame content then appears on the screen. I am using grid geometry.
There are also issues even when widgets don't have height parameters, for example, as there are simply too many rows of widgets to fit on my smaller screen.
Is it possible to scale Tkinter frames at all, so that when I come home to work on my project my window proportionately reduces in size to fit my smaller screen?
An example class is below:
class home_page(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.configure(background="white")
h_title = tk.Label(self, text="Welcome to Fantasy Football!", fg="white", height=2, width=60, anchor="center", bg="#0ebf08", font=controller.title_font)
h_squad_hub_lb = tk.Label(self, text="Squad Hub", fg="white", width=13, anchor="center", bg="#38003c", font=controller.title_font)
squad_hub_text = "Selection headaches keeping you up\nat night? View your team below: "
h_sh_text = tk.Label(self, text=squad_hub_text, bg="white", font=("Segoe UI", 13))
h_view_team_bt = tk.Button(self, text="View Team", bg="#38003c", fg="white", command=lambda: controller.show_frame("pitch_view_team_page"))
h_transfers_bt = tk.Button(self, text="Transfers", bg="#38003c", fg="white", command=lambda: controller.show_frame("pitch_view_transfers_page"))
self.sh_img = PhotoImage(file = "Miscellaneous images/Squad Hub.png")
h_sh_img = tk.Label(self, image=self.sh_img)
h_rules_lb = tk.Label(self, text="Rules", fg="white", bg="#38003c", width=13, anchor="center", font=controller.title_font)
rules_text = "Need to know the game before you can\ncrush it? Check out our rules below: "
h_r_text = tk.Label(self, text=rules_text, bg="white", font=("Segoe UI", 13))
h_selection_info_bt = tk.Button(self, text="Selection Info", bg="#38003c", fg="white", command=lambda: controller.show_frame("seli_rules_page"))
h_scoring_info_bt = tk.Button(self, text="Scoring Info", bg="#38003c", fg="white", command=lambda: controller.show_frame("scoi_rules_page"))
self.r_img = PhotoImage(file = "Miscellaneous images/Rules.png")
h_r_img = tk.Label(self, image=self.r_img)
h_stats_lb = tk.Label(self, text="Statistics", fg="white", bg="#38003c", width=13, anchor="center", font=controller.title_font)
stats_text= "Want some hard facts to help decide on\nyour transfers? Check out the stats below: "
h_s_text = tk.Label(self, text=stats_text, bg="white", font=("Segoe UI", 13))
h_table_bt = tk.Button(self, text="League Table", bg="#38003c", fg="white", command=lambda: controller.show_frame("lgetbl_stats_page"))
h_plrsts_bt = tk.Button(self, text="Player Stats", bg="#38003c", fg="white", command=lambda: controller.show_frame("plrsts_stats_page"))
self.s_img = PhotoImage(file = "Miscellaneous images/Stats.png")
h_s_img = tk.Label(self, image=self.s_img)
h_news_lb = tk.Label(self, text="News", fg="white", width=13, anchor="center", bg="#38003c", font=controller.title_font)
news_text = "Want to hear what your favourite team is\nup to? Check out club news below: "
h_n_text = tk.Label(self, text=news_text, bg="white", font=("Segoe UI", 13))
h_club_list_bt = tk.Button(self, text="Club List", bg="#38003c", fg="white", command=lambda: controller.show_frame("clli_stats_page"))
h_preferences_bt = tk.Button(self, text="My Preferences", bg="#38003c", fg="white", command=lambda: controller.show_frame("mpref_settings_page"))
self.n_img = PhotoImage(file = "Miscellaneous images/News.png")
h_n_img = tk.Label(self, image=self.n_img)
h_title.grid(row=0, column=0, columnspan=15, pady=(60,60))
h_squad_hub_lb.grid(row=1, column=0, columnspan=3)
h_sh_text.grid(row=2, column=0, columnspan=3, rowspan=3)
h_sh_img.grid(row=2, column=3, rowspan=2)
h_view_team_bt.grid(row=4, column=0, pady=(20,40))
h_transfers_bt.grid(row=4, column=1, pady=(20,40))
h_rules_lb.grid(row=1, column=11, columnspan=3)
h_r_text.grid(row=2, column=11, columnspan=3, rowspan=2)
h_r_img.grid(row=2, column=14, rowspan=2)
h_selection_info_bt.grid(row=4, column=11, pady=(20,40))
h_scoring_info_bt.grid(row=4, column=12, pady=(20,40))
h_stats_lb.grid(row=5, column=0, columnspan=3)
h_s_text.grid(row=6, column=0, columnspan=3, rowspan=2)
h_s_img.grid(row=6, column=3, rowspan=2)
h_table_bt.grid(row=8, column=0, pady=(20,40))
h_plrsts_bt.grid(row=8, column=1, pady=(20,40))
h_news_lb.grid(row=5, column=11, columnspan=3)
h_n_text.grid(row=6, column=11, columnspan=3, rowspan=2)
h_n_img.grid(row=6, column=14, rowspan=2)
h_club_list_bt.grid(row=8, column=11, pady=(20,40))
h_preferences_bt.grid(row=8, column=12, pady=(20,40))