Repository navigation
Expand file tree
/
Copy pathexample.py
More file actions
56 lines (45 loc) · 2.02 KB
/
Copy pathexample.py
File metadata and controls
56 lines (45 loc) · 2.02 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
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLabel, QFrame, QSizePolicy
class clockWidget(QLabel):
def __init__(self, fixedTime=''):
super(clockWidget, self).__init__()
self.setText(f"Clock: {fixedTime}")
class Form(QWidget):
""" Creates the main GUI form """
def __init__(self, parent=None, fixedTime=''):
super(Form, self).__init__(parent)
self.showFullScreen()
self.setObjectName("MainWindow")
self.resize(800, 480)
self.setMaximumSize(800, 480)
myStyleSheet = "QWidget { background-color: white; }" # Example style
self.setStyleSheet(myStyleSheet)
# Main layout
self.main_layout = QVBoxLayout()
# Top container with fixed size
self.top_container = QFrame()
self.top_container.setFixedSize(800, 400) # Set fixed size for the top container
self.top_layout = QVBoxLayout(self.top_container)
# Clock widget
self.clock = clockWidget(fixedTime=fixedTime)
self.top_layout.addWidget(self.clock)
# Quit button
self.quitButton = QPushButton("Quit")
self.quitButton.setFixedSize(20, 20)
self.quitButton.clicked.connect(self.close) # Close the application
self.top_layout.addWidget(self.quitButton)
# Add the top container to the main layout
self.main_layout.addWidget(self.top_container)
# Bottom fixed row with specific height
self.bottom_row = QLabel('Fixed Bottom Row')
self.bottom_row.setFixedSize(800, 80) # Set fixed size for the bottom row
self.bottom_row.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # Ensure it doesn't resize
self.main_layout.addWidget(self.bottom_row)
# Set the main layout to the widget
self.setLayout(self.main_layout)
# Run the application
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Form(fixedTime="12:00 PM") # Example fixed time
window.show()
sys.exit(app.exec_())