Skip to content

Commit

Permalink
Updates to docs. Sidebar and GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcraven committed Jun 30, 2020
1 parent 6c07d6e commit abee0a2
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
63 changes: 63 additions & 0 deletions arcade/examples/gui_custom_style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import arcade

import arcade.gui
from arcade.gui import UIFlatButton, UIGhostFlatButton, UIManager
from arcade.gui.ui_style import UIStyle

class MyView(arcade.View):
def __init__(self, window: arcade.Window):
super().__init__()

self.window = window
self.ui_manager = UIManager(window)

def on_draw(self):
arcade.start_render()
arcade.set_background_color(arcade.color.BLACK)

def on_show(self):
self.setup()

def setup(self):
self.ui_manager.purge_ui_elements()
flat = UIFlatButton('Hello world', center_x=200, center_y=self.window.height // 2, width=200, height=40)
flat.set_style_attrs(
font_color=arcade.color.WHITE,
font_color_hover=arcade.color.WHITE,
font_color_press=arcade.color.WHITE,
bg_color=(51, 139, 57),
bg_color_hover=(51, 139, 57),
bg_color_press=(28, 71, 32),
border_color=(51, 139, 57),
border_color_hover=arcade.color.WHITE,
border_color_press=arcade.color.WHITE
)
self.ui_manager.add_ui_element(flat)

# creates a new class, which will match the id
UIStyle.default_style().set_class_attrs(
'right_button',
font_color=arcade.color.WHITE,
font_color_hover=arcade.color.WHITE,
font_color_press=arcade.color.WHITE,
bg_color=(135, 21, 25),
bg_color_hover=(135, 21, 25),
bg_color_press=(122, 21, 24),
border_color=(135, 21, 25),
border_color_hover=arcade.color.WHITE,
border_color_press=arcade.color.WHITE
)
self.ui_manager.add_ui_element(UIGhostFlatButton(
'Hello world',
center_x=600,
center_y=self.window.height // 2,
width=200,
height=40,
id='right_button'
))


if __name__ == '__main__':
window = arcade.Window(title='ARCADE_GUI')
window.show_view(MyView(window))
arcade.run()
Binary file added doc/examples/gui_custom_style.png
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_custom_style.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:orphan:

.. _gui_custom_style:

GUI Custom Style
================

.. note::

This example requires Arcade 2.4a10 or higher.

.. image:: gui_custom_style.png
:width: 600px
:align: center
:alt: GUI Custom Style

.. literalinclude:: ../../arcade/examples/gui_custom_style.py
:caption: gui_custom_style.py
:linenos:
7 changes: 6 additions & 1 deletion doc/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,19 @@ Resizable Window and Fullscreen Games
:ref:`full_screen_example`


Buttons and Dialog Boxes
Graphical User Interface
^^^^^^^^^^^^^^^^^^^^^^^^

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

:ref:`gui_elements`

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

:ref:`gui_custom_style`


Grid-Based Games
----------------
Expand Down
4 changes: 2 additions & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ game without learning a complex framework.
:caption: Getting Started
:maxdepth: 1

installation
get_started
installation
pygame_comparison
sample_games
examples/index
Expand All @@ -208,9 +208,9 @@ game without learning a complex framework.
:maxdepth: 1
:caption: Tutorials

tutorials/views/index
examples/platform_tutorial/index
tutorials/pymunk_platformer/index
tutorials/views/index
tutorials/card_game/index
tutorials/lights/index

Expand Down
8 changes: 8 additions & 0 deletions doc/social.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Social Media
============

* `Discord <https://discord.gg/ZjGDqMp>`_ - The most active spot
* `Reddit /r/pythonarcade <https://www.reddit.com/r/pythonarcade/>`_ The next most active spot
* `Twitter @ArcadeLibrary <https://twitter.com/ArcadeLibrary>`_ Good for announcements
* `Instagram @PythonArcadeLibrary <https://www.instagram.com/PythonArcadeLibrary/>`_
* `Facebook <https://www.facebook.com/ArcadeLibrary/>`_

0 comments on commit abee0a2

Please sign in to comment.