/
SquadListGUI.py
85 lines (73 loc) · 2.31 KB
/
SquadListGUI.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import sys
from PyQt4.QtCore import *
from PyQt4 import QtGui
from PlayerDatabase import *
from AddPlayerGUI import *
from PlayerInfo import *
class SquadList(QMainWindow):
def __init__(self, parent):
super().__init__()
self.parent =parent
self.setWindowTitle("Squad List")
#Button set up
self.btnInfo = QPushButton("Info")
self.btnHome = QPushButton("Home")
self.btnNew = QPushButton("New")
#Widget set up
self.squad_list = QListWidget()
self.VlayoutMAIN = QVBoxLayout()
self.hlayout1 = QHBoxLayout()
self.hlayout1.addWidget(self.btnNew)
self.hlayout1.addWidget(self.btnInfo)
self.hlayout1.addWidget(self.btnHome)
self.VlayoutMAIN.addWidget(self.squad_list)
self.VlayoutMAIN.addLayout(self.hlayout1)
self.widget = QWidget()
self.widget.setLayout(self.VlayoutMAIN)
self.setCentralWidget(self.widget)
#Running the refresh_List function
self.refresh_List()
#Button connections
self.btnHome.clicked.connect(self.btnHome_pushed)
self.btnInfo.clicked.connect(self.btnInfo_pushed)
self.btnNew.clicked.connect(self.btnNew_pushed)
def btnHome_pushed(self):
#Show the parent window
self.parent.show()
#Close the current window
self.close()
def btnNew_pushed(self):
#Call the AddPlayer class
self.new_player = AddPlayer(self)
#Show the window
self.new_player.show()
#Raise the window to the front of the desktop
self.new_player.raise_()
#Hide the current window
self.hide()
def btnInfo_pushed(self):
#Call the PlayerInfo class
self.playerInfo = PlayerInfo(self)
#Show the window
self.playerInfo.show()
#Raise the window to the front of the desktop
self.playerInfo.raise_()
#Hide the current window
self.hide()
def refresh_List(self):
#Get all the players from the database(all entries)
players = g_database.GetAllPlayers()
row = -1
#Clears the list
self.squad_list.clear()
#Runs the loop for each entry player in the players table
for player in players:
row = row+1
#Sets up a blank list
name_list = ""
#Adds the forename intial to the list
name_list = name_list + (player[1][0]) + " "
#Adds the surname to the list
name_list = name_list + (player[2])
#Adds the player to the main list
self.squad_list.addItem(name_list)