Esempio n. 1
0
def main():
    defaults = dict(
        center_x=0,
        center_y=0,
    )
    window = Window()
    view = UIView()

    style = UIStyle.default_style()
    style.set_class_attrs(UILabel.__name__, )

    layout = ListLayout()
    layout.pack(UILabel(text="1. Red Sun", **defaults), space=15)
    layout.pack(UILabel(text="2. Green Gras", **defaults))
    layout.pack(UILabel(text="3. Blue Sky", **defaults), space=20)
    view.manager.add_layout(layout)

    layout = ListLayout(vertical=False)
    layout.pack(UILabel(text="4. Red Sun", **defaults), space=15)
    layout.pack(UILabel(text="5. Green Gras", **defaults))
    layout.pack(UILabel(text="6. Blue Sky", **defaults), space=20)
    view.manager.add_layout(layout)

    window.show_view(view)
    arcade.run()
Esempio n. 2
0
 def setup(self):
     self.ui_manager.purge_ui_elements()
     #default style sheet
     UIStyle.default_style().set_class_attrs(
         'buttons',
         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)
     #add buttons to UI manager
     self.ui_manager.add_ui_element(
         SinglePlayerButton(self.window.height // 2, self.window,
                            self.ui_manager))
     self.ui_manager.add_ui_element(
         MultiPlayerButton(self.window.height // 3, self.window,
                           self.ui_manager))
Esempio n. 3
0
    def on_show_view(self):
        arcade.set_background_color(arcade.color.BLACK)
        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'))
Esempio n. 4
0
    def __init__(self,
                 center_x=0,
                 center_y=0,
                 id: Optional[str] = None,
                 style: UIStyle = None,
                 **kwargs):
        super().__init__()
        # ID for this element, to search in view by id or identify this element from an event
        self.__id = id
        self.mng: Optional['UIManager'] = None

        # unique id, to overwrite style for exactly this element, DONT CHANGE THIS LATER
        self.__style_id = str(uuid4())
        self.style_classes = ['globals']
        self._style: UIStyle = style if style else UIStyle.default_style()
        self._style.push_handlers(self.on_style_change)

        # what do we need to look like a proper arcade.Sprite
        # self.texture <- subclass
        # self.width/height <- subclass
        self.center_x = center_x
        self.center_y = center_y
Esempio n. 5
0
import arcade
from arcade.gui.ui_style import UIStyle

from src.menu import Menu
from src.globals import *

if __name__ == "__main__":
    # Sets a basic UIStyle for a label
    UIStyle.default_style().set_class_attrs(
        'label',
        font_color=arcade.color.WHITE,
        font_color_hover=arcade.color.WHITE,
        font_color_press=arcade.color.WHITE,
    )

    window = arcade.Window(title='Democracy defender',
                           height=HEIGHT,
                           width=WIDTH)
    window.show_view(Menu())
    arcade.run()
Esempio n. 6
0
def test_ui_element_uses_default_style():
    button = UIFlatButton('Love snakes.', 100, 100, 100, 30)

    assert button._style == UIStyle.default_style()