MCPcopy Index your code
hub / github.com/PyQt5/PyQt / __init__

Method __init__

Demo/Lib/FramelessWindow.py:147–172  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

145 Margins = 5
146
147 def __init__(self, *args, **kwargs):
148 super(FramelessWindow, self).__init__(*args, **kwargs)
149 self._pressed = False
150 self.Direction = None
151 # 背景透明
152 self.setAttribute(Qt.WA_TranslucentBackground, True)
153 # 无边框
154 self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
155 # 鼠标跟踪
156 self.setMouseTracking(True)
157 # 布局
158 layout = QVBoxLayout(self, spacing=0)
159 # 预留边界用于实现无边框窗口调整大小
160 layout.setContentsMargins(
161 self.Margins, self.Margins, self.Margins, self.Margins)
162 # 标题栏
163 self.titleBar = TitleBar(self)
164 layout.addWidget(self.titleBar)
165 # 信号槽
166 self.titleBar.windowMinimumed.connect(self.showMinimized)
167 self.titleBar.windowMaximumed.connect(self.showMaximized)
168 self.titleBar.windowNormaled.connect(self.showNormal)
169 self.titleBar.windowClosed.connect(self.close)
170 self.titleBar.windowMoved.connect(self.move)
171 self.windowTitleChanged.connect(self.titleBar.setTitle)
172 self.windowIconChanged.connect(self.titleBar.setIcon)
173
174 def setTitleBarHeight(self, height=38):
175 """设置标题栏高度"""

Callers

nothing calls this directly

Calls 3

TitleBarClass · 0.85
addWidgetMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected