main.py 2.6 KB
Newer Older
Antoine Lima's avatar
Base UI  
Antoine Lima committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 18:34:40 2018

@author: limalayla
"""
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

from PyQt5.QtCore import QTime
from PyQt5 import QtWidgets
Antoine Lima's avatar
Antoine Lima committed
17

Antoine Lima's avatar
Base UI  
Antoine Lima committed
18
from main_ui import Ui_MainWindow
Antoine Lima's avatar
Antoine Lima committed
19
20
from menu_ui import Ui_Form as Menu_Form
from options_ui import Ui_Form as Options_Form
Antoine Lima's avatar
Base UI  
Antoine Lima committed
21
22
23
24
25
26

class MainWin(QtWidgets.QMainWindow):
	def __init__(self, parent=None):
		QtWidgets.QWidget.__init__(self, parent)
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)
Antoine Lima's avatar
Antoine Lima committed
27
28
		
		self.switchPanel(MenuPanel(self))
Antoine Lima's avatar
Base UI  
Antoine Lima committed
29
30
31
32
33
34
35

	def timerEvent(self, e): 
		self.displaySystemTime()

	def displaySystemTime(self):
		self.ui.lcdNumber.display(QTime.currentTime().toString("hh:mm:ss"))

Antoine Lima's avatar
Antoine Lima committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
	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)

Antoine Lima's avatar
Base UI  
Antoine Lima committed
58
59
	def ui_handleClick_btnStart(self):
		print('start')
Antoine Lima's avatar
Antoine Lima committed
60
		self.parent().parent().parent().showFullScreen()
Antoine Lima's avatar
Base UI  
Antoine Lima committed
61
62

	def ui_handleClick_btnOptions(self):
Antoine Lima's avatar
Antoine Lima committed
63
64
		print('options', self.parent(), self.parent().parent(), self.parent().parent().parent())
		self.parent().parent().parent().switchPanel(OptionsPanel(self.parent().parent().parent()))
Antoine Lima's avatar
Base UI  
Antoine Lima committed
65
66
67

	def ui_handleClick_btnExit(self):
		print('exit')
Antoine Lima's avatar
Antoine Lima committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
		self.parent().parent().parent().close()

class OptionsPanel(QtWidgets.QWidget):
	def __init__(self, parent=None):
		QtWidgets.QWidget.__init__(self, parent)

		# UI Setup
		self.ui = Options_Form()
		self.ui.setupUi(self)

		# Button connections
		self.ui.btnBack.clicked.connect(self.ui_handleClick_btnBack)

	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()))
Antoine Lima's avatar
Base UI  
Antoine Lima committed
84
85
86
87
88
89

if __name__=='__main__':
	app = QtWidgets.QApplication(sys.argv)
	myapp = MainWin()
	myapp.show()
	app.exec_()