Skip to content

Commit

Permalink
Merge pull request #180 from ppizarror/new-library-name
Browse files Browse the repository at this point in the history
New library name
  • Loading branch information
ppizarror committed Apr 18, 2020
2 parents b2683a7 + 14638e5 commit 9d2f4b2
Show file tree
Hide file tree
Showing 96 changed files with 1,247 additions and 1,236 deletions.
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exclude test/*.py
include requirements.txt
recursive-include pygameMenu/resources/fonts *.ttf
recursive-include pygameMenu/resources/images *.png
recursive-include pygameMenu/resources/sounds *.ogg
recursive-include pygame_menu/resources/fonts *.ttf
recursive-include pygame_menu/resources/images *.png
recursive-include pygame_menu/resources/sounds *.ogg
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pygame-menu
:target: https://lgtm.com/projects/g/ppizarror/pygame-menu/context:python
:alt: Language grade: Python

Source repo on `GitHub <https://github.com/ppizarror/pygame-menu>`_ ,
Source repo on `GitHub <https://github.com/ppizarror/pygame-menu>`_,
and run it on `Repl.it <https://repl.it/github/ppizarror/pygame-menu>`_

Introduction
Expand All @@ -52,7 +52,7 @@ Introduction
Pygame-menu is a python-pygame library for creating menus. It supports
selectors, buttons, labels, color inputs, and text inputs, with many options to customize.

Comprehensive documentation is available at https://pygame-menu.readthedocs.io.
Comprehensive documentation is available at https://pygame-menu.readthedocs.io

Install Instructions
--------------------
Expand All @@ -74,7 +74,7 @@ To build the documentation from a Git repository:
Dependencies
------------

This library is dependent on the following::
This library is dependent on the following:

- `pygame <http://www.pygame.org/download.shtml>`_
- `pygame <https://www.pygame.org/>`_
- `pyperclip <https://pypi.org/project/pyperclip/>`_
32 changes: 16 additions & 16 deletions docs/_source/add_sounds.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

.. module:: pygameMenu.sound
.. module:: pygame_menu.sound

=============
Adding sounds
Expand All @@ -14,30 +14,30 @@ For example, buttons or keys...

.. code-block:: python
import pygameMenu
from pygameMenu import sound
import pygame_menu
from pygame_menu import sound
engine = sound.Sound()
engine.set_sound(sound.SOUND_TYPE_CLICK_MOUSE, '/home/me/click.ogg')
engine.set_sound(sound.SOUND_TYPE_OPEN_MENU, '/home/me/open.ogg')
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.set_sound(engine, recursive=True) # Apply on menu and all sub-menus
Sound types are the following:

======================================================= =============================
Type Description
======================================================= =============================
:py:data:`pygameMenu.sound.SOUND_TYPE_CLICK_MOUSE` Mouse click
:py:data:`pygameMenu.sound.SOUND_TYPE_CLOSE_MENU` A menu is closed
:py:data:`pygameMenu.sound.SOUND_TYPE_ERROR` Generic error
:py:data:`pygameMenu.sound.SOUND_TYPE_EVENT` Generic event
:py:data:`pygameMenu.sound.SOUND_TYPE_EVENT_ERROR` Error generated by user
:py:data:`pygameMenu.sound.SOUND_TYPE_KEY_ADDITION` User type a key
:py:data:`pygameMenu.sound.SOUND_TYPE_KEY_DELETION` User deletes with a key
:py:data:`pygameMenu.sound.SOUND_TYPE_OPEN_MENU` A menu is opened
======================================================= =============================
====================================================== =============================
Type Description
====================================================== =============================
:py:data:`pygame_menu.sound.SOUND_TYPE_CLICK_MOUSE` Mouse click
:py:data:`pygame_menu.sound.SOUND_TYPE_CLOSE_MENU` A menu is closed
:py:data:`pygame_menu.sound.SOUND_TYPE_ERROR` Generic error
:py:data:`pygame_menu.sound.SOUND_TYPE_EVENT` Generic event
:py:data:`pygame_menu.sound.SOUND_TYPE_EVENT_ERROR` Error generated by user
:py:data:`pygame_menu.sound.SOUND_TYPE_KEY_ADDITION` User type a key
:py:data:`pygame_menu.sound.SOUND_TYPE_KEY_DELETION` User deletes with a key
:py:data:`pygame_menu.sound.SOUND_TYPE_OPEN_MENU` A menu is opened
====================================================== =============================

.. autoclass:: Sound
:members:
60 changes: 30 additions & 30 deletions docs/_source/add_widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ can be wrapped in order to fit the menu size.
"Press UP/DOWN to move through Menu "\
"Press LEFT/RIGHT to move through Selectors."
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_label(HELP, max_char=-1, font_size=20)
.. automethod:: pygameMenu.Menu.add_label
.. automethod:: pygame_menu.Menu.add_label


Add an image
Expand All @@ -44,15 +44,15 @@ requires more CPU resources.

.. code-block:: python
PATH = os.path.join(os.path.dirname(pygameMenu.__file__),
PATH = os.path.join(os.path.dirname(pygame_menu.__file__),
'resources', 'images', 'pygame_menu.png')
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_image(PATH, angle=10, scale=(0.15, 0.15))
menu.add_image(PATH, angle=-10, scale=(0.15, 0.15), scale_smooth=True)
.. automethod:: pygameMenu.Menu.add_image
.. automethod:: pygame_menu.Menu.add_image


Add a button
Expand All @@ -62,21 +62,21 @@ A button is a text that fire action when the user trigger it. An action
is linked to a button by defining the `action` parameter with one of the
three values:

- an other :py:class:`pygameMenu.Menu`, in this case, it will be displayed
- an other :py:class:`pygame_menu.Menu`, in this case, it will be displayed
when the button is triggered.
- a python callable object (a function, a method, a class, ...)
that will be called with the given arguments.
- a specific event of :py:mod:`pygameMenu`. The possible events are
- a specific event of :py:mod:`pygame_menu`. The possible events are
the following:

========================================== ========================================
Event Description
========================================== ========================================
:py:data:`pygameMenu.events.BACK` Go back to previously opened menu
:py:data:`pygameMenu.events.CLOSE` Close the menu
:py:data:`pygameMenu.events.EXIT` Exit the program (not only the menu)
:py:data:`pygameMenu.events.RESET` Go back to first opened menu
========================================== ========================================
========================================== ========================================
Event Description
========================================== ========================================
:py:data:`pygame_menu.events.BACK` Go back to previously opened menu
:py:data:`pygame_menu.events.CLOSE` Close the menu
:py:data:`pygame_menu.events.EXIT` Exit the program (not only the menu)
:py:data:`pygame_menu.events.RESET` Go back to first opened menu
========================================== ========================================

**Example:**

Expand All @@ -89,18 +89,18 @@ three values:
def func(name):
print("Hello world from", name) # name will be 'foo'
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
about_menu = pygameMenu.Menu(...)
about_menu = pygame_menu.Menu(...)
menu.add_button('Exec', func, 'foo', # Execute a function
align=pygameMenu.locals.ALIGN_LEFT)
align=pygame_menu.locals.ALIGN_LEFT)
menu.add_button(about_menu.get_title(), about_menu, # Open a sub-menu
shadow=True, shadow_color=(0, 0, 100))
menu.add_button('Exit', pygameMenu.events.EXIT, # Link to exit action
align=pygameMenu.locals.ALIGN_RIGHT)
menu.add_button('Exit', pygame_menu.events.EXIT, # Link to exit action
align=pygame_menu.locals.ALIGN_RIGHT)
.. automethod:: pygameMenu.Menu.add_button
.. automethod:: pygame_menu.Menu.add_button


Add a choices list
Expand All @@ -127,7 +127,7 @@ displayed, the others are the arguments passed to the callbacks
color = (randrange(0, 255), randrange(0, 255), randrange(0, 255))
surface.fill(color)
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_selector('Current color',
# list of (Text, parameters...)
Expand All @@ -137,7 +137,7 @@ displayed, the others are the arguments passed to the callbacks
('Random', surface, (-1, -1, -1))],
onchange=change_background_color)
.. automethod:: pygameMenu.Menu.add_selector
.. automethod:: pygame_menu.Menu.add_selector


Add a text entry
Expand All @@ -158,13 +158,13 @@ on entered characters can be set using ``input_type``, ``maxchar``,
def check_name(value):
print('User name:', value)
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_text_input('First name: ', default='John', onreturn=check_name)
menu.add_text_input('Last name: ', default='Doe', maxchar=20)
menu.add_text_input('Password: ', input_type=pygameMenu.locals.INPUT_INT, password=True)
menu.add_text_input('Password: ', input_type=pygame_menu.locals.INPUT_INT, password=True)
.. automethod:: pygameMenu.Menu.add_text_input
.. automethod:: pygame_menu.Menu.add_text_input


Add a color entry
Expand All @@ -186,13 +186,13 @@ is a comma (``,``).
def check_color(value):
print('New color:', value)
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_color_input('RGB color 1: ', color_type='rgb', default=(255, 0, 255), onreturn=check_color, font_size=18)
menu.add_color_input('RGB color 2: ', color_type='rgb', input_separator='-', font_size=18)
menu.add_color_input('HEX color 3: ', color_type='hex', default='#ffaa11', font_size=18)
.. automethod:: pygameMenu.Menu.add_color_input
.. automethod:: pygame_menu.Menu.add_color_input


Add a vertical spacer
Expand All @@ -209,10 +209,10 @@ visual rendering of the menu.

.. code-block:: python
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_label('Text #1')
menu.add_vertical_margin(100)
menu.add_label('Text #2')
.. automethod:: pygameMenu.Menu.add_vertical_margin
.. automethod:: pygame_menu.Menu.add_vertical_margin
48 changes: 24 additions & 24 deletions docs/_source/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Package organization
====================

The :py:mod:`pygameMenu.widgets` package contains the widget support for the Menu.
The :py:mod:`pygame_menu.widgets` package contains the widget support for the Menu.
Its structure consists of several sub-packages::

pygameMenu/
pygame_menu/
widgets/
core/ Main object classes for Widget and Selector
examples/ Some examples of widgets
Expand All @@ -18,30 +18,30 @@ Its structure consists of several sub-packages::
Menu navigation
===============

The :py:class:`pygameMenu.Menu` keeps the link and history with all its sub-menus.
The :py:class:`pygame_menu.Menu` keeps the link and history with all its sub-menus.
To be functional, the menu links (pointer to previous and next menus in nested submenus),
have to respect some rules:

- Public methods access the menu instance through the ``_current`` attribute, because
users can move through sub-menus and they should target the current Menu instance.
- Private methods access the menu instance through ``self`` (not ``_current``) because
these methods are called publicly (``_current``) or by themselves.
- Methods used to navigate through menus (:py:meth:`pygameMenu.Menu._open`,
:py:meth:`pygameMenu.Menu._reset`, ...) should be the only place where the ``_top``
- Methods used to navigate through menus (:py:meth:`pygame_menu.Menu._open`,
:py:meth:`pygame_menu.Menu._reset`, ...) should be the only place where the ``_top``
attribute is used.


===============
Create a widget
===============

All widget classes shall inherit from :py:class:`pygameMenu.widgets.core.widget.Widget`,
and they must be located in the :py:mod:`pygameMenu.widgets.widget` package. The most
All widget classes shall inherit from :py:class:`pygame_menu.widgets.core.widget.Widget`,
and they must be located in the :py:mod:`pygame_menu.widgets.widget` package. The most
basic widget should contain this code:

.. code-block:: python
from pygameMenu.widgets.core.widget import Widget
from pygame_menu.widgets.core.widget import Widget
class MyWidget(Widget):
Expand Down Expand Up @@ -89,19 +89,19 @@ basic widget should contain this code:
return False
.. warning:: After creating the widget, it must be added to the ``__init__.py`` file of the
:py:mod:`pygameMenu.widgets` package.
:py:mod:`pygame_menu.widgets` package.

.. code-block:: python
from pygameMenu.widgets.widget.mywidget import MyWidget
from pygame_menu.widgets.widget.mywidget import MyWidget
To add the widget to the :py:class:`pygameMenu.Menu` class, a public method
:py:meth:`pygameMenu.Menu.add_mywidget` with the following structure has to be
To add the widget to the :py:class:`pygame_menu.Menu` class, a public method
:py:meth:`pygame_menu.Menu.add_mywidget` with the following structure has to be
added:

.. code-block:: python
import pygameMenu.widgets as _widgets
import pygame_menu.widgets as _widgets
class Menu(object):
...
Expand All @@ -127,7 +127,7 @@ added:
.. note:: This method uses the **kwargs** parameter for defining the settings of the
Widget, such as the background, margin, etc. This is applied automatically
by the Menu in :py:meth:`pygameMenu.Menu._configure_widget`
by the Menu in :py:meth:`pygame_menu.Menu._configure_widget`
method. If **MyWidget** needs additional parameters, please use some that
are not named as the default kwargs used by the Menu Widget system.

Expand Down Expand Up @@ -157,13 +157,13 @@ The widgets in Menu are drawn with the following idea:
#. Draw menubar
#. Draw scrollbar

For defining a new selection effect, a new :py:class:`pygameMenu.widgets.core.selection.Selection`
For defining a new selection effect, a new :py:class:`pygame_menu.widgets.core.selection.Selection`
subclass must be added to the :py:mod:`pgameMenu.widgets.selection` package. A basic class must
contain the following code:

.. code-block:: python
from pygameMenu.widgets.core.selection import Selection
from pygame_menu.widgets.core.selection import Selection
class MySelection(Selection):
Expand Down Expand Up @@ -194,30 +194,30 @@ contain the following code:

.. code-block:: python
from pygameMenu.widgets.selection.myselection import MySelection
from pygame_menu.widgets.selection.myselection import MySelection
Finally, this new selection effect can be set by following one of these two instructions:

1. Pass it when adding a new widget to the menu

.. code-block:: python
import pygameMenu
import pygame_menu
menu = pygameMenu.Menu(...)
menu = pygame_menu.Menu(...)
menu.add_button(..., selection_effect=pygameMenu.widgets.MySelection(...))
menu.add_button(..., selection_effect=pygame_menu.widgets.MySelection(...))
2. To apply it on all menus and widgets (and avoid passing it for each added widget),
a theme can be created

.. code-block:: python
import pygameMenu
import pygame_menu
MY_THEME = pygameMenu.Theme(
MY_THEME = pygame_menu.Theme(
...,
widget_selection_effect=pygameMenu.widgets.MySelection(...)
widget_selection_effect=pygame_menu.widgets.MySelection(...)
)
menu = pygameMenu.Menu(..., theme=MY_THEME)
menu = pygame_menu.Menu(..., theme=MY_THEME)

0 comments on commit 9d2f4b2

Please sign in to comment.