Commit dfa09c81 authored by Antoine Lima's avatar Antoine Lima

UI v0.3

parent 7b83de26
......@@ -10,4 +10,14 @@ The UI is done with PyQt.
* Convert the .ui files to python sources (`pyuic5 file.ui -o file_ui.py`)
* Done!
## UI Organisation
The software is composed of only one window in which "panels" change. There are currently 3 panels:
* The main menu, default panel shown on startup
* The game itself, containing the scores, timers, ...
* The options menu, to configure some options
Those panels are stacked (in a QStackedWidget) and only one of them can be shown at a time.
We can then "swap" from one to the other, making sure to unload the previous and to load the )
For better control over what is being run, panels can be unloaded when swapped and re-loaded when shown again.
This can be done through two overloadable functions: load and unload.
Each panel (inheriting from the Panel class) can use those to perform actions when shown or hidden
\ No newline at end of file
<RCC>
<qresource prefix="img">
<file>bg0.jpg</file>
</qresource>
</RCC>
This source diff could not be displayed because it is too large. You can view the blob instead.
WARNING:root:Unimplemented method
DEBUG:root:start
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score1
DEBUG:root:cancel
WARNING:root:Unimplemented method
DEBUG:root:exit
WARNING:root:Unimplemented method
DEBUG:root:start
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score2
DEBUG:root:score1
DEBUG:root:score1
DEBUG:root:score1
DEBUG:root:score1
DEBUG:root:cancel
WARNING:root:Unimplemented method
DEBUG:root:exit
bg0.jpg

