-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_widgets.py
More file actions
58 lines (45 loc) · 1.93 KB
/
test_widgets.py
File metadata and controls
58 lines (45 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import os
# ================= Setup Start =================
# Add install dir to sys.path
install_dir = os.path.join(os.getcwd(), "out", "install", "x64-msvc-Release")
sys.path.append(install_dir)
# ================= Setup End =================
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QPushButton
from PySide6.QtCore import Qt
from PySide6.QtGui import QGuiApplication
from PyQWindowKit import Widgets as QWKWidgets
class DemoWindow(QWidget):
def __init__(self):
super().__init__()
self.resize(800, 600)
# 1. Create the Agent
self.agent = QWKWidgets.WidgetWindowAgent(self)
# 2. Setup the window
self.agent.setup(self)
# 3. Setup UI
layout = QVBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
# Title Bar
self.title_bar = QWidget()
self.title_bar.setFixedHeight(30)
self.title_bar.setStyleSheet("background-color: #333; color: white;")
title_layout = QVBoxLayout(self.title_bar)
title_layout.setContentsMargins(10, 0, 0, 0)
title_label = QLabel("PyQWindowKit Widgets Demo")
title_layout.addWidget(title_label)
layout.addWidget(self.title_bar)
# Content
content = QLabel("Hello from QWidget + PyQWindowKit!")
content.setAlignment(Qt.AlignmentFlag.AlignCenter)
layout.addWidget(content)
# 4. Set Title Bar to Agent (enables dragging)
self.agent.setTitleBar(self.title_bar)
# 5. Add some system buttons behavior (optional/simulated for this demo)
# Note: Real system buttons need more setup, but dragging is the key feature to test.
if __name__ == "__main__":
QGuiApplication.setAttribute(Qt.ApplicationAttribute.AA_DontCreateNativeWidgetSiblings)
app = QApplication(sys.argv)
w = DemoWindow()
w.show()
sys.exit(app.exec())