PyQt6-Frameless-Window 0.6.2__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/PKG-INFO +4 -3
  2. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/PyQt6_Frameless_Window.egg-info/PKG-INFO +4 -3
  3. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/__init__.py +1 -1
  4. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/linux/window_effect.py +25 -0
  5. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/mac/window_effect.py +24 -0
  6. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/titlebar/__init__.py +1 -1
  7. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/utils/win32_utils.py +18 -2
  8. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/windows/__init__.py +7 -1
  9. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/windows/c_structures.py +8 -7
  10. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/windows/window_effect.py +43 -3
  11. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/setup.py +1 -1
  12. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/LICENSE +0 -0
  13. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/PyQt6_Frameless_Window.egg-info/SOURCES.txt +0 -0
  14. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/PyQt6_Frameless_Window.egg-info/dependency_links.txt +0 -0
  15. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/PyQt6_Frameless_Window.egg-info/requires.txt +0 -0
  16. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/PyQt6_Frameless_Window.egg-info/top_level.txt +0 -0
  17. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/README.md +0 -0
  18. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/_rc/__init__.py +0 -0
  19. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/_rc/resource.py +0 -0
  20. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/linux/__init__.py +0 -0
  21. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/mac/__init__.py +0 -0
  22. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/titlebar/title_bar_buttons.py +0 -0
  23. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/utils/__init__.py +0 -0
  24. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/utils/linux_utils.py +0 -0
  25. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/utils/mac_utils.py +0 -0
  26. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/qframelesswindow/webengine/__init__.py +0 -0
  27. {PyQt6-Frameless-Window-0.6.2 → pyqt6_frameless_window-0.7.0}/setup.cfg +0 -0
@@ -1,18 +1,20 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyQt6-Frameless-Window
3
- Version: 0.6.2
3
+ Version: 0.7.0
4
4
  Summary: A cross-platform frameless window based on pyqt6, support Win32, Linux and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/PyQt6
6
6
  Author: zhiyiYo
7
7
  Author-email: shokokawaii@outlook.com
8
8
  License: GPLv3
9
9
  Keywords: pyqt6 frameless
10
- Platform: UNKNOWN
11
10
  Classifier: Programming Language :: Python :: 3
12
11
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
12
  Classifier: Operating System :: OS Independent
14
13
  Description-Content-Type: text/markdown
15
14
  License-File: LICENSE
15
+ Requires-Dist: pywin32; platform_system == "Windows"
16
+ Requires-Dist: pyobjc; platform_system == "Darwin"
17
+ Requires-Dist: PyCocoa; platform_system == "Darwin"
16
18
 
17
19
  <p align="center">
18
20
  <img width="15%" align="center" src="https://raw.githubusercontent.com/zhiyiYo/PyQt-Frameless-Window/master/screenshot/logo.png" alt="logo">
@@ -134,4 +136,3 @@ Here are some projects that use PyQt-Frameless-Window:
134
136
  PyQt6-Frameless-Window is licensed under [GPLv3](./LICENSE).
135
137
 
136
138
  Copyright © 2021 by zhiyiYo.
137
-
@@ -1,18 +1,20 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyQt6-Frameless-Window
3
- Version: 0.6.2
3
+ Version: 0.7.0
4
4
  Summary: A cross-platform frameless window based on pyqt6, support Win32, Linux and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/PyQt6
6
6
  Author: zhiyiYo
7
7
  Author-email: shokokawaii@outlook.com
8
8
  License: GPLv3
9
9
  Keywords: pyqt6 frameless
10
- Platform: UNKNOWN
11
10
  Classifier: Programming Language :: Python :: 3
12
11
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
12
  Classifier: Operating System :: OS Independent
14
13
  Description-Content-Type: text/markdown
15
14
  License-File: LICENSE
15
+ Requires-Dist: pywin32; platform_system == "Windows"
16
+ Requires-Dist: pyobjc; platform_system == "Darwin"
17
+ Requires-Dist: PyCocoa; platform_system == "Darwin"
16
18
 
17
19
  <p align="center">
18
20
  <img width="15%" align="center" src="https://raw.githubusercontent.com/zhiyiYo/PyQt-Frameless-Window/master/screenshot/logo.png" alt="logo">
@@ -134,4 +136,3 @@ Here are some projects that use PyQt-Frameless-Window:
134
136
  PyQt6-Frameless-Window is licensed under [GPLv3](./LICENSE).
135
137
 
136
138
  Copyright © 2021 by zhiyiYo.
137
-
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/
12
12
  :license: GPLv3, see LICENSE for more details.
13
13
  """
14
14
 
15
- __version__ = "0.6.2"
15
+ __version__ = "0.7.0"
16
16
  __author__ = "zhiyiYo"
17
17
 
18
18
  import sys
@@ -1,4 +1,6 @@
1
1
  # coding:utf-8
2
+ from PyQt6.QtGui import QColor
3
+
2
4
 
3
5
  class LinuxWindowEffect:
4
6
  """ Linux window effect """
@@ -25,6 +27,29 @@ class LinuxWindowEffect:
25
27
  """
