Skip to content

Commit 7c8279a

Browse files
committed
Fix gui docs
1 parent 4527474 commit 7c8279a

6 files changed

Lines changed: 44 additions & 41 deletions

File tree

arcade/gui/view.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class UIView(View):
2929
def __init__(self):
3030
super().__init__()
3131
self.ui = UIManager()
32+
"""
33+
The UIManager of this view.
34+
"""
3235

3336
def add_widget(self, widget: W) -> W:
3437
"""Add a widget to the UIManager of this view."""

doc/extensions/prettyspecialmethods.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ def brackets(parameters_node):
214214
'__sizeof__': function_transformer('sys.getsizeof'),
215215
'__dir__': function_transformer('dir'),
216216
'__reversed__': function_transformer('reversed'),
217+
218+
'__enter__': function_transformer('enter'),
219+
'__exit__': function_transformer('exit'),
217220
}
218221

219222

doc/programming_guide/gui/concepts.rst

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The GUI is structured like a tree; every widget can have other widgets as
88
children.
99

1010
The root of the tree is the :py:class:`~arcade.gui.UIManager`. The
11-
:py:class:`UIManager` connects the user interactions with the GUI. Read more about
11+
:py:class:`~arcade.gui.UIManager` connects the user interactions with the GUI. Read more about
1212
:ref:`UIEvent`.
1313

1414
Classes of Arcade's GUI code are prefixed with ``UI-`` to make them easy to
@@ -41,7 +41,6 @@ via the :py:attr:`~arcade.gui.UIView.ui` attribute.
4141
It automatically enables and disables the
4242
:py:class:`~arcade.gui.UIManager` when the view is shown or hidden.
4343

44-
4544
UIWidget
4645
````````
4746

@@ -52,14 +51,14 @@ such as buttons or labels.
5251
User interaction with widgets is processed within :py:meth:`~arcade.gui.UIWidget.on_event`.
5352

5453

55-
A :class:`UIWidget` has following properties.
54+
A :class:`~arcade.gui.UIWidget` has following properties.
5655

5756
``rect``
5857
A tuple with four slots. The first two are x and y coordinates (bottom
5958
left of the widget), and the last two are width and height.
6059

6160
``children``
62-
Child widgets rendered within this widget. A :class:`UIWidget` will not
61+
Child widgets rendered within this widget. A :class:`~arcade.gui.UIWidget` will not
6362
move or resize its children; use a :py:class:`~arcade.gui.UILayout`
6463
instead.
6564

@@ -84,17 +83,17 @@ A :class:`UIWidget` has following properties.
8483

8584
``size_hint_min``
8685
A tuple of two integers defining the minimum width and height of the
87-
widget. These values should be taken into account by :class:`UILayout` when
86+
widget. These values should be taken into account by :class:`~arcade.gui.UILayout` when
8887
a ``size_hint`` is given for the axis.
8988

9089
``size_hint_max``
9190
A tuple of two integers defining the maximum width and height of the
92-
widget. These values should be taken into account by :class:`UILayout` when
91+
widget. These values should be taken into account by :class:`~arcade.gui.UILayout` when
9392
a ``size_hint`` is given for the axis.
9493

9594
.. warning:: Size hints do nothing on their own!
9695

97-
They are hints to :class:`UILayout` instances, which may choose to use or
96+
They are hints to :class:`~arcade.gui.UILayout` instances, which may choose to use or
9897
ignore them.
9998

10099
UILayout
@@ -168,8 +167,8 @@ changes only once.
168167

169168
**Example**: Executed steps within :py:class:`~arcade.gui.UIBoxLayout`:
170169

171-
1. :py:meth:`~arcade.UIBoxLayout.prepare_layout` updates own size_hints
172-
2. :py:meth:`~arcade.UIBoxLayout.do_layout`
170+
1. :py:meth:`~arcade.gui.UIBoxLayout.prepare_layout` updates own size_hints
171+
2. :py:meth:`~arcade.gui.UIBoxLayout.do_layout`
173172
1. Collect current ``size``, ``size_hint``, ``size_hint_min`` of children
174173
2. Calculate the new position and sizes
175174
3. Set position and size of children
@@ -222,17 +221,17 @@ changes only once.
222221
Size hint support
223222
^^^^^^^^^^^^^^^^^
224223

225-
+--------------------------+------------+----------------+----------------+
226-
| | size_hint | size_hint_min | size_hint_max |
227-
+==========================+============+================+================+
228-
| :class:`UIAnchorLayout` | X | X | X |
229-
+--------------------------+------------+----------------+----------------+
230-
| :class:`UIBoxLayout` | X | X | X |
231-
+--------------------------+------------+----------------+----------------+
232-
| :class:`UIGridLayout` | X | X | X |
233-
+--------------------------+------------+----------------+----------------+
234-
| :class:`UIManager` | X | X | X |
235-
+--------------------------+------------+----------------+----------------+
224+
+--------------------------------------+------------+----------------+----------------+
225+
| | size_hint | size_hint_min | size_hint_max |
226+
+======================================+============+================+================+
227+
| :class:`~arcade.gui.UIAnchorLayout` | X | X | X |
228+
+--------------------------------------+------------+----------------+----------------+
229+
| :class:`~arcade.gui.UIBoxLayout` | X | X | X |
230+
+--------------------------------------+------------+----------------+----------------+
231+
| :class:`~arcade.gui.UIGridLayout` | X | X | X |
232+
+--------------------------------------+------------+----------------+----------------+
233+
| :class:`~arcade.gui.UIManager` | X | X | X |
234+
+--------------------------------------+------------+----------------+----------------+
236235

237236
UIMixin
238237
=======
@@ -242,9 +241,9 @@ behaviour. Currently the available Mixins are still under heavy development.
242241

243242
Available:
244243

245-
- :py:class:`UIDraggableMixin` - Makes a widget draggable with the mouse.
246-
- :py:class:`UIMouseFilterMixin` - Captures all mouse events.
247-
- :py:class:`UIWindowLikeMixin` - Makes a widget behave like a window, combining draggable and mouse filter behaviour.
244+
- :py:class:`~arcade.gui.UIDraggableMixin` - Makes a widget draggable with the mouse.
245+
- :py:class:`~arcade.gui.UIMouseFilterMixin` - Captures all mouse events.
246+
- :py:class:`~arcade.gui.UIWindowLikeMixin` - Makes a widget behave like a window, combining draggable and mouse filter behaviour.
248247

249248
UIConstructs
250249
============
@@ -253,8 +252,8 @@ Constructs are predefined structures of widgets and layouts like a message box.
253252

254253
Available:
255254

256-
- :py:class:`UIMessageBox` - A simple message box with a title, message and buttons.
257-
- :py:class:`UIButtonRow` - A row of buttons.
255+
- :py:class:`~arcade.gui.UIMessageBox` - A simple message box with a title, message and buttons.
256+
- :py:class:`arcade.gui.UIButtonRow` - A row of buttons.
258257

259258
Available Elements
260259
==================
@@ -273,7 +272,7 @@ can use the :py:attr:`~arcade.gui.UITextWidget.ui_label` attribute to get the
273272
Flat button
274273
^^^^^^^^^^^
275274

276-
**Name**: :py:class:`~arcade.gui.FlatButton`
275+
**Name**: :py:class:`~arcade.gui.UIFlatButton`
277276

278277
A flat button for simple interactions (hover, press, release, click). This
279278
button is created with a simple rectangle. Flat buttons can quickly create a
@@ -373,14 +372,14 @@ parameters. ``bold`` and ``italic`` will set the text to bold or italic.
373372
``align`` specifies the justification of the text. Additionally it takes
374373
``font_name``, ``font_size``, and ``text_color`` options.
375374

376-
Using the :py:attr:`~arcade.gui.UILabel.label` property accesses the internal
375+
Using the :py:attr:`~arcade.gui.UILabel`'s ``_label`` property accesses the internal
377376
:py:class:`~arcade.Text` class.
378377

379378
.. hint::
380379
A :py:attr:`~arcade.gui.UILabel.text` attribute can modify the displayed
381380
text. Beware-calling this again and again will give a lot of lag. Use
382-
:py:meth:`~arcade.Text.begin_update` and py:meth:`~arcade.Text.end_update`
383-
to speed things up.
381+
:py:meth:`~arcade.Text.__enter__` through the ``with`` statement to speed
382+
things up multiple changes to text instances.
384383

