DrafFter
DrafFter

Reputation: 481

How to get a ms windows desktop height in pygtk?

I wrote application in pygtk, that display a popup (like from Chrome) window, without resizing and moving option. All is great except one thing. I have to move this window to bottom of the screen, little above the taskbar. Taskbar on MS windows has, on windows XP 30px, but on windows 7 is higher I have the monitor / screen resolution getting by code:

w = self.get_screen()
print w.get_height()

but i still don't have a height of taskbar. Any ideas how to get this height?

Upvotes: 1

Views: 387

Answers (1)

cdonts
cdonts

Reputation: 9599

On Windows you can use this:

from ctypes import windll, wintypes, byref

SPI_GETWORKAREA = 48
SM_CYSCREEN = 1

def get_taskbar_size():
    SystemParametersInfo = windll.user32.SystemParametersInfoA
    work_area = wintypes.RECT()
    if (SystemParametersInfo(SPI_GETWORKAREA, 0, byref(work_area), 0)):
        GetSystemMetrics = windll.user32.GetSystemMetrics
        return GetSystemMetrics(SM_CYSCREEN) - work_area.bottom

print get_taskbar_size()  # 30

Note that get_taskbar_size will return None if the API call failed.

Upvotes: 2

Related Questions