Example #1
0
def reset_widgets_over() -> None:
    """
    Reset widget over.

    :return: None
    """
    check_widget_mouseleave(force=True)
Example #2
0
    def _append_widget(self, widget: 'Widget') -> None:
        assert isinstance(widget, Widget)
        if widget.get_menu() is None:
            widget.set_menu(self._menu)
        assert widget.get_menu() == self._menu, \
            'widget cannot have a different instance of menu'
        self._menu._check_id_duplicated(widget.get_id())

        if widget.get_scrollarea() is None:
            widget.set_scrollarea(self._menu.get_scrollarea())

        # Unselect
        widget.select(False)

        # Append to lists
        self._menu._widgets.append(widget)

        # Update selection index
        if self._menu._index < 0 and widget.is_selectable:
            widget.select()
            self._menu._index = len(self._menu._widgets) - 1

        # Force menu rendering, this checks if the menu overflows or has sizing
        # errors; if added on execution time forces the update of the surface
        self._menu._widgets_surface = None
        try:
            self._menu._render()
        except (pygame_menu.menu._MenuSizingException,
                pygame_menu.menu._MenuWidgetOverflow):
            self._menu.remove_widget(widget)
            raise
        self._menu.render()

        # Sort frame widgets, as render position changes frame position/frame
        if len(self._menu._update_frames) > 0:
            self._menu._update_frames[0]._sort_menu_update_frames()

        # Update widgets
        check_widget_mouseleave()

        # Call event
        widget._append_to_menu()