385384
Text input field
386385
^^^^^^^^^^^^^^^^
@@ -426,7 +425,7 @@ Arcade's GUI events are fully typed dataclasses, which provide information
426425
about an event affecting the UI.
427426

428427
All pyglet window events are converted by the
429-
:py:class:`~arcade.gui.UIManager` into :class:`UIEvents` and passed via
428+
:py:class:`~arcade.gui.UIManager` into :class:`~arcade.gui.UIEvent` and passed via
430429
:py:meth:`~pyglet.event.EventDispatcher.dispatch_event` to the
431430
:py:meth:`~arcade.gui.UIWidget.on_event` callbacks.
432431

@@ -513,7 +512,7 @@ Different event systems
513512

514513
Arcade's GUI uses different event systems, dependent on the required flow. A
515514
game developer should mostly interact with user-interface events, which are
516-
dispatched from specific :py:class:`~arcade.gui.UIWidget`s like an ``on_click``
515+
dispatched from a specific :py:class:`~arcade.gui.UIWidget` like an ``on_click``
517516
of a button.
518517

519518
In cases where a developer implement own widgets themselves or want to

doc/programming_guide/gui/own_layout.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The main method you need to implement is:
2020

2121
- :meth:`arcade.gui.UILayout.do_layout` - This method is called to layout the child widgets.
2222

23-
Widgets added to the layout are accessible via the :attr:`arcade.gui.UILayout._children` attribute,
23+
Widgets added to the layout are accessible via the ``arcade.gui.UILayout._children`` attribute,
2424
which is a list of all added widgets with the parameter provided when added.
2525

2626
Children should be placed within the bounds of the layout.
@@ -36,5 +36,3 @@ Example `CircleLayout`
3636
~~~~~~~~~~~~~~~~~~~~~~
3737

3838
.. literalinclude:: ../../../arcade/examples/gui/own_layout.py
39-
40-

doc/programming_guide/gui/own_widgets.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ You can also make use of other base classes, which provide a more specialized in
2727
Further baseclasses are:
2828

2929
- :class:`arcade.gui.UIInteractiveWidget`
30-
`UIInteractiveWidget` is a baseclass for widgets that can be interacted with.
31-
It handles mouse events and provides properties like `hovered` or `pressed` and an :meth:`on_click` method.
30+
A base class for widgets that can be interacted with.
31+
It handles mouse events and provides properties like `hovered` or `pressed` and an :meth:`~arcade.gui.UIInteractiveWidget.on_click` method.
3232

3333
- :class:`arcade.gui.UIAnchorLayout`
34-
`UIAnchorLayout` is basically a frame, which can be used to place widgets
35-
to a position within itself. This makes it a great baseclass for a widget containing
34+
Basically a frame, which can be used to place widgets
35+
to a position within itself. This makes it a great base class for a widget containing
3636
multiple other widgets. (Examples: `MessageBox`, `Card`, etc.)
3737

3838
If your widget should act more as a general layout, position various widgets and handle their size,

doc/programming_guide/sound.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ The first way to play it is passing it to :py:func:`arcade.play_sound`:
152152
We store the return value because it is a special object which lets us
153153
control this specific playback of the :py:class:`Sound` data.
154154

155-
.. important:: You **must** pass a :py:class:`Sound`, not a path!
155+
.. important:: You **must** pass a :py:class:`~arcade.Sound`, not a path!
156156

157157
If you pass :py:func:`arcade.play_sound` anything other
158158
than a :py:class:`Sound` or ``None``, it will raise a
159159
:py:class:`TypeError`.
160160

161-
To avoid making this mistake, you can call the :py:class:`Sound`
162-
data's :py:meth:`Sound.play` method instead:
161+
To avoid making this mistake, you can call the :py:class:`~arcade.Sound`
162+
data's :py:meth:`~arcade.Sound.play` method instead:
163163

164164
.. code-block:: python
165165

0 commit comments

Comments
 (0)