示例#1
0
    def _setRoot(self, init_line):

        root = tk.Tk()
        root.title(init_line)

        # configure the overlay widget, aka the master widget of the line we have created
        root.overrideredirect(
            True
        )  # this prevents the override from behaving like a regular window
        root.geometry(f'+{self.position["X"]}+{self.position["Y"]}'
                      )  # this sets overlay's initial position
        root.minsize(
            500, 20)  # set minimum widget size to max of what it will ever be
        root.configure(
            bg=self.colors['background'])  # set the BG colour of the widget
        root.wm_attributes(
            '-topmost',
            True)  # make sure the overlay widget stays on top of other windows
        root.wm_attributes(
            '-alpha',
            self.opacity)  # set opacity to make the widget semi-transparent

        root.update()

        # set the window to allow clicking events to go through
        window = win32gui.FindWindow(None,
                                     init_line)  # find our window to edit it
        lExStyle = win32gui.GetWindowLong(window, win32con.GWL_EXSTYLE)
        lExStyle |= win32con.WS_EX_TRANSPARENT | win32con.WS_EX_LAYERED
        win32gui.SetWindowLong(window, win32con.GWL_EXSTYLE, lExStyle)

        return root
示例#2
0
 def setWindowAnimation(self, hWnd):
     """ 打开窗口动画效果 """
     style = win32gui.GetWindowLong(hWnd, win32con.GWL_STYLE)
     win32gui.SetWindowLong(
         hWnd, win32con.GWL_STYLE, style | win32con.WS_MAXIMIZEBOX
         | win32con.WS_CAPTION
         | win32con.CS_DBLCLKS
         | win32con.WS_THICKFRAME)
示例#3
0
    def addWindowAnimation(self, hWnd):
        """ 打开窗口动画效果

        Parameters
        ----------
        hWnd : int or `sip.voidptr`
            窗口句柄
        """
        style = win32gui.GetWindowLong(hWnd, win32con.GWL_STYLE)
        win32gui.SetWindowLong(
            hWnd,
            win32con.GWL_STYLE,
            style
            | win32con.WS_MAXIMIZEBOX
            | win32con.WS_CAPTION
            | win32con.CS_DBLCLKS
            | win32con.WS_THICKFRAME,
        )
示例#4
0
    def __set_style_long(self, style_long):
        """Set window style using WinAPI flags."""

        # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga
        win32gui.SetWindowLong(self.__hwnd, win32con.GWL_STYLE, style_long)