Browse Source

Adding players is now working

Sebastian Lohff 6 years ago
parent
commit
c75098f8ce
2 changed files with 15 additions and 5 deletions
  1. 6
    1
      game.py
  2. 9
    4
      windows.py

+ 6
- 1
game.py View File

@@ -28,9 +28,14 @@ class SeopardyGame(QtGui.QWidget):
28 28
 		if self.gamestate.get_state() == "start":
29 29
 			QtCore.QCoreApplication.postEvent(self, GameStartEvent())
30 30
 
31
-	def add_player(self):
31
+	def add_player(self, addToGui=False):
32 32
 		self.players.append(Player.gen_player(len(self.players)+1, self))
33 33
 
34
+		if addToGui:
35
+			if len(self.players) > 1:
36
+				self.playerBar.addStretch()
37
+			self.playerBar.addWidget(self.players[-1])
38
+
34 39
 	def _createGui(self):
35 40
 		""" Create the board from questions. """
36 41
 

+ 9
- 4
windows.py View File

@@ -348,12 +348,17 @@ class PlayerStartWindow(QtGui.QDialog):
348 348
 
349 349
 	def event(self, e):
350 350
 		if e.type() == ButtonEvent.eventType:
351
-			if e.get_playerno() <= len(self.players)+1:
352
-				if e.get_playerno() == len(self.players)+1:
351
+			if e.get_playerno() <= len(self._players)+1:
352
+				if e.get_playerno() == len(self._players)+1:
353 353
 					# add a new player
354
-					self._parent.add_player()
354
+					self._parent.add_player(addToGui=True)
355 355
 					self._guiAddPlayer(self._players[-1])
356
-				self.playergrid.itemAtPosition(e.get_playerno()-1, 1).selectAll()
356
+
357
+				layoutItem = self.playerGrid.itemAtPosition(e.get_playerno(), 1)
358
+				if layoutItem:
359
+					widget = layoutItem.widget()
360
+					widget.selectAll()
361
+					widget.setFocus()
357 362
 			return True
358 363
 		else:
359 364
 			return super(PlayerStartWindow, self).event(e)

Loading…
Cancel
Save