简体   繁体   中英

How to get the size and location of the taskbar with PyGTK?

Is there any way to get the position and size of the taskbar on Windows with PyGTK?

If not, is there at least a way to determine the free client area on a specific monitor? (In other words, the area the taskbar does not occupy?)

Slightly neater (but windows only) as this creates a dynamic pair of variables which you can then used to adjust the offset of your remaining code;

import win32gui

#discover where top left corner of active screen is
#return is a dictionary list of keys and values
monitors = win32api.EnumDisplayMonitors()
display1 = win32api.GetMonitorInfo(monitors[0][0])

#from the Work key, select the first and second values
x_adj=(display1['Work'][0])
y_adj=(display1['Work'][1])

Then, in the remainder of your code use these adjustments to refine your navigation clicks. In my case I am moving around a window using pyautogui

import pyautogui

#just move the mouse to a position
pyautogui.moveTo(x=103+x_adj, y=235+y_adj)

#move and click the mouse
pyautogui.click(x=103+x_adj, y=235+y_adj)

In your case you will want to create the top left corner of the new window at (or relative to) the co-ordinates of (x_adj,y_adj)

You can maximize a window, and check its geometry after it was maximized. Something like this (works both on Windows and Linux):

import gtk

size = (10, 10)
def expose(widget, *args):
    global size
    size = widget.get_size()
    if size != (10, 10):
        gtk.main_quit()

win = gtk.Window()
win.resize(*size)
win.connect('expose-event', expose)
win.show()
win.maximize()
gtk.main()
print size

This is somewhat hackish, but I'm not sure if there is a portable way (without using Win32 API if you are on Windows) to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM