main.py 2.06 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
Antoine Lima committed
11
from os.path import dirname, abspath, join
Antoine Lima's avatar
Base UI  
Antoine Lima committed
12
13

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

17
18
from ui.main_ui import Ui_MainWindow
from modules import *
Antoine Lima's avatar
Base UI  
Antoine Lima committed
19
20
21
22
23
24

class MainWin(QtWidgets.QMainWindow):
	def __init__(self, parent=None):
		QtWidgets.QWidget.__init__(self, parent)
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)
25
		
26
27
28
29
30
31
32
		#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
33
34
35
36
37
38
39
40
		self.modules = [
			MenuModule(self),
			AuthModule(self),
			GameModule(self),
			EndGameModule(self),
			LeaderboardModule(self),
			OptionsModule(self)
		]
41
42
		
		for mod in self.modules:
Antoine Lima's avatar
Antoine Lima committed
43
			self.ui.panels.addWidget(mod)
44
		
Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
45
		self.ui.panels.setCurrentIndex(0)
46
47
48
		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
49
50
		self.displaySystemTime()
		self.startTimer(1000)
51
52
53
	
	#def eventFilter(target, event):
	#	return event.type()==QEvent.KeyPress and event.key() not in acceptedKeys
Antoine Lima's avatar
Antoine Lima committed
54

Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
55
56
	def timerEvent(self, e):
		self.displaySystemTime()
Antoine Lima's avatar
Antoine Lima committed
57

Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
58
59
	def displaySystemTime(self):
		self.ui.lcdTime.display(QTime.currentTime().toString("hh:mm:ss"))
60
61
62
63
64
	
	@staticmethod
	def getContent(path):
		contentFolder = join(dirname(dirname(abspath(__file__))), 'content')
		return join(contentFolder, path)
Antoine Lima's avatar
Base UI  
Antoine Lima committed
65

66
67
68
69
70
71
72
73
74
75
	def _refreshAfterSettings(self):
		from settings import Settings
		
		if Settings.ui['fullscreen']:
			self.showFullScreen()
			QApplication.setOverrideCursor(Qt.BlankCursor);
		else:
			self.showNormal()
			QApplication.setOverrideCursor(Qt.ArrowCursor);
	
Antoine Lima's avatar
Base UI  
Antoine Lima committed
76
77
if __name__=='__main__':
	app = QtWidgets.QApplication(sys.argv)
Antoine Lima's avatar
UI v0.3  
Antoine Lima committed
78
79
	#logging.basicConfig(filename='babyfoot.log', level=logging.DEBUG)
	logging.basicConfig(level=logging.DEBUG)
Antoine Lima's avatar
Base UI  
Antoine Lima committed
80
81
	myapp = MainWin()
	myapp.show()
82
	app.exec_()