mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-18 01:08:12 +00:00
Add About window and basic commands to MenuBar (#113)
* Initial commit for about_window.py * Add some basic actions to the MenuBar * Fix keyboard shortcuts * Fix path to icon for Windows
This commit is contained in:
74
src/ui/about_window.py
Normal file
74
src/ui/about_window.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtGui import QPixmap
|
||||
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QHBoxLayout
|
||||
|
||||
from version import *
|
||||
|
||||
|
||||
class AboutDialog(QDialog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle(f"About {APP_NAME}")
|
||||
|
||||
# Create the layout
|
||||
layout = QVBoxLayout()
|
||||
|
||||
# App Icon
|
||||
icon_name = 'Server.png' # todo: temp icon - replace with final later
|
||||
icon_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||
'resources', icon_name)
|
||||
icon_label = QLabel(self)
|
||||
icon_pixmap = QPixmap(icon_path)
|
||||
icon_label.setPixmap(icon_pixmap)
|
||||
icon_layout = QHBoxLayout()
|
||||
icon_layout.addStretch()
|
||||
icon_layout.addWidget(icon_label)
|
||||
icon_layout.addStretch()
|
||||
layout.addLayout(icon_layout)
|
||||
|
||||
# Application name
|
||||
name_label = QLabel(f"<h2>{APP_NAME}</h2>")
|
||||
layout.addWidget(name_label)
|
||||
|
||||
# Description
|
||||
description_label = QLabel(APP_DESCRIPTION)
|
||||
layout.addWidget(description_label)
|
||||
|
||||
# Version
|
||||
version_label = QLabel(f"<strong>Version:</strong> {APP_VERSION}")
|
||||
layout.addWidget(version_label)
|
||||
|
||||
# Contributors
|
||||
contributors_label = QLabel(f"Copyright © {APP_COPYRIGHT_YEAR} {APP_AUTHOR}")
|
||||
layout.addWidget(contributors_label)
|
||||
|
||||
# License
|
||||
license_label = QLabel(f"Released under {APP_LICENSE}")
|
||||
layout.addWidget(license_label)
|
||||
|
||||
# Add an "OK" button to close the dialog
|
||||
button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
|
||||
button_box.accepted.connect(self.accept)
|
||||
layout.addWidget(button_box)
|
||||
|
||||
# Set the layout for the dialog
|
||||
self.setLayout(layout)
|
||||
|
||||
# Make the dialog non-resizable
|
||||
self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)
|
||||
self.setFixedSize(self.sizeHint())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# lazy load GUI frameworks
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
|
||||
# load application
|
||||
app: QApplication = QApplication(sys.argv)
|
||||
window: AboutDialog = AboutDialog()
|
||||
window.show()
|
||||
|
||||
app.exec()
|
||||
Reference in New Issue
Block a user