Code: Select all
#-----------------------------------------------------------------------------
class SetAlwaysOnTop(eg.ActionClass):
name = "Set always on top property"
actions = ("Clear always on top", "Set always on top", "Toggle always on top")
def __call__(self, action):
hwnds = eg.lastFoundWindows
if not hwnds:
hwnds = [win32gui.GetForegroundWindow()]
for hwnd in hwnds:
if not win32gui.IsWindow(hwnd):
eg.printError("Not A Window")
continue
isAlwaysOnTop = win32api.GetWindowLong(hwnd,
win32con.GWL_EXSTYLE) & win32con.WS_EX_TOPMOST != 0
if (isAlwaysOnTop == True) and (action == 0 or action == 2):
win32gui.SetWindowPos(hwnd, win32con.HWND_NOTOPMOST,
0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
elif (isAlwaysOnTop == False) and (action == 1 or action == 2):
win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST,
0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
def GetLabel(self, action):
return self.actions[action]
def Configure(self, action = 2):
dialog = eg.ConfigurationDialog(self)
choices = len(self.actions)
rb = range(0, choices)
for i, text in enumerate(self.actions):
rb[i] = wx.RadioButton(dialog, -1, text)
rb[i].SetValue(action == i)
dialog.sizer.Add(wx.Size(5,5))
dialog.sizer.Add(rb[i], flag = wx.ALIGN_CENTER_VERTICAL)
if dialog.AffirmedShowModal():
for i in range(len(rb)):
if rb[i].GetValue():
return (i, )