コード例 #1
0
ファイル: players.py プロジェクト: wachjose88/stat466-desktop
 def __fill_list(self):
     """
     Fills the QListWidget of the players with all players from db.
     """
     self.list_of_players.clear()
     self.all_players = Player.get()
     for p in self.all_players:
         self.list_of_players.addItem(p.name + ' ' + p.fullname)
コード例 #2
0
ファイル: games.py プロジェクト: wachjose88/stat466-desktop
 def __init__(self, parent = None):
     """
     Constructor: inits all elements of the widget. It offers an 
     analysis of games by specifying the players.
     It creates the actions and connects them to their methods.
     
     Keyword arguments:
     parent -- parent widget
     """
     QWidget.__init__(self, parent)
     self.parent = parent
     self.game = None
     self.all_players = Player.get()
     if len(self.all_players) < 4:
         error = QLabel(self.tr('Error!\nThere are not enough Players.'), self)
         error.move(30, 30)
         return
         
     greet = QLabel(self.tr('Analysis'), self)
     greet.setStyleSheet("""
         QLabel { 
             font-size: 12pt;
         }""")
      
     ok = QPushButton(self.tr('Print Analysis'), self)
     self.connect(ok, SIGNAL('clicked()'), 
         self.__handle_print)
      
     lbl_num = QLabel(self.tr('Games played:'), self)
     self.num = QLabel(' ', self)
     hbox_num = QHBoxLayout()
     hbox_num.addWidget(lbl_num)
     hbox_num.addWidget(self.num)
     
     mind = Game.getMinDate()
     d_from = QDate(1900, 1, 1)
     if mind is not None and len(mind) > 9:
         d_from = QDate.fromString(mind[0:10], 'yyyy-MM-dd')
     lbl_start_date = QLabel(self.tr('From:'), self)
     self.start_date = QDateEdit(d_from, self)
     self.start_date.setDisplayFormat('dd.MM.yyyy')
     self.start_date.setMinimumDate(QDate(1900, 1, 1))
     self.start_date.setMaximumDate(QDate(3000, 1, 1))
     lbl_end_date = QLabel(self.tr('To:'), self)
     self.end_date = QDateEdit(QDate.currentDate (), self)
     self.end_date.setDisplayFormat('dd.MM.yyyy')
     self.end_date.setMinimumDate(QDate(1900, 1, 1))
     self.end_date.setMaximumDate(QDate(3000, 1, 1))
     hbox_start_date = QHBoxLayout()
     hbox_start_date.addStretch(1)
     hbox_start_date.addWidget(lbl_start_date)
     hbox_start_date.addWidget(self.start_date)
     hbox_start_date.addSpacing(11)
     hbox_start_date.addWidget(lbl_end_date)
     hbox_start_date.addWidget(self.end_date)
     hbox_start_date.addStretch(1)
     
     vbox_game = QVBoxLayout()
     vbox_game.addWidget(greet)
     vbox_game.addStretch(2)
     vbox_game.addLayout(hbox_start_date)
     vbox_game.addStretch(2)
     vbox_game.addLayout(hbox_num)
     vbox_game.addStretch(1)
     
     lbl_t1 = QLabel(self.tr('Team 1:'), self)
     vbox_game.addWidget(lbl_t1)
     self.combo_t1_p1 = self.__fill_combo()
     vbox_game.addWidget(self.combo_t1_p1)
     self.combo_t1_p2 = self.__fill_combo(1)
     vbox_game.addWidget(self.combo_t1_p2)
     self.points_t1 = QLabel(' ', self)
     hbox_pt1 = QHBoxLayout()
     lbl_p1 = QLabel(self.tr('Points:'), self)
     hbox_pt1.addWidget(lbl_p1)
     hbox_pt1.addWidget(self.points_t1)
     vbox_game.addLayout(hbox_pt1)
     self.diff_t1 = QLabel(' ', self)
     hbox_diff_t1 = QHBoxLayout()
     lbl_diff_t1 = QLabel(self.tr('Difference:'), self)
     hbox_diff_t1.addWidget(lbl_diff_t1)
     hbox_diff_t1.addWidget(self.diff_t1)
     vbox_game.addLayout(hbox_diff_t1)
     self.avg_t1 = QLabel(' ', self)
     lbl_a1 = QLabel(self.tr('AVG Points per Game:'), self)
     hbox_avg1 = QHBoxLayout()
     hbox_avg1.addWidget(lbl_a1)
     hbox_avg1.addWidget(self.avg_t1)
     vbox_game.addLayout(hbox_avg1)
     vbox_game.addStretch(1)
     lbl_t2 = QLabel(self.tr('Team 2:'), self)
     vbox_game.addWidget(lbl_t2)
     self.combo_t2_p1 = self.__fill_combo(2)
     vbox_game.addWidget(self.combo_t2_p1)
     self.combo_t2_p2 = self.__fill_combo(3)
     vbox_game.addWidget(self.combo_t2_p2)
     self.points_t2 = QLabel(' ', self)
     lbl_p2 = QLabel(self.tr('Points:'), self)
     hbox_pt2 = QHBoxLayout()
     hbox_pt2.addWidget(lbl_p2)
     hbox_pt2.addWidget(self.points_t2)
     vbox_game.addLayout(hbox_pt2)
     self.diff_t2 = QLabel(' ', self)
     hbox_diff_t2 = QHBoxLayout()
     lbl_diff_t2 = QLabel(self.tr('Difference:'), self)
     hbox_diff_t2.addWidget(lbl_diff_t2)
     hbox_diff_t2.addWidget(self.diff_t2)
     vbox_game.addLayout(hbox_diff_t2)
     self.avg_t2 = QLabel(' ', self)
     lbl_a2 = QLabel(self.tr('AVG Points per Game:'), self)
     hbox_avg2 = QHBoxLayout()
     hbox_avg2.addWidget(lbl_a2)
     hbox_avg2.addWidget(self.avg_t2)
     vbox_game.addLayout(hbox_avg2)
     vbox_game.addStretch(2)
     
     vbox_game.addWidget(ok)
     
     self.setLayout(vbox_game)
     
     self.preview = QPrintPreviewDialog()
     self.connect(self.preview,
         SIGNAL("paintRequested (QPrinter *)"),self.__print)
     self.connect(self.combo_t1_p1,
         SIGNAL("currentIndexChanged (int)"),self.__handle_ok)
     self.connect(self.combo_t1_p2,
         SIGNAL("currentIndexChanged (int)"),self.__handle_ok)
     self.connect(self.combo_t2_p1,
         SIGNAL("currentIndexChanged (int)"),self.__handle_ok)
     self.connect(self.combo_t2_p2,
         SIGNAL("currentIndexChanged (int)"),self.__handle_ok)
     self.connect(self.start_date,
         SIGNAL("dateChanged (const QDate&)"),self.__handle_ok)
     self.connect(self.end_date,
         SIGNAL("dateChanged (const QDate&)"),self.__handle_ok)
     self.__handle_ok()
