<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_button(self, button, widget):
 """Update the icon of the button with the given widget if the widget does not is invalid, it is deleted from the tooltip automatically. :param button: the button to update :type button: QtGui.QAbstractButton :param widget: the widget to render as icon :type widget: QtGui.QWidget :returns: None :rtype: None :raises: None """

        if not shiboken.isValid(widget):
            self.remove_widget(widget)
            return
        button.setIconSize(QtCore.QSize(self._iconw, self._iconh))
        pix = QtGui.QPixmap(widget.size())
        widget.render(pix)
        icon = QtGui.QIcon(pix)
        button.setIcon(icon)