In Windows explorer the user can choose to have the taskbar field on any of the for sides of the screen (i.e top, bottom, left or right). This means that code that needs to display windows relative to this selection has to know where the taskbar is placed.
This little procedure finds the position of the taskbar field and returns "top", "bottom", "left" or "right" depending on the choice of the user.
1 2 3 4 5 6 7 8 9 10 11 12 13
import wx def getTaskbarPos(): d_w, d_h = wx.DisplaySize() c_x, c_y, c_w, c_h = wx.ClientDisplayRect() l = [(c_y, "top"), (d_h - c_y - c_h, "bottom"), (c_x, "left"), (d_w - c_x - c_w, "right")] def sorter(a,b): if a<b : return 1 if a>b : return -1 return 0 l.sort(sorter) return l
In my specific case I needed to know where the taskbar was placed so that I could display a borderless information window just above my application's TaskBarIcon. It took me some time to find out how to do it and that is why I'm writing this recipe.
I have tested this in Python 2.4.1 with wxPython 184.108.40.206 on Windows XP SP2, but the same technique will probably work with the X window managers as well.