diff --git a/arcade/examples/gui_custom_style.py b/arcade/examples/gui_custom_style.py new file mode 100644 index 000000000..e9e4dd193 --- /dev/null +++ b/arcade/examples/gui_custom_style.py @@ -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() diff --git a/doc/examples/gui_custom_style.png b/doc/examples/gui_custom_style.png new file mode 100644 index 000000000..ba49fe435 Binary files /dev/null and b/doc/examples/gui_custom_style.png differ diff --git a/doc/examples/gui_custom_style.rst b/doc/examples/gui_custom_style.rst new file mode 100644 index 000000000..077922a0b --- /dev/null +++ b/doc/examples/gui_custom_style.rst @@ -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: diff --git a/doc/examples/index.rst b/doc/examples/index.rst index 2afb91db6..7568bb301 100644 --- a/doc/examples/index.rst +++ b/doc/examples/index.rst @@ -443,7 +443,7 @@ Resizable Window and Fullscreen Games :ref:`full_screen_example` -Buttons and Dialog Boxes +Graphical User Interface ^^^^^^^^^^^^^^^^^^^^^^^^ .. figure:: thumbs/gui_elements.png @@ -451,6 +451,11 @@ Buttons and Dialog Boxes :ref:`gui_elements` +.. figure:: thumbs/gui_custom_style.png + :figwidth: 170px + + :ref:`gui_custom_style` + Grid-Based Games ---------------- diff --git a/doc/index.rst b/doc/index.rst index 5c5748b46..8b9762165 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -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 @@ -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 diff --git a/doc/social.rst b/doc/social.rst new file mode 100644 index 000000000..099083708 --- /dev/null +++ b/doc/social.rst @@ -0,0 +1,8 @@ +Social Media +============ + +* `Discord `_ - The most active spot +* `Reddit /r/pythonarcade `_ The next most active spot +* `Twitter @ArcadeLibrary `_ Good for announcements +* `Instagram @PythonArcadeLibrary `_ +* `Facebook `_