26
28
  pass
27
29
 
30
+ def setBorderAccentColor(self, hWnd, color: QColor):
31
+ """ Set the border color of the window
32
+
33
+ Parameters
34
+ ----------
35
+ hWnd: int or `sip.voidptr`
36
+ Window handle
37
+
38
+ color: QColor
39
+ Border Accent color
40
+ """
41
+ pass
42
+
43
+ def removeBorderAccentColor(self, hWnd):
44
+ """ Remove the border color of the window
45
+
46
+ Parameters
47
+ ----------
48
+ hWnd: int or `sip.voidptr`
49
+ Window handle
50
+ """
51
+ pass
52
+
28
53
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
29
54
  """ Add mica effect to the window (Win11 only)
30
55
 
@@ -2,6 +2,7 @@
2
2
  import Cocoa
3
3
  from PyQt6.QtCore import Qt
4
4
  from PyQt6.QtWidgets import QWidget
5
+ from PyQt6.QtGui import QColor
5
6
  from ..utils.mac_utils import getNSWindow
6
7
 
7
8
 
@@ -54,6 +55,29 @@ class MacWindowEffect:
54
55
  content.addSubview_positioned_relativeTo_(
55
56
  visualEffectView, Cocoa.NSWindowBelow, container)
56
57
 
58
+ def setBorderAccentColor(self, hWnd, color: QColor):
59
+ """ Set the border color of the window
60
+
61
+ Parameters
62
+ ----------
63
+ hWnd: int or `sip.voidptr`
64
+ Window handle
65
+
66
+ color: QColor
67
+ Border Accent color
68
+ """
69
+ pass
70
+
71
+ def removeBorderAccentColor(self, hWnd):
72
+ """ Remove the border color of the window
73
+
74
+ Parameters
75
+ ----------
76
+ hWnd: int or `sip.voidptr`
77
+ Window handle
78
+ """
79
+ pass
80
+
57
81
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
58
82
  """ Add mica effect to the window (Win11 only)
59
83
 
@@ -132,7 +132,7 @@ class StandardTitleBar(TitleBar):
132
132
  self.titleLabel.setStyleSheet("""
133
133
  QLabel{
134
134
  background: transparent;
135
- font: 13px 'Segoe UI';
135
+ font: 13px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
136
136
  padding: 0 4px
137
137
  }
138
138
  """)
@@ -1,9 +1,10 @@
1
1
  # coding:utf-8
2
+ import sys
3
+ import warnings
2
4
  from ctypes import Structure, byref, sizeof, windll, c_int, c_ulong, c_bool, POINTER, WinDLL, wintypes
3
5
  from ctypes.wintypes import DWORD, HWND, LPARAM, RECT, UINT
4
6
  from platform import platform
5
- import sys
6
- import warnings
7
+ from winreg import OpenKey, HKEY_CURRENT_USER, KEY_READ, QueryValueEx, CloseKey
7
8
 
8
9
  import win32api
9
10
  import win32con
@@ -37,6 +38,21 @@ def getSystemAccentColor():
37
38
  return QColor(color.value)
38
39
 
39
40
 
41
+ def isSystemBorderAccentEnabled():
42
+ """ Check whether the border accent is enabled """
43
+ if not isGreaterEqualWin11():
44
+ return False
45
+
46
+ try:
47
+ key = OpenKey(HKEY_CURRENT_USER, r"SOFTWARE\Microsoft\Windows\DWM", 0, KEY_READ)
48
+ value, _ = QueryValueEx(key, "ColorPrevalence")
49
+ CloseKey(key)
50
+
51
+ return bool(value)
52
+ except:
53
+ return False
54
+
55
+
40
56
  def isMaximized(hWnd):
