(pySide2) how does one get Screen size minus the taskbar?

absoluteKelvin
Collaborator
Collaborator

(pySide2) how does one get Screen size minus the taskbar?

absoluteKelvin
Collaborator
Collaborator

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.

https://www.artstation.com/kelvintam
0 Likes
Reply
Accepted solutions (1)
205 Views
2 Replies
Replies (2)

FirespriteNate
Advocate
Advocate
Accepted 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...

0 Likes

absoluteKelvin
Collaborator
Collaborator

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.

 

TuEsjxS8oFcopy.png

 

https://www.artstation.com/kelvintam
0 Likes