diff --git a/docs/_source/add_widgets.rst b/docs/_source/add_widgets.rst index 149e49a5..3cf51a2e 100644 --- a/docs/_source/add_widgets.rst +++ b/docs/_source/add_widgets.rst @@ -633,6 +633,32 @@ more options, take a look at the ``ToggleSwitch`` widget class. .. automethod:: pygame_menu._widgetmanager.WidgetManager.toggle_switch +Add a vertical fill +------------------- + +A vertical fill adds a vertical margin to fill the menu height. It depends on other +vertical fillers in the same column, i.e., if three vertical fillers are in the same +column, them will take a third of the available vertical space. + +**Example:** + +.. image:: ../_static/widget_vfill.png + :scale: 75% + :align: center + +.. code-block:: python + + menu = pygame_menu.Menu(...) + + menu.add.vertical_fill() + menu.add.button('Button 1') + menu.add.vertical_fill() + menu.add.button('Button 2') + menu.add.vertical_fill() + +.. automethod:: pygame_menu._widgetmanager.WidgetManager.vertical_fill + + Add a vertical spacer --------------------- diff --git a/docs/_source/contributors.rst b/docs/_source/contributors.rst index 3d90c968..64f1990b 100644 --- a/docs/_source/contributors.rst +++ b/docs/_source/contributors.rst @@ -22,12 +22,15 @@ Other contributors: - `ironsmile `_ - `jwllee `_ - `maditnerd `_ +- `MayuSakurai `_ - `mrkprdo `_ - `notrurs `_ - `NullP01nt `_ - `PandaRoux8 `_ - `Rifqi31 `_ +- `ThePeeps191 `_ - `thisIsMikeKane `_ +- `vnmabus `_ - `werdeil `_ - `zPaw `_ diff --git a/docs/_source/widgets_button.rst b/docs/_source/widgets_button.rst index 5f12b08c..8d68fa91 100644 --- a/docs/_source/widgets_button.rst +++ b/docs/_source/widgets_button.rst @@ -9,4 +9,4 @@ Button :members: :show-inheritance: :inherited-members: - :exclude-members: draw_after_if_selected, set_onchange, change, set_default_value, set_value, reset_value, get_value, value_changed + :exclude-members: change, draw_after_if_selected, get_value, reset_value, set_default_value, set_onchange, set_value, value_changed diff --git a/docs/_source/widgets_colorinput.rst b/docs/_source/widgets_colorinput.rst index 258fedc0..72cd7d29 100644 --- a/docs/_source/widgets_colorinput.rst +++ b/docs/_source/widgets_colorinput.rst @@ -9,4 +9,4 @@ ColorInput :members: :show-inheritance: :inherited-members: - :exclude-members: draw_after_if_selected, rotate, scale, set_max_width, set_max_height, resize + :exclude-members: draw_after_if_selected, resize, rotate, scale, set_max_height, set_max_width diff --git a/docs/_source/widgets_dropselect.rst b/docs/_source/widgets_dropselect.rst index b5ca057f..5b06869a 100644 --- a/docs/_source/widgets_dropselect.rst +++ b/docs/_source/widgets_dropselect.rst @@ -9,4 +9,4 @@ DropSelect :members: :show-inheritance: :inherited-members: - :exclude-members: rotate, scale, set_max_width, set_max_height, resize, flip + :exclude-members: flip, resize, rotate, scale, set_max_height, set_max_width diff --git a/docs/_source/widgets_dropselect_multiple.rst b/docs/_source/widgets_dropselect_multiple.rst index 1d6883f3..0f0c02fa 100644 --- a/docs/_source/widgets_dropselect_multiple.rst +++ b/docs/_source/widgets_dropselect_multiple.rst @@ -9,4 +9,4 @@ DropSelectMultiple :members: :show-inheritance: :inherited-members: - :exclude-members: rotate, scale, set_max_width, set_max_height, resize, flip + :exclude-members: flip, resize, rotate, scale, set_max_height, set_max_width diff --git a/docs/_source/widgets_frame.rst b/docs/_source/widgets_frame.rst index 0f5e8a47..3b6c6dab 100644 --- a/docs/_source/widgets_frame.rst +++ b/docs/_source/widgets_frame.rst @@ -9,4 +9,4 @@ Frame :members: :show-inheritance: :inherited-members: - :exclude-members: draw_after_if_selected, get_sound, get_selection_effect, get_selected_time, get_value, set_onreturn, set_onchange, set_default_value, reset_value, value_changed, is_selected, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_selection_effect, apply, change, flip, set_max_width, set_max_height, scale, rotate, select, set_shadow, set_sound, set_value + :exclude-members: apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_font_color_status, get_selected_time, get_selection_effect, get_sound, get_value, is_selected, reset_value, rotate, scale, select, set_default_value, set_max_height, set_max_width, set_onchange, set_onreturn, set_onselect, set_selection_effect, set_shadow, set_sound, set_value, value_changed diff --git a/docs/_source/widgets_hmargin.rst b/docs/_source/widgets_hmargin.rst index ee6c45ac..f6667707 100644 --- a/docs/_source/widgets_hmargin.rst +++ b/docs/_source/widgets_hmargin.rst @@ -9,4 +9,4 @@ HMargin :members: :show-inheritance: :inherited-members: - :exclude-members: set_tab_size, set_font_shadow, set_margin, get_margin, get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, set_default_value, reset_value, value_changed, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, set_background_color, set_selection_effect, apply, change, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, set_border, get_border, draw_after_if_selected + :exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update diff --git a/docs/_source/widgets_image.rst b/docs/_source/widgets_image.rst index 19b07a31..840c4602 100644 --- a/docs/_source/widgets_image.rst +++ b/docs/_source/widgets_image.rst @@ -9,4 +9,4 @@ Image :members: :show-inheritance: :inherited-members: - :exclude-members: set_font, get_font_info, draw_after_if_selected, set_sound, get_sound, get_font_color_status, get_value, value_changed, set_tab_size, set_font_shadow, update_font, set_title, get_title, update, set_onchange, set_onreturn, change, apply, set_default_value, set_value, reset_value + :exclude-members: apply, change, draw_after_if_selected, get_font_color_status, get_font_info, get_sound, get_title, get_value, reset_value, set_default_value, set_font, set_font_shadow, set_onchange, set_onreturn, set_sound, set_tab_size, set_title, set_value, update, update_font, value_changed diff --git a/docs/_source/widgets_label.rst b/docs/_source/widgets_label.rst index afe79685..0085ef8a 100644 --- a/docs/_source/widgets_label.rst +++ b/docs/_source/widgets_label.rst @@ -9,4 +9,4 @@ Label :members: :show-inheritance: :inherited-members: - :exclude-members: draw_after_if_selected, update, set_onchange, set_onreturn, change, apply, set_default_value, set_value, reset_value, get_value, value_changed, get_sound, set_sound + :exclude-members: apply, change, draw_after_if_selected, get_sound, get_value, reset_value, set_default_value, set_onchange, set_onreturn, set_sound, set_value, update, value_changed diff --git a/docs/_source/widgets_menubar.rst b/docs/_source/widgets_menubar.rst index 0944d7c3..30aed0f3 100644 --- a/docs/_source/widgets_menubar.rst +++ b/docs/_source/widgets_menubar.rst @@ -9,4 +9,4 @@ MenuBar :members: :show-inheritance: :inherited-members: - :exclude-members: get_value, select, set_onselect, change, set_onchange, set_padding, scale, resize, set_max_height, set_max_width, set_selection_effect, set_border, flip, rotate, set_default_value, set_value, reset_value, draw_after_if_selected, value_changed + :exclude-members: change, draw_after_if_selected, flip, get_value, reset_value, resize, rotate, scale, select, set_border, set_default_value, set_max_height, set_max_width, set_onchange, set_onselect, set_padding, set_selection_effect, set_value, value_changed diff --git a/docs/_source/widgets_menulink.rst b/docs/_source/widgets_menulink.rst index 8aa373c0..c351deac 100644 --- a/docs/_source/widgets_menulink.rst +++ b/docs/_source/widgets_menulink.rst @@ -9,4 +9,4 @@ MenuLink :members: :show-inheritance: :inherited-members: - :exclude-members: add_self_to_kwargs, add_draw_callback, apply_draw_callbacks, remove_draw_callback, get_alignment, get_border, get_decorator, get_frame, get_frame_depth, set_frame, get_focus_rect, get_height, get_margin, get_position, get_size, get_translate, get_width, set_float, draw_after_if_selected, set_tab_size, set_font_shadow, get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, value_changed, set_default_value, reset_value, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, get_rect, set_background_color, set_selection_effect, apply, change, set_margin, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, update, add_update_callback, remove_update_callback, apply_update_callbacks, set_border, draw + :exclude-members: add_draw_callback, add_self_to_kwargs, add_update_callback, apply, apply_draw_callbacks, apply_update_callbacks, background_inflate_to_selection_effect, change, draw, draw_after_if_selected, flip, get_alignment, get_border, get_decorator, get_focus_rect, get_font_color_status, get_font_info, get_frame, get_frame_depth, get_height, get_margin, get_padding, get_position, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, remove_draw_callback, remove_update_callback, reset_value, resize, rotate, scale, select, set_alignment, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_float, set_font, set_font_shadow, set_frame, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, translate, update, update_font, value_changed diff --git a/docs/_source/widgets_none.rst b/docs/_source/widgets_none.rst index a9d17790..e95d4043 100644 --- a/docs/_source/widgets_none.rst +++ b/docs/_source/widgets_none.rst @@ -9,4 +9,4 @@ NoneWidget :members: :show-inheritance: :inherited-members: - :exclude-members: get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, set_default_value, value_changed, reset_value, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, get_rect, set_background_color, set_selection_effect, apply, change, set_margin, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, set_border, set_font_shadow, get_border, draw_after_if_selected, get_height, get_width, get_size, get_margin + :exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update diff --git a/docs/_source/widgets_progressbar.rst b/docs/_source/widgets_progressbar.rst index 3a18508f..11f2d885 100644 --- a/docs/_source/widgets_progressbar.rst +++ b/docs/_source/widgets_progressbar.rst @@ -9,4 +9,4 @@ ProgressBar :members: :show-inheritance: :inherited-members: - :exclude-members: scale, resize, set_max_width, set_max_height, rotate, flip, draw_after_if_selected, change, apply, add_self_to_kwargs, get_sound, set_sound, set_onchange, set_onreturn + :exclude-members: add_self_to_kwargs, apply, change, draw_after_if_selected, flip, get_sound, resize, rotate, scale, set_max_height, set_max_width, set_onchange, set_onreturn, set_sound diff --git a/docs/_source/widgets_rangeslider.rst b/docs/_source/widgets_rangeslider.rst index 2cbab5f5..808e1e37 100644 --- a/docs/_source/widgets_rangeslider.rst +++ b/docs/_source/widgets_rangeslider.rst @@ -9,4 +9,4 @@ RangeSlider :members: :show-inheritance: :inherited-members: - :exclude-members: scale, resize, set_max_width, set_max_height, rotate, flip, + :exclude-members: flip, resize, rotate, scale, set_max_height, set_max_width diff --git a/docs/_source/widgets_scrollbar.rst b/docs/_source/widgets_scrollbar.rst index c37874d8..47c32f1d 100644 --- a/docs/_source/widgets_scrollbar.rst +++ b/docs/_source/widgets_scrollbar.rst @@ -9,4 +9,4 @@ ScrollBar :members: :show-inheritance: :inherited-members: - :exclude-members: set_selection_effect, background_inflate_to_selection_effect, get_selected_time, get_selection_effect, get_font_color_status, set_font, apply, set_onreturn, set_onselect, select, draw_after_if_selected, set_title, set_font_shadow, update_font, set_padding, scale, resize, set_max_width, set_max_height, rotate, flip + :exclude-members: apply, background_inflate_to_selection_effect, draw_after_if_selected, flip, get_font_color_status, get_selected_time, get_selection_effect, resize, rotate, scale, select, set_font, set_font_shadow, set_max_height, set_max_width, set_onreturn, set_onselect, set_padding, set_selection_effect, set_title, update_font diff --git a/docs/_source/widgets_surface.rst b/docs/_source/widgets_surface.rst index ce1bd9fd..ee24b7a3 100644 --- a/docs/_source/widgets_surface.rst +++ b/docs/_source/widgets_surface.rst @@ -9,4 +9,4 @@ SurfaceWidget :members: :show-inheritance: :inherited-members: - :exclude-members: set_controls, set_onchange, get_font_color_status, get_font_info, set_font, set_sound, get_sound, set_onreturn, draw_after_if_selected, get_value, set_value, get_title, reset_value, value_changed, set_title, apply, change, update_font, set_padding, scale, resize, set_max_width, set_max_height, rotate, flip, set_default_value, set_font_shadow, set_tab_size + :exclude-members: apply, change, draw_after_if_selected, flip, get_font_color_status, get_font_info, get_sound, get_title, get_value, reset_value, resize, rotate, scale, set_controls, set_default_value, set_font, set_font_shadow, set_max_height, set_max_width, set_onchange, set_onreturn, set_padding, set_sound, set_tab_size, set_title, set_value, update_font, value_changed diff --git a/docs/_source/widgets_table.rst b/docs/_source/widgets_table.rst index 2e5bcee8..2f7de2ca 100644 --- a/docs/_source/widgets_table.rst +++ b/docs/_source/widgets_table.rst @@ -9,4 +9,4 @@ Table :members: :show-inheritance: :inherited-members: - :exclude-members: update_indices, contains_widget, get_scroll_value_percentage, scrollh, scrollv, get_index, get_indices, make_scrollarea, sort_menu_update_frames, set_title, remove_title, add_title_generic_button, add_title_button, get_title, pack, unpack, get_sound, get_selection_effect, get_selected_time, get_value, value_changed, set_onreturn, set_onchange, set_default_value, reset_value, is_selected, background_inflate_to_selection_effect, set_onselect, set_selection_effect, apply, change, flip, set_max_width, set_max_height, scale, rotate, select, set_shadow, set_sound, set_value, set_tab_size, draw_after_if_selected + :exclude-members: add_title_button, add_title_generic_button, apply, background_inflate_to_selection_effect, change, contains_widget, draw_after_if_selected, flip, get_index, get_indices, get_scroll_value_percentage, get_selected_time, get_selection_effect, get_sound, get_title, get_value, is_selected, make_scrollarea, pack, remove_title, reset_value, rotate, scale, scrollh, scrollv, select, set_default_value, set_max_height, set_max_width, set_onchange, set_onreturn, set_onselect, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, sort_menu_update_frames, unpack, update_indices, value_changed diff --git a/docs/_source/widgets_textinput.rst b/docs/_source/widgets_textinput.rst index b3cde7dd..85b356ce 100644 --- a/docs/_source/widgets_textinput.rst +++ b/docs/_source/widgets_textinput.rst @@ -9,4 +9,4 @@ TextInput :members: :show-inheritance: :inherited-members: - :exclude-members: rotate, scale, set_max_width, set_max_height, resize, draw_after_if_selected + :exclude-members: draw_after_if_selected, resize, rotate, scale, set_max_height, set_max_width diff --git a/docs/_source/widgets_toggleswitch.rst b/docs/_source/widgets_toggleswitch.rst index 144d99e4..c057ccb8 100644 --- a/docs/_source/widgets_toggleswitch.rst +++ b/docs/_source/widgets_toggleswitch.rst @@ -9,4 +9,4 @@ ToggleSwitch :members: :show-inheritance: :inherited-members: - :exclude-members: scale, resize, set_max_width, set_max_height, rotate, flip, draw_after_if_selected + :exclude-members: draw_after_if_selected, flip, resize, rotate, scale, set_max_height, set_max_width diff --git a/docs/_source/widgets_vfill.rst b/docs/_source/widgets_vfill.rst new file mode 100644 index 00000000..5077585f --- /dev/null +++ b/docs/_source/widgets_vfill.rst @@ -0,0 +1,12 @@ + +.. module:: pygame_menu.widgets.widget.vfill + +===== +VFill +===== + +.. autoclass:: pygame_menu.widgets.VFill + :members: + :show-inheritance: + :inherited-members: + :exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update diff --git a/docs/_source/widgets_vmargin.rst b/docs/_source/widgets_vmargin.rst index 6688f5d9..44002f78 100644 --- a/docs/_source/widgets_vmargin.rst +++ b/docs/_source/widgets_vmargin.rst @@ -9,4 +9,4 @@ VMargin :members: :show-inheritance: :inherited-members: - :exclude-members: render, get_translate, get_size, get_width, add_self_to_kwargs, set_margin, get_margin, get_surface, get_sound, get_selection_effect, get_selected_time, get_padding, get_font_info, get_value, set_onreturn, set_onmouseover, set_onmouseleave, set_onchange, set_default_value, value_changed, reset_value, mouseover, mouseleave, is_selected, get_title, background_inflate_to_selection_effect, get_font_color_status, set_onselect, set_padding, set_title, set_background_color, set_selection_effect, apply, change, set_font, update_font, set_position, flip, set_max_width, set_max_height, scale, resize, translate, rotate, set_alignment, select, set_shadow, set_sound, set_cursor, set_controls, set_value, set_border, set_font_shadow, set_tab_size, get_border, draw_after_if_selected + :exclude-members: add_self_to_kwargs, apply, background_inflate_to_selection_effect, change, draw_after_if_selected, flip, get_border, get_focus_rect, get_font_color_status, get_font_info, get_height, get_margin, get_padding, get_rect, get_selected_time, get_selection_effect, get_size, get_sound, get_surface, get_title, get_translate, get_value, get_width, is_selected, mouseleave, mouseover, render, reset_value, resize, rotate, scale, select, set_background_color, set_border, set_controls, set_cursor, set_default_value, set_font, set_font_shadow, set_margin, set_max_height, set_max_width, set_onchange, set_onmouseleave, set_onmouseover, set_onreturn, set_onselect, set_padding, set_position, set_selection_effect, set_shadow, set_sound, set_tab_size, set_title, set_value, shadow, translate, update_font, value_changed, update diff --git a/docs/_static/widget_vfill.png b/docs/_static/widget_vfill.png new file mode 100644 index 00000000..79f0d204 Binary files /dev/null and b/docs/_static/widget_vfill.png differ diff --git a/docs/add_widgets.py b/docs/add_widgets.py index 4e4358b9..7ccf6274 100644 --- a/docs/add_widgets.py +++ b/docs/add_widgets.py @@ -24,7 +24,7 @@ pygame.display.set_icon(icon) # Set example, only this should change -EXAMPLE = 'PROGRESSBAR' +EXAMPLE = 'VERTICALFILL' # Create example menu: 'pygame_menu.Menu' @@ -385,6 +385,15 @@ def open_link(*args) -> None: menu.add.url('https://github.com/ppizarror/pygame-menu', 'The best menu ever') menu.add.url('https://pygame-menu.readthedocs.io/en/master/', 'pygame-menu documentation') +elif EXAMPLE == 'VERTICALFILL': + menu = make_menu(pygame_menu.themes.THEME_DEFAULT, 'Vertical fill') + + menu.add.vertical_fill() + menu.add.button('Button 1') + menu.add.vertical_fill() + menu.add.button('Button 2') + menu.add.vertical_fill() + elif EXAMPLE == 'VERTICALMARGIN': menu = make_menu(pygame_menu.themes.THEME_DEFAULT, 'Vertical spacer') diff --git a/docs/index.rst b/docs/index.rst index 2777c4fe..d6d564c1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -145,6 +145,7 @@ class. The currently existing classes are: - :py:class:`~pygame_menu.widgets.Table` - :py:class:`~pygame_menu.widgets.TextInput` - :py:class:`~pygame_menu.widgets.ToggleSwitch` + - :py:class:`~pygame_menu.widgets.VFill` - :py:class:`~pygame_menu.widgets.VMargin` For advanced programmers, those classes can be used to design custom menus or windows. @@ -177,6 +178,7 @@ to display large custom surfaces. _source/widgets_table _source/widgets_textinput _source/widgets_toggleswitch + _source/widgets_vfill _source/widgets_vmargin diff --git a/pygame_menu/__init__.py b/pygame_menu/__init__.py index 5031d97d..368d4a8d 100644 --- a/pygame_menu/__init__.py +++ b/pygame_menu/__init__.py @@ -105,12 +105,15 @@ 'ironsmile', 'jwllee', 'maditnerd', + 'MayuSakurai', 'mrkprdo', 'notrurs', 'NullP01nt', 'PandaRoux8', 'Rifqi31', + 'ThePeeps191', 'thisIsMikeKane', + 'vnmabus', 'werdeil', 'zPaw' diff --git a/pygame_menu/_widgetmanager.py b/pygame_menu/_widgetmanager.py index a760f6e1..0d560354 100644 --- a/pygame_menu/_widgetmanager.py +++ b/pygame_menu/_widgetmanager.py @@ -35,6 +35,7 @@ from pygame_menu.widgets.widget.table import TableManager from pygame_menu.widgets.widget.textinput import TextInputManager from pygame_menu.widgets.widget.toggleswitch import ToggleSwitchManager +from pygame_menu.widgets.widget.vfill import VFillManager from pygame_menu.widgets.widget.vmargin import VMarginManager from pygame_menu._types import Any, Dict, PaddingInstance @@ -60,6 +61,7 @@ class WidgetManager( TableManager, TextInputManager, ToggleSwitchManager, + VFillManager, VMarginManager ): """ diff --git a/pygame_menu/menu.py b/pygame_menu/menu.py index 99f76123..e924f235 100644 --- a/pygame_menu/menu.py +++ b/pygame_menu/menu.py @@ -3418,6 +3418,15 @@ def get_widget( return widget return None + def get_widgets_column(self, col: int) -> Tuple['Widget', ...]: + """ + Return all the widgets within column which are visible. + + :param col: Column number (start from zero) + :return: Widget list + """ + return tuple(self._widget_columns[col]) + def get_widgets(self, ids: Optional[Union[List[str], Tuple[str, ...]]] = None) -> Tuple['Widget', ...]: """ Return the Menu widgets as a tuple. diff --git a/pygame_menu/widgets/__init__.py b/pygame_menu/widgets/__init__.py index bd82f33c..164acc07 100644 --- a/pygame_menu/widgets/__init__.py +++ b/pygame_menu/widgets/__init__.py @@ -18,7 +18,7 @@ from pygame_menu.widgets.widget import Button, ColorInput, DropSelect, \ DropSelectMultiple, Frame, HMargin, Image, Label, MenuBar, MenuLink, NoneWidget, \ ProgressBar, RangeSlider, ScrollBar, Selector, SurfaceWidget, Table, TextInput, \ - ToggleSwitch, VMargin + ToggleSwitch, VFill, VMargin # Widget constants from pygame_menu.widgets.widget.colorinput import COLORINPUT_TYPE_RGB, \ diff --git a/pygame_menu/widgets/core/widget.py b/pygame_menu/widgets/core/widget.py index 6aba29c4..3c2c6a59 100644 --- a/pygame_menu/widgets/core/widget.py +++ b/pygame_menu/widgets/core/widget.py @@ -2942,33 +2942,46 @@ def set_float( self._menu.render() return self - def show(self) -> 'Widget': + def __update_menu_after_toggle(self, prev_visible: bool) -> 'Widget': """ - Set the Widget visible. + Updates menu position after widget toggle (show/hide). + :param prev_visible: Previous visible status :return: Self reference """ - self._visible = True self._render() if self._menu is not None: self._menu._update_selection_if_hidden() + if prev_visible != self._visible: + try: + self._menu._update_widget_position() + except AttributeError: + pass return self + def show(self) -> 'Widget': + """ + Set the Widget visible. + + :return: Self reference + """ + prev_visible = self._visible + self._visible = True + return self.__update_menu_after_toggle(prev_visible) + def hide(self) -> 'Widget': """ Hides the Widget. :return: Self reference """ + prev_visible = self._visible if self._mouseover: self._mouseover = False self.mouseleave(mouse_motion_current_mouse_position()) self._visible = False self.active = False - self._render() - if self._menu is not None: - self._menu._update_selection_if_hidden() - return self + return self.__update_menu_after_toggle(prev_visible) def set_col_row_index(self, col: int, row: int, index: int) -> 'Widget': """ diff --git a/pygame_menu/widgets/widget/__init__.py b/pygame_menu/widgets/widget/__init__.py index ad4186ad..1bc99743 100644 --- a/pygame_menu/widgets/widget/__init__.py +++ b/pygame_menu/widgets/widget/__init__.py @@ -25,4 +25,5 @@ from pygame_menu.widgets.widget.table import Table from pygame_menu.widgets.widget.textinput import TextInput from pygame_menu.widgets.widget.toggleswitch import ToggleSwitch +from pygame_menu.widgets.widget.vfill import VFill from pygame_menu.widgets.widget.vmargin import VMargin diff --git a/pygame_menu/widgets/widget/hmargin.py b/pygame_menu/widgets/widget/hmargin.py index 9bf6b37f..beabe6dd 100644 --- a/pygame_menu/widgets/widget/hmargin.py +++ b/pygame_menu/widgets/widget/hmargin.py @@ -39,6 +39,9 @@ def __init__( margin: NumberType, widget_id: str = '' ) -> None: + assert isinstance(margin, NumberInstance) + assert margin > 0, \ + 'zero margin is not valid, prefer adding a NoneWidget menu.add.none_widget()' super(HMargin, self).__init__(widget_id=widget_id) self._rect.width = int(margin) self._rect.height = 0 @@ -52,7 +55,7 @@ class HMarginManager(AbstractWidgetManager, ABC): HMargin manager. """ - def _horizontal_margin( + def horizontal_margin( self, margin: NumberType, margin_id: str = '' @@ -71,10 +74,6 @@ def _horizontal_margin( :return: Widget object :rtype: :py:class:`pygame_menu.widgets.HMargin` """ - assert isinstance(margin, NumberInstance) - assert margin > 0, \ - 'zero margin is not valid, prefer adding a NoneWidget menu.add.none_widget()' - attributes = self._filter_widget_attributes({}) widget = HMargin(margin, widget_id=margin_id) self._configure_widget(widget=widget, **attributes) diff --git a/pygame_menu/widgets/widget/none.py b/pygame_menu/widgets/widget/none.py index c7d0c180..4d4f4796 100644 --- a/pygame_menu/widgets/widget/none.py +++ b/pygame_menu/widgets/widget/none.py @@ -120,9 +120,6 @@ def flip(self, *args, **kwargs) -> 'NoneWidget': def translate(self, *args, **kwargs) -> 'NoneWidget': raise WidgetTransformationNotImplemented() - def set_alignment(self, *args, **kwargs) -> 'NoneWidget': - return self - def select(self, *args, **kwargs) -> 'NoneWidget': return self diff --git a/pygame_menu/widgets/widget/vfill.py b/pygame_menu/widgets/widget/vfill.py new file mode 100644 index 00000000..d898430f --- /dev/null +++ b/pygame_menu/widgets/widget/vfill.py @@ -0,0 +1,112 @@ +""" +pygame-menu +https://github.com/ppizarror/pygame-menu + +VERTICAL VILL +Vertical fill box. Fills all available vertical space. +""" + +__all__ = [ + 'VFill', + 'VFillManager' +] + +import pygame +import pygame_menu + +from abc import ABC +from pygame_menu.widgets.core.widget import AbstractWidgetManager +from pygame_menu.widgets.widget.none import NoneWidget + +from pygame_menu._types import NumberType, NumberInstance + + +# noinspection PyMissingOrEmptyDocstring +class VFill(NoneWidget): + """ + Vertical fill widget. This widget fills all vertical space if available, else, + it uses the min height. + + .. note:: + + VFill does not accept any transformation. + + :param min_height: Minimum height in px + :param widget_id: ID of the widget + """ + _min_height: int + + def __init__( + self, + min_height: NumberType, + widget_id: str = '' + ) -> None: + assert isinstance(min_height, NumberInstance) + assert min_height >= 0, 'negative min height is not valid' + super(VFill, self).__init__(widget_id=widget_id) + self._min_height = min_height + + def get_rect(self, *args, **kwargs) -> 'pygame.Rect': + # Get all menu widgets, and for those in the same column store the total + # size (without considering other vfills). Then, divide all available height + # in the total vfills found + c = self.get_col_row_index()[0] + if c == -1: + self._rect.height = self._min_height + return self._rect + menu_widgets_col = self.get_menu().get_widgets_column(c) + available_height = self.get_menu().get_height(inner=True) + total_column_height = 0 + total_vfills = 0 + column_vfills = [] + + for w in menu_widgets_col: + if not isinstance(w, VFill): + total_column_height += w.get_height() + else: + column_vfills.append(w) + total_column_height += w._min_height + total_vfills += 1 + + vfill_height = ((available_height - total_column_height) / total_vfills) if total_vfills > 0 else 0 + + # Discount 1px only to last + if self == column_vfills[-1] and vfill_height > 0: + vfill_height -= 1 + + vfill_height = max(0, vfill_height) + self._rect.height = self._min_height + vfill_height + + return self._rect + + +class VFillManager(AbstractWidgetManager, ABC): + """ + VFill manager. + """ + + def vertical_fill( + self, + min_height: NumberType = 0, + vfill_id: str = '' + ) -> 'pygame_menu.widgets.VFill': + """ + Adds a vertical fill to the Menu. This widget fills all vertical space + if available, else, it uses the min height. + + .. note:: + + This is applied only to the base Menu (not the currently displayed, + stored in ``_current`` pointer); for such behaviour apply to + :py:meth:`pygame_menu.menu.Menu.get_current` object. + + :param min_height: Minimum height in px + :param vfill_id: ID of the vertical fill + :return: Widget object + :rtype: :py:class:`pygame_menu.widgets.VFill` + """ + attributes = self._filter_widget_attributes({}) + widget = VFill(min_height, widget_id=vfill_id) + self._configure_widget(widget=widget, **attributes) + self._append_widget(widget) + return widget diff --git a/pygame_menu/widgets/widget/vmargin.py b/pygame_menu/widgets/widget/vmargin.py index fcb2e112..493782be 100644 --- a/pygame_menu/widgets/widget/vmargin.py +++ b/pygame_menu/widgets/widget/vmargin.py @@ -39,6 +39,8 @@ def __init__( margin: NumberType, widget_id: str = '' ) -> None: + assert isinstance(margin, NumberInstance) + assert margin > 0, 'negative or zero margin is not valid' super(VMargin, self).__init__(widget_id=widget_id) self._rect.width = 0 self._rect.height = int(margin) @@ -71,12 +73,8 @@ def vertical_margin( :return: Widget object :rtype: :py:class:`pygame_menu.widgets.VMargin` """ - assert isinstance(margin, NumberInstance) - assert margin > 0, 'negative or zero margin is not valid' - attributes = self._filter_widget_attributes({}) widget = VMargin(margin, widget_id=margin_id) self._configure_widget(widget=widget, **attributes) self._append_widget(widget) - return widget diff --git a/test/test_widget_frame.py b/test/test_widget_frame.py index 13f42ad4..abc513f4 100644 --- a/test/test_widget_frame.py +++ b/test/test_widget_frame.py @@ -1199,14 +1199,14 @@ def check_all_visible() -> None: self.assertEqual(menu.get_selected_widget(), b3) self.assertAlmostEqual(f3.get_scroll_value_percentage(ORIENTATION_VERTICAL), 0 if PYGAME_V2 else 0.005) if PYGAME_V2: - self.assertAlmostEqual(menu.get_scrollarea().get_scroll_value_percentage(ORIENTATION_VERTICAL), 0.467) + self.assertAlmostEqual(menu.get_scrollarea().get_scroll_value_percentage(ORIENTATION_VERTICAL), 0.562) f2.scrollv(0) menu._down() self.assertEqual(menu.get_selected_widget(), b2) self.assertAlmostEqual(f2.get_scroll_value_percentage(ORIENTATION_VERTICAL), 0) if PYGAME_V2: - self.assertAlmostEqual(menu.get_scrollarea().get_scroll_value_percentage(ORIENTATION_VERTICAL), 0.467) + self.assertAlmostEqual(menu.get_scrollarea().get_scroll_value_percentage(ORIENTATION_VERTICAL), 0.562) menu._down() menu._down() diff --git a/test/test_widget_none.py b/test/test_widget_none.py index b120476e..e0be1a21 100644 --- a/test/test_widget_none.py +++ b/test/test_widget_none.py @@ -3,13 +3,14 @@ https://github.com/ppizarror/pygame-menu TEST WIDGET - NONE -Test NoneWidget, HMargin, VMargin and MenuLink widgets. +Test NoneWidget, HMargin, VFill, VMargin and MenuLink widgets. """ __all__ = ['NoneWidgetTest'] from test._utils import MenuUtils, surface, PygameEventUtils, BaseTest +import math import pygame_menu import pygame_menu.controls as ctrl @@ -23,126 +24,129 @@ def test_none(self) -> None: """ Test none widget. """ - wid = NoneWidget() - - wid.set_margin(9, 9) - self.assertEqual(wid.get_margin(), (0, 0)) - - wid.set_padding(9) - self.assertEqual(wid.get_padding(), (0, 0, 0, 0)) - - wid.set_background_color((1, 1, 1)) - wid._draw_background_color(surface) - self.assertIsNone(wid._background_color) - - no_sel = NoneSelection() - wid.set_selection_effect(no_sel) - self.assertNotEqual(no_sel, wid.get_selection_effect()) - - wid.set_title('none') - self.assertEqual(wid.get_title(), '') - - r = wid.get_rect(inflate=(10, 10)) - self.assertEqual(r.x, 0) - self.assertEqual(r.y, 0) - self.assertEqual(r.width, 0) - self.assertEqual(r.height, 0) - - self.assertFalse(wid.is_selectable) - self.assertTrue(wid.is_visible()) - - wid.apply() - wid.change() - - # noinspection SpellCheckingInspection - wid.set_font('myfont', 0, (1, 1, 1), (1, 1, 1), (1, 1, 1), (0, 0, 0), (0, 0, 0)) - wid.update_font({'name': ''}) - wid._apply_font() - self.assertIsNone(wid._font) - - # Test font rendering - surf = wid._render_string('nice', (1, 1, 1)) - self.assertEqual(surf.get_width(), 0) - self.assertEqual(surf.get_height(), 0) - - wid._apply_transforms() - - wid.hide() - self.assertFalse(wid.is_visible()) - wid.show() - self.assertTrue(wid.is_visible()) - - self.assertRaises(ValueError, lambda: wid.get_value()) - - surf = wid.get_surface() - self.assertEqual(surf.get_width(), 0) - self.assertEqual(surf.get_height(), 0) - - # Apply transforms - wid.set_position(1, 1) - self.assertEqual(wid.get_position(), (0, 0)) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.translate(1, 1)) - self.assertEqual(wid.get_translate(), (0, 0)) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.rotate(10)) - self.assertEqual(wid._angle, 0) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.resize(10, 10)) - self.assertFalse(wid._scale[0]) - self.assertEqual(wid._scale[1], 1) - self.assertEqual(wid._scale[2], 1) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.scale(100, 100)) - self.assertFalse(wid._scale[0]) - self.assertEqual(wid._scale[1], 1) - self.assertEqual(wid._scale[2], 1) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.flip(True, True)) - self.assertFalse(wid._flip[0]) - self.assertFalse(wid._flip[1]) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.set_max_width(100)) - self.assertIsNone(wid._max_width[0]) - - self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.set_max_height(100)) - self.assertIsNone(wid._max_height[0]) - - # Selection - wid.select() - self.assertFalse(wid.is_selected()) - self.assertFalse(wid.is_selectable) - - # noinspection PyTypeChecker - wid.set_sound(None) - self.assertIsNotNone(wid._sound) - - wid.set_border(1, (0, 0, 0), (0, 0)) - self.assertEqual(wid._border_width, 0) - self.assertEqual(wid.get_selected_time(), 0) - - # Test events - def my_event() -> None: - """ - Generic event object. - """ - return - - wid.set_onchange(my_event) - self.assertIsNone(wid._onchange) - wid.set_onmouseover(my_event) - self.assertIsNone(wid._onmouseover) - wid.set_onmouseleave(my_event) - self.assertIsNone(wid._onmouseleave) - wid.set_onselect(my_event) - self.assertIsNone(wid._onselect) - wid.set_onreturn(my_event) - self.assertIsNone(wid._onreturn) - wid.mouseleave() - wid.mouseover() - wid._mouseover = True - wid._check_mouseover() - self.assertFalse(wid._mouseover) + menu = MenuUtils.generic_menu() + for wid in [ + NoneWidget(), + menu.add.vertical_margin(10), + menu.add.horizontal_margin(10), + menu.add.vertical_fill(10) + ]: + wid.set_margin(9, 9) + self.assertEqual(wid.get_margin(), (0, 0)) + + wid.set_padding(9) + self.assertEqual(wid.get_padding(), (0, 0, 0, 0)) + + wid.set_background_color((1, 1, 1)) + wid._draw_background_color(surface) + self.assertIsNone(wid._background_color) + + no_sel = NoneSelection() + wid.set_selection_effect(no_sel) + self.assertNotEqual(no_sel, wid.get_selection_effect()) + + wid.set_title('none') + self.assertEqual(wid.get_title(), '') + + r = wid.get_rect(inflate=(10, 10)) + self.assertEqual(r.x, 0) + self.assertEqual(r.y, 0) + + self.assertFalse(wid.is_selectable) + self.assertTrue(wid.is_visible()) + + wid.apply() + wid.change() + + # noinspection SpellCheckingInspection + wid.set_font('myfont', 0, (1, 1, 1), (1, 1, 1), (1, 1, 1), (0, 0, 0), (0, 0, 0)) + wid.update_font({'name': ''}) + wid._apply_font() + self.assertIsNone(wid._font) + + # Test font rendering + surf = wid._render_string('nice', (1, 1, 1)) + self.assertEqual(surf.get_width(), 0) + self.assertEqual(surf.get_height(), 0) + + wid._apply_transforms() + + wid.hide() + self.assertFalse(wid.is_visible()) + wid.show() + self.assertTrue(wid.is_visible()) + + self.assertRaises(ValueError, lambda: wid.get_value()) + + surf = wid.get_surface() + self.assertEqual(surf.get_width(), 0) + self.assertEqual(surf.get_height(), 0) + + # Apply transforms + wid.set_position(1, 1) + self.assertEqual(wid.get_position(), (0, 0)) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.translate(1, 1)) + self.assertEqual(wid.get_translate(), (0, 0)) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.rotate(10)) + self.assertEqual(wid._angle, 0) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.resize(10, 10)) + self.assertFalse(wid._scale[0]) + self.assertEqual(wid._scale[1], 1) + self.assertEqual(wid._scale[2], 1) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.scale(100, 100)) + self.assertFalse(wid._scale[0]) + self.assertEqual(wid._scale[1], 1) + self.assertEqual(wid._scale[2], 1) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.flip(True, True)) + self.assertFalse(wid._flip[0]) + self.assertFalse(wid._flip[1]) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.set_max_width(100)) + self.assertIsNone(wid._max_width[0]) + + self.assertRaises(WidgetTransformationNotImplemented, lambda: wid.set_max_height(100)) + self.assertIsNone(wid._max_height[0]) + + # Selection + wid.select() + self.assertFalse(wid.is_selected()) + self.assertFalse(wid.is_selectable) + + # noinspection PyTypeChecker + wid.set_sound(None) + self.assertIsNotNone(wid._sound) + + wid.set_border(1, (0, 0, 0), (0, 0)) + self.assertEqual(wid._border_width, 0) + self.assertEqual(wid.get_selected_time(), 0) + + # Test events + def my_event() -> None: + """ + Generic event object. + """ + return + + wid.set_onchange(my_event) + self.assertIsNone(wid._onchange) + wid.set_onmouseover(my_event) + self.assertIsNone(wid._onmouseover) + wid.set_onmouseleave(my_event) + self.assertIsNone(wid._onmouseleave) + wid.set_onselect(my_event) + self.assertIsNone(wid._onselect) + wid.set_onreturn(my_event) + self.assertIsNone(wid._onreturn) + wid.mouseleave() + wid.mouseover() + wid._mouseover = True + wid._check_mouseover() + self.assertFalse(wid._mouseover) def test_draw_update(self) -> None: """ @@ -198,10 +202,105 @@ def test_hmargin(self) -> None: w.draw(surface) menu = MenuUtils.generic_menu() - w = menu.add._horizontal_margin(999) + w = menu.add.horizontal_margin(999) self.assertEqual(w.get_rect().width, 999) self.assertEqual(w.get_rect().height, 0) + def test_vfill(self) -> None: + """ + Test VFill widget. + """ + menu = MenuUtils.generic_menu() + b = menu.add.button('nice') # Add button + bh = b.get_height() + self.assertEqual(menu.get_height(widget=True), bh) + self.assertEqual(menu.get_size(widget=True), b.get_size()) + + # Now add 1 vfill, this should use all available height + vf1 = menu.add.vertical_fill() + self.assertEqual(vf1.get_width(), 0) + self.assertEqual(vf1.get_height(), menu.get_height(inner=True) - bh - 1) + self.assertEqual(menu.get_height(inner=True) - 1, menu.get_height(widget=True)) + self.assertEqual(menu.get_size(widget=True), (b.get_width(), bh + vf1.get_height())) + + # Add another vfill, now both vfills should have the same height + vf2 = menu.add.vertical_fill() + self.assertEqual(vf1.get_height(), vf2.get_height() + 1) # Second vfill removes 1px + self.assertEqual(menu.get_height(inner=True) - 1, menu.get_height(widget=True)) + + # Test another menu, but with interlaced buttons and vfills + menu = MenuUtils.generic_menu() + b1 = menu.add.button(1) + vf1 = menu.add.vertical_fill() + menu.add.button(2) + vf2 = menu.add.vertical_fill() + menu.add.button(3) + vf3 = menu.add.vertical_fill() + menu.add.button(4) + self.assertEqual(vf1.get_width(), 0) + self.assertEqual(vf1.get_height(), vf2.get_height()) + self.assertEqual(vf2.get_height(), vf3.get_height() + 1) + prev_height = vf1.get_height() + + # Now, if more buttons are added, the height of previous vills should be zero + added_last = [] + for i in range(5, 10): + b = menu.add.button(i) + added_last.append(b) + self.assertEqual(vf1.get_height(), 0) + self.assertEqual(vf2.get_height(), 0) + self.assertEqual(vf3.get_height(), 0) + + # Removing buttons should also update vfills + for b in added_last: + menu.remove_widget(b) + self.assertEqual(vf1.get_height(), prev_height) + + # Hiding vfill should also update + vfill_total = vf1.get_height() + vf2.get_height() + vf3.get_height() + vf2.hide() + vfill_total_after = vf1.get_height() + vf3.get_height() + self.assertEqual(vf1.get_height(), vf3.get_height() + 1) + self.assertEqual(vfill_total, vfill_total_after - 1) + vf2.show() + self.assertEqual(vfill_total, vf1.get_height() + vf2.get_height() + vf3.get_height()) + + # Hiding a button should also affect vfills + vf1_height_prev = vf1.get_height() + b1_height = math.ceil(b1.get_height() / 3) + b1.hide() + self.assertEqual(vf1.get_height(), vf1_height_prev + b1_height) + b1.show() + self.assertEqual(vf1.get_height(), vf1_height_prev) + + # Test min height + menu = MenuUtils.generic_menu() + b = menu.add.button(1) + v = menu.add.vertical_fill(10) + self.assertEqual(v.get_height(), menu.get_height(inner=True) - b.get_height() - 1) + for i in range(20): + menu.add.button(i) + self.assertEqual(v.get_height(), 10) + + # Test widget alignment + menu = MenuUtils.generic_menu(theme=pygame_menu.Theme( + widget_alignment=pygame_menu.locals.ALIGN_LEFT + )) + + # Now add 1 vfill, this should use all available height + vf1 = menu.add.vertical_fill() + self.assertEqual(menu.get_size(widget=True), (0, vf1.get_height())) + self.assertEqual(vf1.get_height(), menu.get_height(inner=True) - 1) + + # Add button, this should change widget size width + b = menu.add.button('nice') # Add button + self.assertEqual(menu.get_size(widget=True), (b.get_width(), b.get_height() + vf1.get_height())) + + # Now add 1 vfill, this should use all available height + vf2 = menu.add.vertical_fill() + self.assertEqual(menu.get_size(widget=True), + (b.get_width(), b.get_height() + vf1.get_height() + vf2.get_height())) + def test_vmargin(self) -> None: """ Test vertical margin widget. @@ -286,7 +385,7 @@ def test_value(self) -> None: widgets = [ menu.add.none_widget(), menu.add.vertical_margin(1), - menu.add._horizontal_margin(1), + menu.add.horizontal_margin(1), menu.add.menu_link(menu2) ] for w in widgets: diff --git a/test/test_widget_surface.py b/test/test_widget_surface.py index d0477a27..acb35139 100644 --- a/test/test_widget_surface.py +++ b/test/test_widget_surface.py @@ -9,7 +9,6 @@ __all__ = ['SurfaceWidgetTest'] from test._utils import MenuUtils, surface, PygameEventUtils, BaseTest - import pygame from pygame_menu.widgets.core.widget import WidgetTransformationNotImplemented