Skip to content

Commit

Permalink
Work on updating docs for GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcraven committed Jun 18, 2020
1 parent a1548fa commit 0ed00e8
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 80 deletions.
92 changes: 92 additions & 0 deletions arcade/examples/gui_elements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"""
Show GUI Elements
Show how to use GUI elements.
python -m arcade.examples.gui_elements_example
"""
import arcade

import arcade.gui
from arcade.gui import UIManager


class MyView(arcade.View):
"""
Main view. Really the only view in this example. """
def __init__(self):
super().__init__()

self.ui_manager = UIManager(window)

def on_draw(self):
""" Draw this view. GUI elements are automatically drawn. """
arcade.start_render()

def on_show(self):
""" Called once when view is activated. """
self.setup()
arcade.set_background_color(arcade.color.BLACK)

def setup(self):
""" Set up this view. """
self.ui_manager.purge_ui_elements()

y_slot = self.window.height // 4
left_column_x = self.window.width // 4
right_column_x = 3 * self.window.width // 4

# left side elements
self.ui_manager.add_ui_element(arcade.gui.UILabel(
'UILabel',
center_x=left_column_x,
center_y=y_slot * 3,
))

ui_input_box = arcade.gui.UIInputBox(
center_x=left_column_x,
center_y=y_slot * 2,
width=300
)
ui_input_box.text = 'UIInputBox'
ui_input_box.cursor_index = len(ui_input_box.text)
self.ui_manager.add_ui_element(ui_input_box)

button_normal = arcade.load_texture(':resources:gui_basic_assets/red_button_normal.png')
hovered_texture = arcade.load_texture(':resources:gui_basic_assets/red_button_hover.png')
pressed_texture = arcade.load_texture(':resources:gui_basic_assets/red_button_press.png')
button = arcade.gui.UIImageButton(
center_x=left_column_x,
center_y=y_slot * 1,
normal_texture=button_normal,
hover_texture=hovered_texture,
press_texture=pressed_texture,
text='UIImageButton'
)
self.ui_manager.add_ui_element(button)

# right side elements
button = arcade.gui.UIFlatButton(
'FlatButton',
center_x=right_column_x,
center_y=y_slot * 1,
width=250,
# height=20
)
self.ui_manager.add_ui_element(button)

button = arcade.gui.UIGhostFlatButton(
'GhostFlatButton',
center_x=right_column_x,
center_y=y_slot * 2,
width=250,
# height=20
)
self.ui_manager.add_ui_element(button)


if __name__ == '__main__':
window = arcade.Window(title='ARCADE_GUI')
view = MyView()
window.show_view(view)
arcade.run()
3 changes: 2 additions & 1 deletion arcade/gui/examples/show_uiinputbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def setup(self):

if __name__ == '__main__':
window = arcade.Window(title='ARCADE_GUI')
window.show_view(MyView(window))
view = MyView(window)
window.show_view(view)
arcade.run()
Binary file removed doc/examples/gui_button.png
Binary file not shown.
16 changes: 0 additions & 16 deletions doc/examples/gui_button.rst

This file was deleted.

Binary file removed doc/examples/gui_dialogue_box.png
Binary file not shown.
16 changes: 0 additions & 16 deletions doc/examples/gui_dialogue_box.rst

This file was deleted.

Binary file added doc/examples/gui_elements.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions doc/examples/gui_elements.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:orphan:

.. _gui_elements:

GUI Elements
============

.. note::

This example requires Arcade 2.4a10 or higher.

.. image:: gui_elements.png
:width: 600px
:align: center
:alt: GUI Elements

.. literalinclude:: ../../arcade/examples/gui_elements.py
:caption: gui_elements.py
:linenos:
Binary file removed doc/examples/gui_text_box.png
Binary file not shown.
16 changes: 0 additions & 16 deletions doc/examples/gui_text_box.rst

This file was deleted.

Binary file removed doc/examples/gui_text_button.png
Binary file not shown.
15 changes: 0 additions & 15 deletions doc/examples/gui_text_button.rst

This file was deleted.

18 changes: 2 additions & 16 deletions doc/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -446,25 +446,11 @@ Resizable Window and Fullscreen Games
Buttons and Dialog Boxes
^^^^^^^^^^^^^^^^^^^^^^^^

.. figure:: thumbs/gui_button.png
.. figure:: thumbs/gui_elements.png
:figwidth: 170px

:ref:`gui_button`
:ref:`gui_elements`

.. figure:: thumbs/gui_dialogue_box.png
:figwidth: 170px

:ref:`gui_dialogue_box`

.. figure:: thumbs/gui_text_box.png
:figwidth: 170px

:ref:`gui_text_box`

.. figure:: thumbs/gui_text_button.png
:figwidth: 170px

:ref:`gui_text_button`

Grid-Based Games
----------------
Expand Down

0 comments on commit 0ed00e8

Please sign in to comment.