forked from pythonarcade/arcade
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/pvcraven/arcade into…
… development
- Loading branch information
Showing
13 changed files
with
229 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from typing import cast | ||
|
||
import arcade | ||
from arcade.gui import UILabel, UIInputBox, UIFlatButton, UIManager | ||
|
||
|
||
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): | ||
print('on_show') | ||
self.setup() | ||
|
||
def setup(self): | ||
self.ui_manager.purge_ui_elements() | ||
|
||
self.ui_manager.add_ui_element(UILabel( | ||
text='Username:', | ||
center_x=100, | ||
center_y=self.window.height // 2, | ||
width=300, | ||
height=40, | ||
)) | ||
|
||
input_box = UIInputBox(center_x=350, | ||
center_y=self.window.height // 2, | ||
width=300, | ||
height=40, | ||
id='username') | ||
self.ui_manager.add_ui_element(input_box) | ||
|
||
submit_button = UIFlatButton(text='Login', | ||
center_x=650, | ||
center_y=self.window.height // 2, | ||
width=200, | ||
height=40, | ||
id='submit_button') | ||
self.ui_manager.add_ui_element(submit_button) | ||
|
||
self.ui_manager.add_ui_element(UILabel( | ||
text='', | ||
center_x=self.window.width // 2, | ||
center_y=self.window.height // 2 - 100, | ||
width=600, | ||
height=40, | ||
id='login_message' | ||
)) | ||
|
||
@input_box.event('on_enter') | ||
@submit_button.event('on_click') | ||
def submit(): | ||
username_input = cast(UIInputBox, self.ui_manager.find_by_id('username')) | ||
username = username_input.text | ||
|
||
login_message: UILabel = cast(UILabel, self.ui_manager.find_by_id('login_message')) | ||
login_message.text = f'Welcome {username}, you are my first player.' | ||
|
||
|
||
if __name__ == '__main__': | ||
window = arcade.Window(title='ARCADE_GUI') | ||
window.show_view(MyView(window)) | ||
arcade.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import arcade | ||
|
||
import arcade.gui | ||
from arcade.gui import UIManager | ||
|
||
|
||
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() | ||
|
||
def on_show(self): | ||
print('on_show') | ||
self.setup() | ||
arcade.set_background_color(arcade.color.BLACK) | ||
|
||
def setup(self): | ||
self.ui_manager.purge_ui_elements() | ||
|
||
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') | ||
self.ui_manager.add_ui_element(arcade.gui.UIImageButton( | ||
center_x=self.window.width // 2, | ||
center_y=window.height // 2, | ||
normal_texture=button_normal, | ||
hover_texture=hovered_texture, | ||
press_texture=pressed_texture, | ||
text='UIImageButton', | ||
)) | ||
|
||
|
||
if __name__ == '__main__': | ||
window = arcade.Window(title='ARCADE_GUI') | ||
window.show_view(MyView(window)) | ||
arcade.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.