41
57
  """ Determine whether the window is maximized
42
58
 
@@ -12,7 +12,7 @@ from PyQt6.QtWidgets import QApplication, QWidget
12
12
 
13
13
  from ..titlebar import TitleBar
14
14
  from ..utils import win32_utils as win_utils
15
- from ..utils.win32_utils import Taskbar
15
+ from ..utils.win32_utils import Taskbar, isSystemBorderAccentEnabled, getSystemAccentColor
16
16
  from .c_structures import LPNCCALCSIZE_PARAMS
17
17
  from .window_effect import WindowsWindowEffect
18
18
 
@@ -177,6 +177,12 @@ class WindowsFramelessWindow(QWidget):
177
177
 
178
178
  result = 0 if not msg.wParam else win32con.WVR_REDRAW
179
179
  return True, result
180
+ elif msg.message == win32con.WM_SETFOCUS and isSystemBorderAccentEnabled():
181
+ self.windowEffect.setBorderAccentColor(self.winId(), getSystemAccentColor())
182
+ return True, 0
183
+ elif msg.message == win32con.WM_KILLFOCUS:
184
+ self.windowEffect.removeBorderAccentColor(self.winId())
185
+ return True, 0
180
186
 
181
187
  return False, 0
182
188
 
@@ -94,13 +94,14 @@ class DWMWINDOWATTRIBUTE(Enum):
94
94
  DWMWA_FREEZE_REPRESENTATION = 15
95
95
  DWMWA_PASSIVE_UPDATE_MODE = 16
96
96
  DWMWA_USE_HOSTBACKDROPBRUSH = 17
97
- DWMWA_USE_IMMERSIVE_DARK_MODE = 18
98
- DWMWA_WINDOW_CORNER_PREFERENCE = 19
99
- DWMWA_BORDER_COLOR = 20
100
- DWMWA_CAPTION_COLOR = 21
101
- DWMWA_TEXT_COLOR = 22
102
- DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 23
103
- DWMWA_LAST = 24
97
+ DWMWA_USE_IMMERSIVE_DARK_MODE = 20
98
+ DWMWA_WINDOW_CORNER_PREFERENCE = 33
99
+ DWMWA_BORDER_COLOR = 34
100
+ DWMWA_CAPTION_COLOR = 35
101
+ DWMWA_TEXT_COLOR = 36
102
+ DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
103
+ DWMWA_SYSTEMBACKDROP_TYPE = 38
104
+ DWMWA_LAST = 39
104
105
 
105
106
 
106
107
  class MARGINS(Structure):
@@ -7,6 +7,7 @@ from ctypes.wintypes import DWORD, LONG, LPCVOID
7
7
  import win32api
8
8
  import win32con
9
9
  import win32gui
10
+ from PyQt6.QtGui import QColor
10
11
 
11
12
  from .c_structures import (ACCENT_POLICY, ACCENT_STATE, DWMNCRENDERINGPOLICY,
12
13
  DWMWINDOWATTRIBUTE, MARGINS,
@@ -82,6 +83,44 @@ class WindowsWindowEffect:
82
83
  self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
83
84
  self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData))
84
85
 
86
+ def setBorderAccentColor(self, hWnd, color: QColor):
87
+ """ Set the border color of the window
88
+
89
+ Parameters
90
+ ----------
91
+ hWnd: int or `sip.voidptr`
92
+ Window handle
93
+
94
+ color: QColor
95
+ Border Accent color
96
+ """
97
+ if not isGreaterEqualWin11():
98
+ return
99
+
100
+ hWnd = int(hWnd)
101
+ colorref = DWORD(color.red() | (color.green() << 8) | (color.blue() << 16))
102
+ self.DwmSetWindowAttribute(hWnd,
103
+ DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR.value,
104
+ byref(colorref),
105
+ 4)
106
+
107
+ def removeBorderAccentColor(self, hWnd):
108
+ """ Remove the border color of the window
109
+
110
+ Parameters
111
+ ----------
112
+ hWnd: int or `sip.voidptr`
113
+ Window handle
114
+ """
115
+ if not isGreaterEqualWin11():
116
+ return
117
+
118
+ hWnd = int(hWnd)
119
+ self.DwmSetWindowAttribute(hWnd,
120
+ DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR.value,
121
+ byref(DWORD(0xFFFFFFFF)),
122
+ 4)
123
+
85
124
  def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
86
125
  """ Add the mica effect to the window (Win11 only)
87
126
 
@@ -101,7 +140,8 @@ class WindowsWindowEffect:
101
140
  return
102
141
 
103
142
  hWnd = int(hWnd)
104
- margins = MARGINS(-1, -1, -1, -1)
143
+ # fix issue #125
144
+ margins = MARGINS(16777215, 16777215, 0, 0)
105
145
  self.DwmExtendFrameIntoClientArea(hWnd, byref(margins))
106
146
 
107
147
  self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
@@ -116,9 +156,9 @@ class WindowsWindowEffect:
116
156
  if sys.getwindowsversion().build < 22523:
117
157
  self.DwmSetWindowAttribute(hWnd, 1029, byref(c_int(1)), 4)
118
158
  else:
119
- self.DwmSetWindowAttribute(hWnd, 38, byref(c_int(4 if isAlt else 2)), 4)
159
+ self.DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE.value, byref(c_int(4 if isAlt else 2)), 4)
120
160
 
121
- self.DwmSetWindowAttribute(hWnd, 20, byref(c_int(1*isDarkMode)), 4)
161
+ self.DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE.value, byref(c_int(1*isDarkMode)), 4)
122
162
 
123
163
  def setAeroEffect(self, hWnd):
124
164
  """ Add the aero effect to the window
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
6
6
 
7
7
  setuptools.setup(
8
8
  name="PyQt6-Frameless-Window",
9
- version="0.6.2",
9
+ version="0.7.0",
10
10
  keywords="pyqt6 frameless",
11
11
  author="zhiyiYo",
12
12
  author_email="shokokawaii@outlook.com",