Coverage for GuiTourneyViewer.py: 0%
72 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-28 16:41 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-28 16:41 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
4#Copyright 2010-2011 Steffen Schaumburg
5#This program is free software: you can redistribute it and/or modify
6#it under the terms of the GNU Affero General Public License as published by
7#the Free Software Foundation, version 3 of the License.
8#
9#This program is distributed in the hope that it will be useful,
10#but WITHOUT ANY WARRANTY; without even the implied warranty of
11#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12#GNU General Public License for more details.
13#
14#You should have received a copy of the GNU Affero General Public License
15#along with this program. If not, see <http://www.gnu.org/licenses/>.
16#In the "official" distribution you can find the license in agpl-3.0.txt.
22#import L10n
23#_ = L10n.get_translation()
26from PyQt5.QtCore import QCoreApplication, QSortFilterProxyModel, Qt
27from PyQt5.QtGui import (QPainter, QPixmap, QStandardItem, QStandardItemModel)
28from PyQt5.QtWidgets import (QApplication, QFrame, QMenu,
29 QProgressDialog, QScrollArea, QSplitter,
30 QTableView, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton,QGridLayout ,QWidget ,QTableWidget ,QTableWidgetItem,QComboBox, QMessageBox)
32class GuiTourneyViewer(QWidget):
33 def __init__(self, config, db, sql, mainwin):
34 QWidget.__init__(self, mainwin)
35 self.db = db
36 self.mainwin = mainwin
37 #self.mainVBox = gtk.VBox()
38 #self.mainVBox = QVBoxLayout()
39 #self.interfaceHBox = gtk.HBox()
40 self.interfaceHBox = QVBoxLayout()
41 #self.mainVBox.pack_start(self.interfaceHBox, expand=False)
42 #self.mainVBox.addWidget(self.interfaceHBox)
43 self.setLayout(self.interfaceHBox)
45 #self.siteBox = gtk.combo_box_new_text()
46 self.siteBox = QComboBox()
47 for count, site in enumerate(config.supported_sites, start=1):
48 print(site)
49 #self.siteBox.append_text(site)
50 self.siteBox.insertItem(count,site)
51 #self.siteBox.set_active(0)
52 self.interfaceHBox.addWidget(self.siteBox)
54 #label=gtk.Label(("Enter the tourney number you want to display:"))
55 self.label_tour = QLabel()
56 self.label_tour.setText("Enter the tourney number you want to display:")
57 self.interfaceHBox.addWidget(self.label_tour)
59 #self.entryTourney = gtk.Entry()
60 self.entryTourney = QLineEdit()
61 self.interfaceHBox.addWidget(self.entryTourney)
63 #self.displayButton = gtk.Button(("Display"))
67 self.label_Player = QLabel()
68 self.label_Player.setText("Enter the player you want to display:")
69 self.interfaceHBox.addWidget(self.label_Player)
70 #self.entryPlayer = gtk.Entry()
71 self.entryPlayer = QLineEdit()
72 self.interfaceHBox.addWidget(self.entryPlayer)
74 #self.playerButton = gtk.Button(("Display Player"))
75 # self.playerButton = QPushButton()
76 # self.playerButton.setText("Display Player")
77 # self.playerButton.clicked.connect(self.displayPlayerClicked)
78 # self.interfaceHBox.addWidget(self.playerButton)
79 self.displayButton = QPushButton()
80 self.displayButton.setText("Display")
81 self.interfaceHBox.addWidget(self.displayButton)
82 self.displayButton.clicked.connect(self.displayClicked)
83 # self.table = gtk.Table(columns=10, rows=9)
85 self.table = QTableWidget()
86 self.interfaceHBox.addWidget(self.table)
91 # self.mainVBox.show_all()
92 #end def __init__
93 def warning_box(self, string, diatitle=("FPDB WARNING")):
94 return QMessageBox(QMessageBox.Warning, diatitle, string).exec_()
96 def displayClicked(self, widget, data=None):
97 if self.siteBox.currentText() == "" or self.entryPlayer.text() == "" or self.entryTourney.text() == "":
98 self.warning_box("you must enter Site Name, player Name and Tourney Number")
99 else:
100 self.siteName = self.siteBox.currentText()
101 self.playerName = self.entryPlayer.text()
102 self.tourneyNo = int(self.entryTourney.text())
103 result = self.db.getTourneyInfo(self.siteName, self.tourneyNo)
104 rows = len(result)
105 columns = len(result[0])
106 self.table.setColumnCount(columns)
107 self.table.setRowCount(rows)
109 if result[1] == None:
111 self.errorLabel = QLabel.setText(("Tournament not found.") + " " + ("Please ensure you imported it and selected the correct site."))
112 self.interfaceHBox.addWidget(self.errorLabel)
113 else:
114 for row in range(rows): # add items from array to QTableWidget
115 for column in range(columns):
116 if column == 0:
117 item = QTableWidgetItem(str(result[row][column]))
118 else:
119 item = QTableWidgetItem(str(result[row][column]))
120 print(type(row))
121 print(type(column))
122 print(type(item))
123 self.table.setItem(row, column, QTableWidgetItem(item))
126 #self.mainVBox.show_all()
127 #def displayClicked
129 # def displayPlayerClicked(self, widget, data=None):
130 # self.siteName = self.siteBox.currentText()
131 # self.playerName = self.entryPlayer.text()
132 # self.tourneyNo = int(self.entryTourney.text())
133 # result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName)
134 # rows = len(result)
135 # columns = len(result[0])
136 # self.table.setColumnCount(columns)
137 # self.table.setRowCount(rows)
139 # if result[1] == None:
141 # self.errorLabel = QLabel.setText(("Tournament not found.") + " " + ("Please ensure you imported it and selected the correct site."))
142 # self.interfaceHBox.addWidget(self.errorLabel)
143 # else:
144 # for row in range(rows): # add items from array to QTableWidget
145 # for column in range(columns):
146 # if column == 0:
147 # item = QTableWidgetItem(str(result[row][column]))
148 # else:
149 # item = QTableWidgetItem(str(result[row][column]))
150 # print(type(row))
151 # print(type(column))
152 # print(type(item))
153 # self.table.setItem(row, column, QTableWidgetItem(item))
156 #self.mainVBox.show_all()
157 #def displayPlayerClicked
159 def get_vbox(self):
160 """returns the vbox of this thread"""
161 return self.mainVBox
162 #end def get_vbox
164 def prepare(self, columns, rows):
165 try: self.errorLabel.destroy()
166 except: pass
168 try:
169 self.tourneyNo=int(self.entryTourney.text())
170 except ValueError:
171 self.errorLabel=QLabel()
172 self.errorLabel.setText("invalid entry in tourney number - must enter numbers only")
173 self.interfaceHBox.addWidget(self.errorLabel)
174 return False
175 self.siteName=self.siteBox.currentText()
176 self.playerName=self.entryPlayer.text()
178 #self.table.destroyed()
179 self.table=QGridLayout()
181 return True
182 #end def readInfo
183#end class GuiTourneyViewer