コード例 #3
0
ファイル: games.py プロジェクト: wachjose88/stat466-desktop
 def __init__(self, parent = None):
     """
     Constructor: inits all elements of the widget. It offers a 
     calendar, combo- and input boxes to create a game.
     It creates the actions and connects them to their methods.
     
     Keyword arguments:
     parent -- parent widget
     """
     QWidget.__init__(self, parent)
     self.parent = parent
     self.game = None
     self.all_players = Player.get()
     if len(self.all_players) < 4:
         error = QLabel(self.tr('Error!\nThere are not enough Players.'), self)
         error.move(30, 30)
         return
     
     greet = QLabel(self.tr('Create a new Game'), self)
     greet.setStyleSheet("""
         QLabel { 
             font-size: 12pt;
         }""")
     at_lbl = QLabel(self.tr('Played at:'), self)
     
     self.calendar = QCalendarWidget()
     self.calendar.setMinimumDate(QDate(1900, 1, 1))
     self.calendar.setMaximumDate(QDate(3000, 1, 1))
     self.calendar.setGridVisible(True)
     self.calendar.setFirstDayOfWeek(Qt.Monday)
     
     save = QPushButton(self.tr('Save Game'), self)
     self.connect(save, SIGNAL('clicked()'), 
         self.__handle_save)
         
     chancel = QPushButton(self.tr('Chancel'), self)
     self.connect(chancel, SIGNAL('clicked()'), 
         self.__handle_chancel) 
      
     lbl_time = QLabel(self.tr('Time:'), self)
     self.time = QTimeEdit(QTime.currentTime (), self)
     hbox_time = QHBoxLayout()
     hbox_time.addWidget(lbl_time)
     hbox_time.addWidget(self.time)
     
     lbl_game = QLabel(self.tr('Game:'), self)
     vbox_game = QVBoxLayout()
     vbox_game.addWidget(lbl_game)
     vbox_game.addStretch(1)
     
     
     lbl_t1 = QLabel(self.tr('Team 1:'), self)
     vbox_game.addWidget(lbl_t1)
     self.combo_t1_p1 = self.__fill_combo()
     vbox_game.addWidget(self.combo_t1_p1)
     self.combo_t1_p2 = self.__fill_combo(1)
     vbox_game.addWidget(self.combo_t1_p2)
     self.points_t1 = QLineEdit()
     hbox_pt1 = QHBoxLayout()
     lbl_p1 = QLabel(self.tr('Points:'), self)
     hbox_pt1.addWidget(lbl_p1)
     hbox_pt1.addWidget(self.points_t1)
     vbox_game.addLayout(hbox_pt1)
     vbox_game.addStretch(1)
     lbl_t2 = QLabel(self.tr('Team 2:'), self)
     vbox_game.addWidget(lbl_t2)
     self.combo_t2_p1 = self.__fill_combo(2)
     vbox_game.addWidget(self.combo_t2_p1)
     self.combo_t2_p2 = self.__fill_combo(3)
     vbox_game.addWidget(self.combo_t2_p2)
     self.points_t2 = QLineEdit()
     lbl_p2 = QLabel(self.tr('Points:'), self)
     hbox_pt2 = QHBoxLayout()
     hbox_pt2.addWidget(lbl_p2)
     hbox_pt2.addWidget(self.points_t2)
     vbox_game.addLayout(hbox_pt2)
     vbox_game.addStretch(2)
     
     hbox_btns = QHBoxLayout()
     hbox_btns.addStretch(2)
     hbox_btns.addWidget(save)
     hbox_btns.addWidget(chancel)
     vbox_at = QVBoxLayout()
     vbox_at.addWidget(at_lbl)
     vbox_at.addWidget(self.calendar)
     vbox_at.addLayout(hbox_time)
     hbox_all = QHBoxLayout()
     hbox_all.addLayout(vbox_at)
     hbox_all.addLayout(vbox_game)
     vbox = QVBoxLayout()
     vbox.addWidget(greet)
     vbox.addLayout(hbox_all)
     vbox.addLayout(hbox_btns)
     
     self.setLayout(vbox)