##### [Tkinter] Window geometry appears different on Win and Linux
 [Tkinter] Window geometry appears different on Win and Linux Larz60+ aetate et sapientia Posts: 9,975 Threads: 372 Joined: Sep 2016 Reputation: 421 Nov-25-2019, 04:52 PM (This post was last modified: Nov-25-2019, 11:36 PM by Larz60+.) Here's a class that will get the geometry for all monitors on your computer ``` # Author: Larz60+ Nov 2019 from screeninfo import get_monitors class GetGeometry: def __init__(self): self.geometry = [] def get_tkinter_geometry(self, percent_of_screen, xpad=None, ypad=None): ''' Given percent of monitor size in floating point eg: 10 % = 10.0, calculates tkinter geometry for each monitor attached to computer requires screeninfo "pip install screeninfo" returns: list holding tkinter geometry strings padded with xpad and ypad or centered if xpad is None. None if bad pct passed ''' if not isinstance(percent_of_screen, float): print("requires float percent eg: 10.0 for 10%") return pct = percent_of_screen / 100 for size in get_monitors(): cwidth = int(size.width * pct) cheight = int(size.height * pct) xoff = xpad yoff = ypad if xpad is None: xoff = int((size.width - cwidth) / 2) yoff = int((size.height - cheight) / 2) self.geometry.append(f"{cwidth}x{cheight}+{xoff}+{yoff}")```test function: ```import GetTkGeometry gg = GetTkGeometry.GetTkGeometry() # padding specified 10 % of screen dimensions gg.get_tkinter_geometry(10.0, 10, 10) geometry = gg.geometry print(f"\ngeometry - 10% of monitor size 10 pixel x and y padding:\n{geometry}") # padding not specified 60 % of screen dimensions gg.get_tkinter_geometry(60.0) geometry = gg.geometry print(f"\ngeometry - 60% of monitor size centered (no pading specified):\n{geometry}")```results for my system: ``````Output:geometry - 10% of monitor size 10 pixel x and y padding: ['192x108+10+10'] geometry - 60% of monitor size centered (no pading specified): ['192x108+10+10', '1152x648+384+216']`````` Reply

 Messages In This Thread [Tkinter] Window geometry appears different on Win and Linux - by steve_shambles - Nov-25-2019, 11:41 AM RE: [Tkinter] Window geometry appears different on Win and Linux - by Larz60+ - Nov-25-2019, 04:52 PM RE: [Tkinter] Window geometry appears different on Win and Linux - by steve_shambles - Nov-25-2019, 08:19 PM RE: [Tkinter] Window geometry appears different on Win and Linux - by Larz60+ - Nov-25-2019, 11:38 PM RE: [Tkinter] Window geometry appears different on Win and Linux - by steve_shambles - Nov-26-2019, 02:32 AM RE: [Tkinter] Window geometry appears different on Win and Linux - by Larz60+ - Nov-26-2019, 06:52 AM RE: [Tkinter] Window geometry appears different on Win and Linux - by steve_shambles - Nov-29-2019, 12:30 AM

 Possibly Related Threads… Thread Author Replies Views Last Post function in new window (tkinter) Dale22 7 336 Nov-24-2020, 11:28 PM Last Post: Dale22 Scrollable big image in a window (TKinter) Prospekteur 3 346 Sep-14-2020, 03:06 AM Last Post: Larz60+ Run more than one window together with tkinter SmukasPlays 1 327 Aug-24-2020, 05:00 PM Last Post: Larz60+ Adding an image to a tkinter window djwilson0495 2 1,170 Aug-23-2020, 11:07 AM Last Post: ebolisa [Tkinter] calling a new window from a tkinter window neuroprogrammer 2 415 Jul-28-2020, 10:59 PM Last Post: deanhystad How to display results from terminal window onto tkinter. buttercup 0 301 Jul-21-2020, 04:41 AM Last Post: buttercup Tkinter: multitab window WizardMitMagi 3 612 Apr-29-2020, 02:40 PM Last Post: deanhystad tkinter.TclError: bad window path name kenwatts275 3 2,108 Apr-26-2020, 08:16 PM Last Post: kenwatts275 Using Tkinter widgets on child window chewy1418 8 1,893 Feb-27-2020, 10:34 PM Last Post: Marbelous Transfer Toplevel window entry to root window entry with TKinter HBH 0 1,473 Jan-23-2020, 09:00 PM Last Post: HBH

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020