Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import kivy
|
2 |
+
from kivy.app import App
|
3 |
+
from kivy.uix.boxlayout import BoxLayout
|
4 |
+
from kivy.uix.label import Label
|
5 |
+
from kivy.uix.button import Button
|
6 |
+
from kivy.uix.screenmanager import ScreenManager, Screen
|
7 |
+
|
8 |
+
kivy.require('2.1.0') # Replace with the version of Kivy you have
|
9 |
+
|
10 |
+
class HomeScreen(Screen):
|
11 |
+
def __init__(self, **kwargs):
|
12 |
+
super().__init__(**kwargs)
|
13 |
+
layout = BoxLayout(orientation='vertical')
|
14 |
+
layout.add_widget(Label(text='Welcome to Queen\'s Jewels', font_size=24))
|
15 |
+
btn_products = Button(text='View Products', size_hint=(1, 0.2))
|
16 |
+
btn_products.bind(on_press=self.go_to_products)
|
17 |
+
layout.add_widget(btn_products)
|
18 |
+
self.add_widget(layout)
|
19 |
+
|
20 |
+
def go_to_products(self, instance):
|
21 |
+
self.manager.current = 'products'
|
22 |
+
|
23 |
+
class ProductScreen(Screen):
|
24 |
+
def __init__(self, **kwargs):
|
25 |
+
super().__init__(**kwargs)
|
26 |
+
layout = BoxLayout(orientation='vertical')
|
27 |
+
layout.add_widget(Label(text='Product List', font_size=24))
|
28 |
+
# Add more widgets for products here
|
29 |
+
btn_back = Button(text='Back to Home', size_hint=(1, 0.2))
|
30 |
+
btn_back.bind(on_press=self.go_to_home)
|
31 |
+
layout.add_widget(btn_back)
|
32 |
+
self.add_widget(layout)
|
33 |
+
|
34 |
+
def go_to_home(self, instance):
|
35 |
+
self.manager.current = 'home'
|
36 |
+
|
37 |
+
class QueenJewelsApp(App):
|
38 |
+
def build(self):
|
39 |
+
sm = ScreenManager()
|
40 |
+
sm.add_widget(HomeScreen(name='home'))
|
41 |
+
sm.add_widget(ProductScreen(name='products'))
|
42 |
+
return sm
|
43 |
+
|
44 |
+
if __name__ == '__main__':
|
45 |
+
QueenJewelsApp().run()
|