def translate_widget(self):
        """Translate widget out or inside screen."""
        attr_name, sign = VALUE_MAP[self.direction_name]
        is_hiding = next(self.is_hiding)

        ### keep or invert signal depending of 'is_hiding'
        sign *= 1 if is_hiding else -1

        ### calculate translation deltas (offset)
        ### and perform translation

        amount = getattr(self.widget.rect, attr_name) * sign

        if attr_name == "width":
            offset = [amount, 0]

        else:
            offset = [0, amount]

        self.widget.translate(*offset)

        ### change surf to appropriate one

        surf_name = "hidden" if is_hiding else "shown"
        self.image = SURFACE_MAP[surf_name]

        ### snap switch to its designated place
        self.snap_switch_to_widget()
Translate widget out or inside screen.
nodezator/hideswitch.py