コード例 #1
0
    def start(self):
        app = QtGui.QApplication(sys.argv)
        self.main_window = QtGui.QWidget()
        self.main_window.resize(WINDOW_HEIGHT, WINDOW_WIDTH)
        self.main_window.setWindowTitle('Hockey probability app')
        app.setWindowIcon(QtGui.QIcon(join(dirname(sys.argv[0]), 'hokey.png')))
        self.main_layout = QtGui.QVBoxLayout()

        self.teams = get_teams_stats_urls(teams_list_url, headers)

        team_names = [team_name for team_name, _ in self.teams.items()]
        team_combo_box_1 = teams_combo_box(team_names)
        team_combo_box_2 = teams_combo_box(team_names)
        team_combo_box_1.currentIndexChanged['QString'].connect(self.team_combo_box_callback('team1'))
        team_combo_box_2.currentIndexChanged['QString'].connect(self.team_combo_box_callback('team2'))
        buttons_layout = QtGui.QGridLayout()
        buttons_layout.addWidget(team_combo_box_1, 0, 0)
        buttons_layout.addWidget(team_combo_box_2, 0, 1)
        calculate_btn = QtGui.QPushButton('Calculate probabilities')
        calculate_btn.clicked.connect(self.calculate_btn_callback)
        self.tabs = construct_tabs({})
        self.main_layout.addWidget(self.tabs)
        self.main_layout.addLayout(buttons_layout)
        self.main_layout.addWidget(calculate_btn)
        self.team1 = team_combo_box_1.currentText()
        self.team2 = team_combo_box_2.currentText()
        self.main_window.setLayout(self.main_layout)
        self.main_window.show()
        sys.exit(app.exec_())
コード例 #2
0
 def test_get_teams_stats_urls(self):
     base = "http://espn.go.com/nhl"
     url = "%s/teams" % base
     for team_name, team_stats_url in get_teams_stats_urls(url, {}).items():
         self.assertTrue(team_stats_url.startswith(base), "Url: %s does not stats with %s" % (team_stats_url, base))
         print((team_name, team_stats_url))