class LoadGames(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.ui = Ui_loadGames() self.ui.setupUi(self) self.loadData() def loadData(self): model = QStandardItemModel() self.games = Game.loadFromFile() items = [] for g in self.games: items.append(str(g)) for i in items: model.appendRow( QStandardItem(i) ) self.ui.listView.setModel(model) def on_pushButton_3_clicked(self): self.close() def on_pushButton_clicked(self): sel = self.ui.listView.selectedIndexes() if len(sel) == 1: g = self.games[ sel[0].row() ] self.parent().newGame(g.userName, g.seconds, g.board) self.close()
def __init__(self, parent): QDialog.__init__(self, parent) self.ui = Ui_loadGames() self.ui.setupUi(self) self.loadData()