<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_text(self, text):
 """ Set the text in the widget. """

        d = self.declaration
        if d.input_type == 'html':
            text = Spanned(__id__=Html.fromHtml(text))
        self.widget.setTextKeepState(text)