-
Notifications
You must be signed in to change notification settings - Fork 0
/
score_board.py
52 lines (43 loc) · 2.1 KB
/
score_board.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from PyQt6.QtWidgets import QDockWidget, QVBoxLayout, QWidget, QLabel #TODO import additional Widget classes as desired
from PyQt6.QtCore import pyqtSlot
class ScoreBoard(QDockWidget):
'''# base the score_board on a QDockWidget'''
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
'''initiates ScoreBoard UI'''
self.resize(200, 200)
self.center()
self.setWindowTitle('ScoreBoard')
#create a widget to hold other widgets
self.mainWidget = QWidget()
self.mainLayout = QVBoxLayout()
#create two labels which will be updated by signals
self.label_clickLocation = QLabel("Click Location: ")
self.label_timeRemaining = QLabel("Time remaining: ")
self.mainWidget.setLayout(self.mainLayout)
self.mainLayout.addWidget(self.label_clickLocation)
self.mainLayout.addWidget(self.label_timeRemaining)
self.setWidget(self.mainWidget)
self.show()
def center(self):
'''centers the window on the screen, you do not need to implement this method'''
def make_connection(self, board):
'''this handles a signal sent from the board class'''
# when the clickLocationSignal is emitted in board the setClickLocation slot receives it
board.clickLocationSignal.connect(self.setClickLocation)
# when the updateTimerSignal is emitted in the board the setTimeRemaining slot receives it
board.updateTimerSignal.connect(self.setTimeRemaining)
@pyqtSlot(str) # checks to make sure that the following slot is receiving an argument of the type 'int'
def setClickLocation(self, clickLoc):
'''updates the label to show the click location'''
self.label_clickLocation.setText("Click Location:" + clickLoc)
print('slot ' + clickLoc)
@pyqtSlot(int)
def setTimeRemaining(self, timeRemainng):
'''updates the time remaining label to show the time remaining'''
update = "Time Remaining:" + str(timeRemainng)
self.label_timeRemaining.setText(update)
print('slot '+update)
# self.redraw()