29.3 KB

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1080</width>
<height>727</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">#btnScore1, #btnScore2 {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 white, stop: 1 rgb(168, 170, 184));
color: black;
border-style: solid;
border-width:1px;
border-radius:14ex;
border-color: green;
max-width:200px;
max-height:200px;
min-width:200px;
min-height:200px;
}
</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnScore1">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnScore2">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLCDNumber" name="lcdChrono">
<property name="minimumSize">
<size>
<width>0</width>
<height>75</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="smallDecimalPoint">
<bool>false</bool>
</property>
<property name="digitCount">
<number>8</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'game.ui'
#
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(1080, 727)
Form.setStyleSheet("#btnScore1, #btnScore2 {\n"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 white, stop: 1 rgb(168, 170, 184));\n"
"color: black;\n"
" border-style: solid;\n"
" border-width:1px;\n"
" border-radius:14ex;\n"
" border-color: green;\n"
" max-width:200px;\n"
" max-height:200px;\n"
" min-width:200px;\n"
" min-height:200px;\n"
"}\n"
"")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
self.verticalLayout.addItem(spacerItem)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.btnScore1 = QtWidgets.QPushButton(Form)
self.btnScore1.setObjectName("btnScore1")
self.horizontalLayout.addWidget(self.btnScore1)
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem2)
self.btnScore2 = QtWidgets.QPushButton(Form)
self.btnScore2.setObjectName("btnScore2")
self.horizontalLayout.addWidget(self.btnScore2)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem3)
self.verticalLayout.addLayout(self.horizontalLayout)
spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
self.verticalLayout.addItem(spacerItem4)
self.lcdChrono = QtWidgets.QLCDNumber(Form)
self.lcdChrono.setMinimumSize(QtCore.QSize(0, 75))
self.lcdChrono.setFrameShape(QtWidgets.QFrame.NoFrame)
self.lcdChrono.setSmallDecimalPoint(False)
self.lcdChrono.setDigitCount(8)
self.lcdChrono.setObjectName("lcdChrono")
self.verticalLayout.addWidget(self.lcdChrono)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem5)
self.btnCancel = QtWidgets.QPushButton(Form)
self.btnCancel.setObjectName("btnCancel")
self.horizontalLayout_2.addWidget(self.btnCancel)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.btnScore1.setText(_translate("Form", "0"))
self.btnScore2.setText(_translate("Form", "0"))
self.btnCancel.setText(_translate("Form", "Cancel"))
......@@ -3,87 +3,42 @@
"""
Created on Wed Apr 18 18:34:40 2018
@author: limalayla
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
import sys
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm, mm
from math import ceil
import sys
import logging
from PyQt5.QtCore import QTime
from PyQt5 import QtWidgets
from PyQt5.QtCore import QTime
from main_ui import Ui_MainWindow
from menu_ui import Ui_Form as Menu_Form
from options_ui import Ui_Form as Options_Form
from panels import MenuPanel, GamePanel, OptionsPanel
class MainWin(QtWidgets.QMainWindow):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.switchPanel(MenuPanel(self))
def timerEvent(self, e):
self.displaySystemTime()
def displaySystemTime(self):
self.ui.lcdNumber.display(QTime.currentTime().toString("hh:mm:ss"))
def switchPanel(self, panel):
print("switching from {} to {} (size {})".format(self.ui.stackedWidget.currentWidget(), panel, self.ui.stackedWidget.count()))
#self.ui.panel = panel
self.ui.stackedWidget.removeWidget(self.ui.stackedWidget.currentWidget())
self.ui.stackedWidget.addWidget(panel)
self.ui.stackedWidget.setCurrentIndex(self.ui.stackedWidget.count()-1)
class MenuPanel(QtWidgets.QWidget):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
# UI Setup
self.ui = Menu_Form()
self.ui.setupUi(self)
#self.displaySystemTime()
#self.startTimer(1000)
# Button connections
self.ui.btn0Start.clicked.connect(self.ui_handleClick_btnStart)
self.ui.btn1Options.clicked.connect(self.ui_handleClick_btnOptions)
self.ui.btn2Exit.clicked.connect(self.ui_handleClick_btnExit)
def ui_handleClick_btnStart(self):
print('start')
self.parent().parent().parent().showFullScreen()
def ui_handleClick_btnOptions(self):
print('options', self.parent(), self.parent().parent(), self.parent().parent().parent())
self.parent().parent().parent().switchPanel(OptionsPanel(self.parent().parent().parent()))
def ui_handleClick_btnExit(self):
print('exit')
self.parent().parent().parent().close()
class OptionsPanel(QtWidgets.QWidget):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.ui.panels.addWidget(MenuPanel(self))
self.ui.panels.addWidget(GamePanel(self))
self.ui.panels.addWidget(OptionsPanel(self))
self.ui.panels.setCurrentIndex(0)
# UI Setup
self.ui = Options_Form()
self.ui.setupUi(self)
self.displaySystemTime()
self.startTimer(1000)
# Button connections
self.ui.btnBack.clicked.connect(self.ui_handleClick_btnBack)
def timerEvent(self, e):
self.displaySystemTime()
def ui_handleClick_btnBack(self):
print('back', self.parent(), self.parent().parent(), self.parent().parent().parent())
self.parent().parent().parent().switchPanel(MenuPanel(self.parent().parent().parent()))
def displaySystemTime(self):
self.ui.lcdTime.display(QTime.currentTime().toString("hh:mm:ss"))
if __name__=='__main__':
app = QtWidgets.QApplication(sys.argv)
#logging.basicConfig(filename='babyfoot.log', level=logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)
myapp = MainWin()
myapp.show()
app.exec_()
app.exec_()
\ No newline at end of file
......@@ -44,6 +44,9 @@
<string>Babyfoot</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true">#centralWidget {border-image: url(:/img/bg0.jpg) 0 0 0 0 stretch stretch; }</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
......@@ -64,22 +67,17 @@
</spacer>
</item>
<item>
<widget class="QLCDNumber" name="lcdNumber">
<widget class="QLCDNumber" name="lcdTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QLCDNumber{
color: rgb(56, 56, 63);
}</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="numDigits">
<property name="digitCount">
<number>8</number>
</property>
<property name="segmentStyle">
......@@ -90,7 +88,10 @@
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QStackedWidget" name="panels">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
......@@ -99,6 +100,8 @@
</layout>
</widget>
</widget>
<resources/>
<resources>
<include location="assets.qrc"/>
</resources>
<connections/>
</ui>
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!
......@@ -22,6 +22,7 @@ class Ui_MainWindow(object):
MainWindow.setSizeIncrement(QtCore.QSize(1, 1))
MainWindow.setBaseSize(QtCore.QSize(640, 360))
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setStyleSheet("#centralWidget {border-image: url(:/img/bg0.jpg) 0 0 0 0 stretch stretch; }")
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName("verticalLayout")
......@@ -30,31 +31,30 @@ class Ui_MainWindow(object):
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.lcdNumber = QtWidgets.QLCDNumber(self.centralwidget)
self.lcdTime = QtWidgets.QLCDNumber(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lcdNumber.sizePolicy().hasHeightForWidth())
self.lcdNumber.setSizePolicy(sizePolicy)
self.lcdNumber.setStyleSheet("QLCDNumber{\n"
" color: rgb(56, 56, 63);\n"
"}")
self.lcdNumber.setFrameShape(QtWidgets.QFrame.NoFrame)
self.lcdNumber.setNumDigits(8)
self.lcdNumber.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
self.lcdNumber.setObjectName("lcdNumber")
self.horizontalLayout.addWidget(self.lcdNumber)
sizePolicy.setHeightForWidth(self.lcdTime.sizePolicy().hasHeightForWidth())
self.lcdTime.setSizePolicy(sizePolicy)
self.lcdTime.setFrameShape(QtWidgets.QFrame.NoFrame)
self.lcdTime.setDigitCount(8)
self.lcdTime.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
self.lcdTime.setObjectName("lcdTime")
self.horizontalLayout.addWidget(self.lcdTime)
self.verticalLayout.addLayout(self.horizontalLayout)
self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget)
self.stackedWidget.setObjectName("stackedWidget")
self.verticalLayout.addWidget(self.stackedWidget)
self.panels = QtWidgets.QStackedWidget(self.centralwidget)
self.panels.setAutoFillBackground(False)
self.panels.setObjectName("panels")
self.verticalLayout.addWidget(self.panels)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
self.stackedWidget.setCurrentIndex(-1)
self.panels.setCurrentIndex(-1)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Babyfoot"))
import assets_rc
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'menu.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!
......
......@@ -13,16 +13,87 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="btnBack">
<property name="text">
<string>Back</string>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>712</width>
<height>482</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableWidget" name="options">
<property name="showGrid">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnBack">
<property name="text">
<string>Back</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="assets.qrc"/>
</resources>
<connections/>
</ui>
......@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'options.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!
......@@ -12,11 +12,42 @@ class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(728, 540)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.scrollArea = QtWidgets.QScrollArea(Form)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 712, 482))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.options = QtWidgets.QTableWidget(self.scrollAreaWidgetContents)
self.options.setShowGrid(True)
self.options.setObjectName("options")
self.options.setColumnCount(2)
self.options.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.options.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.options.setHorizontalHeaderItem(1, item)
self.options.horizontalHeader().setVisible(True)
self.options.horizontalHeader().setStretchLastSection(True)
self.options.verticalHeader().setVisible(False)
self.verticalLayout_2.addWidget(self.options)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout.addWidget(self.scrollArea)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.btnSave = QtWidgets.QPushButton(Form)
self.btnSave.setObjectName("btnSave")
self.horizontalLayout.addWidget(self.btnSave)
self.btnBack = QtWidgets.QPushButton(Form)
self.btnBack.setObjectName("btnBack")
self.gridLayout.addWidget(self.btnBack, 0, 0, 1, 1)
self.horizontalLayout.addWidget(self.btnBack)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
......@@ -24,5 +55,11 @@ class Ui_Form(object):
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
item = self.options.horizontalHeaderItem(0)
item.setText(_translate("Form", "Name"))
item = self.options.horizontalHeaderItem(1)
item.setText(_translate("Form", "Value"))
self.btnSave.setText(_translate("Form", "Save"))
self.btnBack.setText(_translate("Form", "Back"))
import assets_rc
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 18:34:40 2018
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
import logging
from PyQt5 import QtWidgets
from PyQt5.QtCore import QTime, QTimer
from PyQt5.QtGui import QRegion
from PyQt5.QtWidgets import QTableWidgetItem, QComboBox
from menu_ui import Ui_Form as Menu_Form
from game_ui import Ui_Form as Game_Form
from options_ui import Ui_Form as Options_Form
class Panel(QtWidgets.QWidget):
def __init__(self, parent=None, form=None):
Panel.__dict_panels = {MenuPanel: 0, GamePanel: 1, OptionsPanel: 2}
# UI Setup
QtWidgets.QWidget.__init__(self, parent)
self.ui = form
self.ui.setupUi(self)
self.parentWin = parent
def switchPanel(self, newType):
panelIndex = Panel.__dict_panels.get(newType)
if panelIndex!=None:
self.parentWin.ui.panels.currentWidget().unload()
self.parentWin.ui.panels.setCurrentIndex(panelIndex)
self.parentWin.ui.panels.currentWidget().load()
else:
logging.error('Error: unknown panel {} in {}'.format(newType, self.__dict_panels))
def load(self):
logging.warning('Unimplemented method')
def unload(self):
logging.warning('Unimplemented method')
class MenuPanel(Panel):
def __init__(self, parent=None):
super().__init__(parent, Menu_Form())
# Button connections
self.ui.btn0Start.clicked.connect(self.ui_handleClick_btnStart)
self.ui.btn1Options.clicked.connect(self.ui_handleClick_btnOptions)