Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
maya 2023
from PySide2.QtWidgets import QApplication
from PySide2.QtGui import QScreen
screensize = QScreen.availableGeometry(QApplication.primaryScreen()).size().toTuple()
from testing and studying other peoples scripts. I figured out how to get the size of the primary screen. But would like to get the screen size without the windows taskbar.
Solved! Go to Solution.
Solved by FirespriteNate. Go to Solution.
I've never had to do this, so I can't vouch for its accuracy, but if you look at the docs for QScreen.availableGeometry it says:
This property holds the screen’s available geometry in pixels.
The available geometry is the geometry excluding window manager
reserved areas such as task bars and system menus.
Which sounds like it should already be giving you the thing you want.
Just out of interest, why do you want this size? Maybe there's a different or more appropriate way to get the ultimate data you need?
EDIT: - OK, I just tried this code on Maya 2022 and it worked perfectly, I got (1920, 1160) back, which is the exact size of my desktop on Monitor 1, minus the Windows taskbar height...
Ah yes silly me, I didn't actually verify the pixels. I was trying to resize a window so that it won't be cut off. It threw me off since my window wasn't aligned to the top of the screen, as it got cut off near the bottom when resizing.
Can't find what you're looking for? Ask the community or share your knowledge.