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_())
def calculate_btn_callback(self): raw_data_to_show = self.get_team_data_to_show() data_to_show = filter_data_to_show(raw_data_to_show) self.tabs.setParent(None) self.tabs = construct_tabs(data_to_show) self.main_layout.insertWidget(0, self.tabs)