-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubclass_module.py
More file actions
53 lines (43 loc) · 1.3 KB
/
subclass_module.py
File metadata and controls
53 lines (43 loc) · 1.3 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
from PyQt6.QtCore import QSize, Qt
from PyQt6.QtGui import QAction, QIcon, QKeySequence
from PyQt6.QtWidgets import (
QApplication,
QMainWindow,
QLabel,
QCheckBox,
QStatusBar,
QToolBar,
QDialog,
QWidget,
QDialogButtonBox,
QVBoxLayout
)
from random import randint
class AnotherWindow(QWidget):
'''
This window is a QWidget. Without a parent, it will appear as
a free-floating window.
'''
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.label = QLabel(f"window {randint(0, 100)}")
layout.addWidget(self.label)
self.setFixedSize(QSize(300,200))
self.setLayout(layout)
# CUSTOM DIALOG BOX:
class CustomDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("HI.")
QBtn = (
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
)
self.buttonBox = QDialogButtonBox(QBtn)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
layout = QVBoxLayout()
message = QLabel("...Something just happened.")
layout.addWidget(message)
layout.addWidget(self.buttonBox)
self.setLayout(layout)