def __init__(self, name, parent): super(Player, self).__init__() self.name = name self.score = 0 # create widget and add it to main window self.scoreboard = Ui_ScoreboardWidget() self.scoreboard.setupUi(parent) self.scoreboard.setLayout(self.scoreboard.verticalLayout_2) parent.ui.horizontalLayout.addWidget(self.scoreboard) self.scoreboard.setLayout(self.scoreboard.verticalLayout_2) # set up signals etc self.scoreboard.lblPlayername.setText(parent.ui.ledPlayerName.text()) self.scoreboard.btnPlus1.released.connect(self.btnPlus1_clicked) self.scoreboard.btnMinus1.released.connect(self.btnMinus1_clicked)
class Player(QtGui.QWidget): #class Player(object): def __init__(self, name, parent): super(Player, self).__init__() self.name = name self.score = 0 # create widget and add it to main window self.scoreboard = Ui_ScoreboardWidget() self.scoreboard.setupUi(parent) self.scoreboard.setLayout(self.scoreboard.verticalLayout_2) parent.ui.horizontalLayout.addWidget(self.scoreboard) self.scoreboard.setLayout(self.scoreboard.verticalLayout_2) # set up signals etc self.scoreboard.lblPlayername.setText(parent.ui.ledPlayerName.text()) self.scoreboard.btnPlus1.released.connect(self.btnPlus1_clicked) self.scoreboard.btnMinus1.released.connect(self.btnMinus1_clicked) def btnPlus1_clicked(self): self.score += 1 self.update_score() def btnMinus1_clicked(self): self.score -= 1 self.update_score() def update_score(self): self.scoreboard.lcdPoints.display(str(self.score)) self.emit(QtCore.SIGNAL('update_score'))
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_ScoreboardWidget() self.ui.setupUi(self)
class Form(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_ScoreboardWidget() self.ui.setupUi(self)