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