'Python TKinter Window Position on a Mac
Trying to position a window Python TKinter; have the code working lovely on a PC, but when transposed to a Mac, not working. I'm using the geometry method, taking 4 params; a-height, b-width, c-right-offset, d-top-offset) - geometry(axb+c+d)
The vars return the correct values on both platforms; under MacOS - it correctly sizes the window, but does not position it correctly. Windows OS works fine - size and position.
I'm not an expert on Python/TKinter and I'm aware of many OS differences, but this one has me vexed. Any ideas???? Thanks in advance.
# Set the window size and position it centre parent
hspCommon.SetFormCentre(self.__Root, self.__Child, 790, 595)
def SetFormCentre(myRoot, myWindow, myWindowWidth, myWindowHeight):
# Gets the requested values of the height and width
ScreenWidth = int(myRoot.winfo_screenwidth())
ScreenHeight = int(myRoot.winfo_screenheight())
ScreenWidthDiv2 = ScreenWidth / 2
ScreenHeightDiv2 = ScreenHeight / 2
WindowWidthDiv2 = int(myWindowWidth) / 2
WindowHeightDiv2 = int(myWindowHeight) / 2
# Gets both half the screen width/height and window width/height
PositionRight = int(ScreenWidthDiv2 - WindowWidthDiv2)
PositionDown = int(ScreenHeightDiv2 - WindowHeightDiv2)
# Positions the window in the center of the screen.
mySizeAndPos = "{}x{}+{}+{}".format(myWindowWidth,myWindowHeight,PositionRight,PositionDown)
myWindow.geometry(mySizeAndPos)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
