Files
2026-06-22 17:42:45 +03:00

56 lines
1.5 KiB
Python

import arcade
from arcade.gui import UIManager, UIAnchorLayout, UITextureButton, UIGridLayout
from game import MainView
class MainMenu(arcade.View):
def __init__(self):
super().__init__()
self.ui = UIManager()
grid = UIGridLayout(
column_count=1,
row_count=4,
size_hint=(0, 0),
vertical_spacing=10,
horizontal_spacing=10,
)
anchor = self.ui.add(UIAnchorLayout(children=[grid]))
normal = arcade.load_texture(":resources:gui_basic_assets/button/red_normal.png")
hover = arcade.load_texture(":resources:gui_basic_assets/button/red_hover.png")
press = arcade.load_texture(":resources:gui_basic_assets/button/red_press.png")
button_start = grid.add(UITextureButton(
text = "Start",
texture=normal,
texture_hovered=hover,
texture_pressed=press
),row=0,column=0)
button_exit = grid.add(UITextureButton(
text = "Exit",
texture=normal,
texture_hovered=hover,
texture_pressed=press
),row=1,column=0)
@button_start.event('on_click')
def on_click(event):
self.window.show_view(MainView())
@button_exit.event('on_click')
def on_click(event):
self.window.close()
def on_show_view(self):
self.ui.enable()
def on_hide_view(self):
self.ui.disable()
def on_draw(self):
self.clear((100,100,200))
self.ui.draw()
if __name__ == '__main__':
window = arcade.Window(fullscreen=True)
window.show_view(MainMenu())
arcade.run()