(self, var, transform=())
Set the variable to edit.
Set the variable to edit.
Set the variable to edit .
def set_data(self, var, transform=()):
        # type: (Optional[Variable], Sequence[Transform]) -> None
        """
        Set the variable to edit.
        """
        self.clear()
        self.var = var
        if var is not None:
            name = var.name
            annotations = var.annotations
            unlink = False
            for tr in transform:
                if isinstance(tr, Rename):
                    name = tr.name
                elif isinstance(tr, Annotate):
                    annotations = tr.annotations
                elif isinstance(tr, Unlink):
                    unlink = True
            self.name_edit.setText(name)
            self.labels_model.set_dict(dict(annotations))
            self.add_label_action.actionGroup().setEnabled(True)
            self.unlink_var_cb.setChecked(unlink)
        else:
            self.add_label_action.actionGroup().setEnabled(False)

        self.unlink_var_cb.setDisabled(var is None or not var.linked)
def set_data ( self , var , transform = ( ) ) : # type: (Optional[Variable], Sequence[Transform]) -> None self . clear ( ) self . var = var if var is not None : name = var . name annotations = var . annotations unlink = False for tr in transform : if isinstance ( tr , Rename ) : name = tr . name elif isinstance ( tr , Annotate ) : annotations = tr . annotations elif isinstance ( tr , Unlink ) : unlink = True self . name_edit . setText ( name ) self . labels_model . set_dict ( dict ( annotations ) ) self . add_label_action . actionGroup ( ) . setEnabled ( True ) self . unlink_var_cb . setChecked ( unlink ) else : self . add_label_action . actionGroup ( ) . setEnabled ( False ) self . unlink_var_cb . setDisabled ( var is None or not var . linked )