main.py 1.66 KB
Newer Older
Antoine Lima's avatar
Base UI  
Antoine Lima committed
1
2
3
4
5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 18:34:40 2018

Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
6
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
Antoine Lima's avatar
Base UI  
Antoine Lima committed
7
8
"""

Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
9
10
import sys
import logging
Antoine Lima's avatar
Base UI  
Antoine Lima committed
11
12

from PyQt5 import QtWidgets
13
14
from PyQt5.QtWidgets import QGraphicsBlurEffect
from PyQt5.QtCore import QTime, Qt
Antoine Lima's avatar
Antoine Lima committed
15

16
17
from ui.main_ui import Ui_MainWindow
from modules import *
Antoine Lima's avatar
Base UI  
Antoine Lima committed
18

19
20
#acceptedKeys = [Qt.Key_Escape, Qt.Key_Enter, Qt.Key_Return, Qt.UpArrow, Qt.DownArrow, Qt.LeftArrow, Qt.RightArrow]

Antoine Lima's avatar
Base UI  
Antoine Lima committed
21
22
23
24
25
class MainWin(QtWidgets.QMainWindow):
	def __init__(self, parent=None):
		QtWidgets.QWidget.__init__(self, parent)
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)
26
		
27
28
29
30
31
32
33
		#Background blur
		bgBlur = QGraphicsBlurEffect()
		bgBlur.setBlurHints(QGraphicsBlurEffect.QualityHint)
		#bgBlur.setBlurRadius(5)
		#self.ui.panels.setGraphicsEffect(bgBlur)
		
		# Module loading
Antoine Lima's avatar
Antoine Lima committed
34
		self.modules = [MenuModule, GameModule, OptionsModule, AuthModule, LeaderboardModule]
35
36
37
		
		for mod in self.modules:
			self.ui.panels.addWidget(mod(self))
38
		
Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
39
		self.ui.panels.setCurrentIndex(0)
40
41
42
		self.ui.panels.currentWidget().setFocus()
		self.ui.panels.currentWidget().grabKeyboard()
		self.ui.panels.currentWidget().load()
Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
43
44
		self.displaySystemTime()
		self.startTimer(1000)
45
46
47
	
	#def eventFilter(target, event):
	#	return event.type()==QEvent.KeyPress and event.key() not in acceptedKeys
Antoine Lima's avatar
Antoine Lima committed
48

Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
49
50
	def timerEvent(self, e):
		self.displaySystemTime()
Antoine Lima's avatar
Antoine Lima committed
51

Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
52
53
	def displaySystemTime(self):
		self.ui.lcdTime.display(QTime.currentTime().toString("hh:mm:ss"))
Antoine Lima's avatar
Base UI  
Antoine Lima committed
54
55
56

if __name__=='__main__':
	app = QtWidgets.QApplication(sys.argv)
Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
57
58
	#logging.basicConfig(filename='babyfoot.log', level=logging.DEBUG)
	logging.basicConfig(level=logging.DEBUG)
Antoine Lima's avatar
Base UI  
Antoine Lima committed
59
60
	myapp = MainWin()
	myapp.show()
61
	app.exec_()