PySide2-Frameless-Window 0.3.10__tar.gz → 0.4.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 (28) hide show
  1. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/PKG-INFO +1 -1
  2. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/PySide2_Frameless_Window.egg-info/PKG-INFO +1 -1
  3. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/__init__.py +1 -1
  4. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/linux/__init__.py +20 -1
  5. PySide2-Frameless-Window-0.4.0/qframelesswindow/mac/__init__.py +160 -0
  6. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/windows/__init__.py +20 -1
  7. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/setup.py +1 -1
  8. PySide2-Frameless-Window-0.3.10/qframelesswindow/mac/__init__.py +0 -94
  9. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/LICENSE +0 -0
  10. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/PySide2_Frameless_Window.egg-info/SOURCES.txt +0 -0
  11. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/PySide2_Frameless_Window.egg-info/dependency_links.txt +0 -0
  12. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/PySide2_Frameless_Window.egg-info/requires.txt +0 -0
  13. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/PySide2_Frameless_Window.egg-info/top_level.txt +0 -0
  14. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/README.md +0 -0
  15. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/_rc/__init__.py +0 -0
  16. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/_rc/resource.py +0 -0
  17. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/linux/window_effect.py +0 -0
  18. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/mac/window_effect.py +0 -0
  19. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/titlebar/__init__.py +0 -0
  20. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/titlebar/title_bar_buttons.py +0 -0
  21. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/utils/__init__.py +0 -0
  22. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/utils/linux_utils.py +0 -0
  23. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/utils/mac_utils.py +0 -0
  24. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/utils/win32_utils.py +0 -0
  25. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/webengine/__init__.py +0 -0
  26. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/windows/c_structures.py +0 -0
  27. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/qframelesswindow/windows/window_effect.py +0 -0
  28. {PySide2-Frameless-Window-0.3.10 → PySide2-Frameless-Window-0.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySide2-Frameless-Window
3
- Version: 0.3.10
3
+ Version: 0.4.0
4
4
  Summary: A cross-platform frameless window based on pyside2, support Win32, Linux and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/Pyside2
6
6
  Author: zhiyiYo
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySide2-Frameless-Window
3
- Version: 0.3.10
3
+ Version: 0.4.0
4
4
  Summary: A cross-platform frameless window based on pyside2, support Win32, Linux and macOS.
5
5
  Home-page: https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/Pyside2
6
6
  Author: zhiyiYo
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Frameless-Window/tree/
12
12
  :license: LGPLv3, see LICENSE for more details.
13
13
  """
14
14
 
15
- __version__ = "0.3.10"
15
+ __version__ = "0.4.0"
16
16
  __author__ = "zhiyiYo"
17
17
 
18
18
  import sys
@@ -1,5 +1,5 @@
1
1
  # coding:utf-8
2
- from PySide2.QtCore import QCoreApplication, QEvent, Qt
2
+ from PySide2.QtCore import QCoreApplication, QEvent, Qt, QSize, QRect
3
3
  from PySide2.QtWidgets import QWidget
4
4
 
5
5
  from ..titlebar import TitleBar
@@ -14,6 +14,7 @@ class LinuxFramelessWindow(QWidget):
14
14
 
15
15
  def __init__(self, parent=None):
16
16
  super().__init__(parent=parent)
17
+ self._isSystemButtonVisible = False
17
18
 
18
19
  def _initFrameless(self):
19
20
  self.windowEffect = LinuxWindowEffect(self)
@@ -51,6 +52,24 @@ class LinuxFramelessWindow(QWidget):
51
52
  """ set whether resizing is enabled """
52
53
  self._isResizeEnabled = isEnabled
53
54
 
55
+ def isSystemButtonVisible(self):
56
+ """ Returns whether the system title bar button is visible """
57
+ return self._isSystemButtonVisible
58
+
59
+ def setSystemTitleBarButtonVisible(self, isVisible):
60
+ """ set the visibility of system title bar button, only works for macOS """
61
+ pass
62
+
63
+ def systemTitleBarRect(self, size: QSize) -> QRect:
64
+ """ Returns the system title bar rect, only works for macOS
65
+
66
+ Parameters
67
+ ----------
68
+ size: QSize
69
+ original system title bar rect
70
+ """
71
+ return QRect(0, 0, size.width(), size.height())
72
+
54
73
  def eventFilter(self, obj, event):
55
74
  et = event.type()
56
75
  if et != QEvent.MouseButtonPress and et != QEvent.MouseMove or not self._isResizeEnabled:
@@ -0,0 +1,160 @@
1
+ # coding:utf-8
2
+ import Cocoa
3
+ import objc
4
+ from PySide2.QtCore import QEvent, Qt, QRect, QSize, QPoint, QTimer
5
+ from PySide2.QtWidgets import QWidget
6
+
7
+ from ..titlebar import TitleBar
8
+ from .window_effect import MacWindowEffect
9
+
10
+
11
+ class MacFramelessWindow(QWidget):
12
+ """ Frameless window for Linux system """
13
+
14
+ def __init__(self, parent=None):
15
+ super().__init__(parent=parent)
16
+ self._isSystemButtonVisible = False
17
+
18
+ def _initFrameless(self):
19
+ self.windowEffect = MacWindowEffect(self)
20
+ # must enable acrylic effect before creating title bar
21
+ if isinstance(self, AcrylicWindow):
22
+ self.windowEffect.setAcrylicEffect(self.winId())
23
+
24
+ self.titleBar = TitleBar(self)
25
+ self._isResizeEnabled = True
26
+
27
+ self.updateFrameless()
28
+
29
+ self.resize(500, 500)
30
+ self.titleBar.raise_()
31
+
32
+ def updateFrameless(self):
33
+ view = objc.objc_object(c_void_p=self.winId().__int__())
34
+ self.__nsWindow = view.window()
35
+
36
+ # hide system title bar
37
+ self._hideSystemTitleBar()
38
+
39
+ def setTitleBar(self, titleBar):
40
+ """ set custom title bar
41
+
42
+ Parameters
43
+ ----------
44
+ titleBar: TitleBar
45
+ title bar
46
+ """
47
+ self.titleBar.deleteLater()
48
+ self.titleBar.hide()
49
+ self.titleBar = titleBar
50
+ self.titleBar.setParent(self)
51
+ self.titleBar.raise_()
52
+
53
+ def setResizeEnabled(self, isEnabled: bool):
54
+ """ set whether resizing is enabled """
55
+ self._isResizeEnabled = isEnabled
56
+
57
+ def resizeEvent(self, e):
58
+ super().resizeEvent(e)
59
+ self.titleBar.resize(self.width(), self.titleBar.height())
60
+
61
+ def paintEvent(self, e):
62
+ super().paintEvent(e)
63
+ self.setSystemTitleBarButtonVisible(self.isSystemButtonVisible())
64
+
65
+ def changeEvent(self, event):
66
+ if event.type() == QEvent.WindowStateChange:
67
+ self._hideSystemTitleBar(self.isSystemButtonVisible())
68
+
69
+ # Delay must be added, otherwise the buttons will be misplaced
70
+ QTimer.singleShot(1, self._updateSystemButtonRect)
71
+ elif event.type() == QEvent.Resize:
72
+ self._updateSystemButtonRect()
73
+
74
+ def _hideSystemTitleBar(self, showButton=False):
75
+ # extend view to title bar region
76
+ self.__nsWindow.setStyleMask_(
77
+ self.__nsWindow.styleMask() | Cocoa.NSFullSizeContentViewWindowMask)
78
+ self.__nsWindow.setTitlebarAppearsTransparent_(True)
79
+
80
+ # disable the moving behavior of system
81
+ self.__nsWindow.setMovableByWindowBackground_(False)
82
+ self.__nsWindow.setMovable_(False)
83
+
84
+ # hide title bar buttons and title
85
+ self.__nsWindow.setTitleVisibility_(Cocoa.NSWindowTitleHidden)
86
+ self.setSystemTitleBarButtonVisible(showButton)
87
+
88
+ def isSystemButtonVisible(self):
89
+ return self._isSystemButtonVisible
90
+
91
+ def setSystemTitleBarButtonVisible(self, isVisible):
92
+ self._isSystemButtonVisible = isVisible
93
+ self.__nsWindow.setShowsToolbarButton_(isVisible)
94
+
95
+ isHidden = not isVisible
96
+ self.__nsWindow.standardWindowButton_(Cocoa.NSWindowCloseButton).setHidden_(isHidden)
97
+ self.__nsWindow.standardWindowButton_(Cocoa.NSWindowZoomButton).setHidden_(isHidden)
98
+ self.__nsWindow.standardWindowButton_(Cocoa.NSWindowMiniaturizeButton).setHidden_(isHidden)
99
+
100
+ if isVisible:
101
+ self._updateSystemButtonRect()
102
+
103
+ def _updateSystemButtonRect(self):
104
+ if not self.isSystemButtonVisible():
105
+ return
106
+
107
+ # get system title bar button
108
+ leftButton = self.__nsWindow.standardWindowButton_(Cocoa.NSWindowCloseButton)
109
+ midButton = self.__nsWindow.standardWindowButton_(Cocoa.NSWindowMiniaturizeButton)
110
+ rightButton = self.__nsWindow.standardWindowButton_(Cocoa.NSWindowZoomButton)
111
+
112
+ # get system title bar
113
+ titlebar = rightButton.superview()
114
+ titlebarHeight = int(titlebar.frame().size.height)
115
+
116
+ spacing = midButton.frame().origin.x - leftButton.frame().origin.x
117
+ width = midButton.frame().size.width
118
+ height = midButton.frame().size.height
119
+
120
+ if self.__nsWindow.contentView():
121
+ viewSize = self.__nsWindow.contentView().frame().size
122
+ else:
123
+ viewSize = self.__nsWindow.frame().size
124
+
125
+ center = self.systemTitleBarRect(QSize(int(viewSize.width), titlebarHeight)).center()
126
+
127
+ # The origin of the NSWindow coordinate system is in the lower left corner, we do the necessary transformations
128
+ center.setY(titlebarHeight - center.y())
129
+
130
+ # adjust the position of minimize button
131
+ centerOrigin = Cocoa.NSPoint(center.x() - width // 2, center.y() - height // 2)
132
+ midButton.setFrameOrigin_(centerOrigin)
133
+
134
+ # adjust the position of close button
135
+ leftOrigin = Cocoa.NSPoint(centerOrigin.x - spacing, centerOrigin.y)
136
+ leftButton.setFrameOrigin_(leftOrigin)
137
+
138
+ # adjust the position of zoom button
139
+ rightOrigin = Cocoa.NSPoint(centerOrigin.x + spacing, centerOrigin.y)
140
+ rightButton.setFrameOrigin_(rightOrigin)
141
+
142
+ def systemTitleBarRect(self, size: QSize) -> QRect:
143
+ """ Returns the system title bar rect
144
+
145
+ Parameters
146
+ ----------
147
+ size: QSize
148
+ original system title bar rect
149
+ """
150
+ return QRect(0, 0, 75, size.height())
151
+
152
+
153
+ class AcrylicWindow(MacFramelessWindow):
154
+ """ A frameless window with acrylic effect """
155
+
156
+ def _initFrameless(self):
157
+ super()._initFrameless()
158
+ self.setAttribute(Qt.WA_TranslucentBackground)
159
+ self.windowEffect.setAcrylicEffect(self.winId())
160
+ self.setStyleSheet("background: transparent")
@@ -6,7 +6,7 @@ from ctypes.wintypes import LPRECT, MSG
6
6
  import win32api
7
7
  import win32con
8
8
  import win32gui
9
- from PySide2.QtCore import Qt
9
+ from PySide2.QtCore import Qt, QSize, QRect
10
10
  from PySide2.QtGui import QCloseEvent, QCursor
11
11
  from PySide2.QtWidgets import QApplication, QWidget
12
12
  from PySide2.QtWinExtras import QtWin
@@ -25,6 +25,7 @@ class WindowsFramelessWindow(QWidget):
25
25
 
26
26
  def __init__(self, parent=None):
27
27
  super().__init__(parent=parent)
28
+ self._isSystemButtonVisible = False
28
29
 
29
30
  def _initFrameless(self):
30
31
  self.windowEffect = WindowsWindowEffect(self)
@@ -76,6 +77,24 @@ class WindowsFramelessWindow(QWidget):
76
77
  super().resizeEvent(e)
77
78
  self.titleBar.resize(self.width(), self.titleBar.height())
78
79
 
80
+ def isSystemButtonVisible(self):
81
+ """ Returns whether the system title bar button is visible """
82
+ return self._isSystemButtonVisible
83
+
84
+ def setSystemTitleBarButtonVisible(self, isVisible):
85
+ """ set the visibility of system title bar button, only works for macOS """
86
+ pass
87
+
88
+ def systemTitleBarRect(self, size: QSize) -> QRect:
89
+ """ Returns the system title bar rect, only works for macOS
90
+
91
+ Parameters
92
+ ----------
93
+ size: QSize
94
+ original system title bar rect
95
+ """
96
+ return QRect(0, 0, size.width(), size.height())
97
+
79
98
  def nativeEvent(self, eventType, message):
80
99
  """ Handle the Windows message """
81
100
  msg = MSG.from_address(message.__int__())
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
6
6
 
7
7
  setuptools.setup(
8
8
  name="PySide2-Frameless-Window",
9
- version="0.3.10",
9
+ version="0.4.0",
10
10
  keywords="pyside2 frameless",
11
11
  author="zhiyiYo",
12
12
  author_email="shokokawaii@outlook.com",
@@ -1,94 +0,0 @@
1
- # coding:utf-8
2
- import Cocoa
3
- import objc
4
- from PySide2.QtCore import QEvent, Qt
5
- from PySide2.QtWidgets import QWidget
6
-
7
- from ..titlebar import TitleBar
8
- from .window_effect import MacWindowEffect
9
-
10
-
11
- class MacFramelessWindow(QWidget):
12
- """ Frameless window for Linux system """
13
-
14
- def __init__(self, parent=None):
15
- super().__init__(parent=parent)
16
-
17
- def _initFrameless(self):
18
- self.windowEffect = MacWindowEffect(self)
19
- # must enable acrylic effect before creating title bar
20
- if isinstance(self, AcrylicWindow):
21
- self.windowEffect.setAcrylicEffect(self.winId())
22
-
23
- self.titleBar = TitleBar(self)
24
- self._isResizeEnabled = True
25
-
26
- self.updateFrameless()
27
-
28
- self.resize(500, 500)
29
- self.titleBar.raise_()
30
-
31
- def updateFrameless(self):
32
- view = objc.objc_object(c_void_p=self.winId().__int__())
33
- self.__nsWindow = view.window()
34
-
35
- # hide system title bar
36
- self.__hideSystemTitleBar()
37
-
38
- def setTitleBar(self, titleBar):
39
- """ set custom title bar
40
-
41
- Parameters
42
- ----------
43
- titleBar: TitleBar
44
- title bar
45
- """
46
- self.titleBar.deleteLater()
47
- self.titleBar.hide()
48
- self.titleBar = titleBar
49
- self.titleBar.setParent(self)
50
- self.titleBar.raise_()
51
-
52
- def setResizeEnabled(self, isEnabled: bool):
53
- """ set whether resizing is enabled """
54
- self._isResizeEnabled = isEnabled
55
-
56
- def resizeEvent(self, e):
57
- super().resizeEvent(e)
58
- self.titleBar.resize(self.width(), self.titleBar.height())
59
-
60
- def paintEvent(self, e):
61
- super().paintEvent(e)
62
- self.__hideSystemTitleBar()
63
-
64
- def changeEvent(self, event):
65
- super().changeEvent(event)
66
- if event.type() == QEvent.WindowStateChange:
67
- self.__hideSystemTitleBar()
68
-
69
- def __hideSystemTitleBar(self):
70
- # extend view to title bar region
71
- self.__nsWindow.setStyleMask_(
72
- self.__nsWindow.styleMask() | Cocoa.NSFullSizeContentViewWindowMask)
73
- self.__nsWindow.setTitlebarAppearsTransparent_(True)
74
-
75
- # disable the moving behavior of system
76
- self.__nsWindow.setMovableByWindowBackground_(False)
77
- self.__nsWindow.setMovable_(False)
78
-
79
- # hide title bar buttons and title
80
- self.__nsWindow.setShowsToolbarButton_(False)
81
- self.__nsWindow.setTitleVisibility_(Cocoa.NSWindowTitleHidden)
82
- self.__nsWindow.standardWindowButton_(Cocoa.NSWindowCloseButton).setHidden_(True)
83
- self.__nsWindow.standardWindowButton_(Cocoa.NSWindowZoomButton).setHidden_(True)
84
- self.__nsWindow.standardWindowButton_(Cocoa.NSWindowMiniaturizeButton).setHidden_(True)
85
-
86
-
87
- class AcrylicWindow(MacFramelessWindow):
88
- """ A frameless window with acrylic effect """
89
-
90
- def _initFrameless(self):
91
- super()._initFrameless()
92
- self.setAttribute(Qt.WA_TranslucentBackground)
93
- self.windowEffect.setAcrylicEffect(self.winId())
94
- self.setStyleSheet("background: transparent")