Added basic Qt MainWindow (with all boilerplate code)

This commit is contained in:
Blue Fox 2023-07-08 19:13:05 +02:00
parent d0cf04194d
commit 3878dba288
5 changed files with 178 additions and 0 deletions

2
.gitignore vendored
View File

@ -0,0 +1,2 @@
Scorganizr.pyproject.user
__pycache__/

3
Scorganizr.pyproject Normal file
View File

@ -0,0 +1,3 @@
{
"files": ["main.py", "form.ui"]
}

84
form.ui Normal file
View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<height>408</height>
</rect>
</property>
<property name="windowTitle">
<string>Scorganizr</string>
</property>
<property name="windowIcon">
<iconset theme="insert-image">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="documentMode">
<bool>false</bool>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="tearOffEnabled">
<bool>false</bool>
</property>
<property name="title">
<string>File</string>
</property>
<property name="separatorsCollapsible">
<bool>false</bool>
</property>
<property name="toolTipsVisible">
<bool>false</bool>
</property>
<addaction name="actionQuit"/>
</widget>
<addaction name="menuFile"/>
</widget>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
</widget>
<resources/>
<connections>
<connection>
<sender>actionQuit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>358</x>
<y>203</y>
</hint>
</hints>
</connection>
</connections>
</ui>

19
main.py Normal file
View File

@ -0,0 +1,19 @@
# This Python file uses the following encoding: utf-8
import sys
from PySide6.QtWidgets import QApplication, QMainWindow
from ui_form import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = MainWindow()
widget.show()
sys.exit(app.exec())

70
ui_form.py Normal file
View File

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'form.ui'
##
## Created by: Qt User Interface Compiler version 6.5.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient,
QCursor, QFont, QFontDatabase, QGradient,
QIcon, QImage, QKeySequence, QLinearGradient,
QPainter, QPalette, QPixmap, QRadialGradient,
QTransform)
from PySide6.QtWidgets import (QApplication, QMainWindow, QMenu, QMenuBar,
QSizePolicy, QTabWidget, QWidget)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(718, 408)
icon = QIcon()
iconThemeName = u"insert-image"
if QIcon.hasThemeIcon(iconThemeName):
icon = QIcon.fromTheme(iconThemeName)
else:
icon.addFile(u".", QSize(), QIcon.Normal, QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setAnimated(True)
MainWindow.setDocumentMode(False)
MainWindow.setTabShape(QTabWidget.Rounded)
self.actionQuit = QAction(MainWindow)
self.actionQuit.setObjectName(u"actionQuit")
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 718, 20))
self.menuFile = QMenu(self.menubar)
self.menuFile.setObjectName(u"menuFile")
self.menuFile.setTearOffEnabled(False)
self.menuFile.setSeparatorsCollapsible(False)
self.menuFile.setToolTipsVisible(False)
MainWindow.setMenuBar(self.menubar)
self.menubar.addAction(self.menuFile.menuAction())
self.menuFile.addAction(self.actionQuit)
self.retranslateUi(MainWindow)
self.actionQuit.triggered.connect(MainWindow.close)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Scorganizr", None))
self.actionQuit.setText(QCoreApplication.translate("MainWindow", u"Quit", None))
#if QT_CONFIG(shortcut)
self.actionQuit.setShortcut(QCoreApplication.translate("MainWindow", u"Ctrl+Q", None))
#endif // QT_CONFIG(shortcut)
self.menuFile.setTitle(QCoreApplication.translate("MainWindow", u"File", None))
# retranslateUi