<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _write_widget(self, val):
 """Writes value into the widget. If specified, user setter is invoked."""

        self._itsme = True
        try:
            setter = self._wid_info[self._wid][1]
            wtype = self._wid_info[self._wid][2]
            if setter:
                if wtype is not None:
                    setter(self._wid, self._cast_value(val, wtype))
                else:
                    setter(self._wid, val)
        finally:
            self._itsme = False