-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListOfWidgets.py
More file actions
95 lines (76 loc) · 2.22 KB
/
ListOfWidgets.py
File metadata and controls
95 lines (76 loc) · 2.22 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from PyQt6.QtCore import Qt, QTimer, QSize
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import (
QApplication,
QCheckBox,
QComboBox,
QDateEdit,
QDateTimeEdit,
QDial,
QDoubleSpinBox,
QFontComboBox,
QLabel,
QLCDNumber,
QLineEdit,
QMainWindow,
QProgressBar,
QPushButton,
QRadioButton,
QSlider,
QSpinBox,
QTimeEdit,
QVBoxLayout,
QWidget,
)
import ctypes
# This code makes it so windows doesn't think Pythonw.exe's icon should be used for this window's icon
myappid = u'mycompany.myproduct.subproduct.version' #arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("List of Widgets")
self.setWindowIcon(QIcon("icons\\list.png"))
self.setMinimumSize(QSize(280, 600))
layout = QVBoxLayout()
widgets = [
QCheckBox,
QComboBox,
QDateEdit,
QDateTimeEdit,
QDial,
QDoubleSpinBox,
QFontComboBox,
QLCDNumber,
QLabel,
QLineEdit,
QProgressBar,
QPushButton,
QRadioButton,
QSlider,
QSpinBox,
QTimeEdit,
]
[layout.addWidget(w()) for w in widgets]
self.windowSizeButton = QPushButton("Print Window's Current Size")
self.windowSizeButton.clicked.connect(self.WindowSize)
self.windowSizeButton.setCheckable(True)
layout.addWidget(self.windowSizeButton)
self.timer = QTimer()
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
def WindowSize(self):
self.timer.setInterval(100)
self.timer.timeout.connect(self.printWindowSize)
self.timer.start()
def printWindowSize(self):
if self.windowSizeButton.isChecked():
self.timer.start()
if self.windowSizeButton.isChecked() != True:
self.timer.stop()
print(f"width: {window.size().width()}, height: {window.size().height()}")
app = QApplication([])
window = MainWindow()
window.show()
app.exec()