def __init__(self, model, attr): self.widget = QtGui.QCheckBox() self.model = model self.attr = attr self.widget.setChecked(getattr(self.model, self.attr))