Hello @cmdvmd, how are you doing?
I really like this amazing project, congrats!
Today I took a time to test widgets, and it's very cool.
I created a very simple example for testing widgets. Maybe you can use in documentation.
from functools import partial
from kivycupertino.app import CupertinoApp
from kivycupertino.uix.button import (
CupertinoButton,
CupertinoSystemButton,
)
from kivycupertino.uix.dialog import CupertinoAlertDialog, CupertinoActionSheet
from kivycupertino.uix.switch import CupertinoSwitch
from kivycupertino.uix.indicator import CupertinoProgressBar
from kivycupertino.uix.label import CupertinoLabel
from kivy.uix.floatlayout import FloatLayout
from kivy.core.window import Window
Window.clearcolor = 0.95, 0.95, 0.95, 1
class MyApp(CupertinoApp):
def alert(self):
def close(x, widget):
self.fl.remove_widget(widget)
alert = CupertinoAlertDialog()
alert.title = 'Alert!'
alert.content = 'Yes, this a alert!'
alert.add_action('Action!', partial(close, widget=alert))
self.fl.add_widget(alert)
def action(self):
def close(x, widget):
self.fl.remove_widget(widget)
action = CupertinoActionSheet()
action.add_action('Close', partial(close, widget=action))
self.fl.add_widget(action)
def progress(self, op, widget):
if op == '-':
widget.value -= 10
else:
widget.value += 10
def build(self):
self.fl = FloatLayout()
label = CupertinoLabel(text='Label')
label.pos_hint = {'center_x': 0.5, 'center_y': 0.6}
btn = CupertinoButton(text='Button')
btn.size_hint = 0.8, 0.06
btn.pos_hint = {'center_x': 0.5, 'center_y': 0.5}
btn.on_release = self.alert
sys_btn = CupertinoSystemButton(text='SystemButton')
sys_btn.pos_hint = {'center_x': 0.5, 'center_y': 0.4}
sys_btn.size_hint_y = 0.06
sys_btn.on_release = self.action
progress = CupertinoProgressBar()
progress.size_hint = 0.8, 0.01
progress.pos_hint = {'center_x': 0.5, 'center_y': 0.3}
progress.value = 50
progress_btn1 = CupertinoSystemButton(text='-')
progress_btn1.size_hint = 0.1, 0.06
progress_btn1.pos_hint = {'center_x': 0.25, 'center_y': 0.25}
progress_btn1.on_release = partial(self.progress, '-', progress)
progress_btn2 = CupertinoSystemButton(text='+')
progress_btn2.size_hint = 0.1, 0.06
progress_btn2.pos_hint = {'center_x': 0.75, 'center_y': 0.25}
progress_btn2.on_release = partial(self.progress, '+', progress)
switch = CupertinoSwitch()
switch.size_hint = 0.1, 0.06
switch.pos_hint = {'center_x': 0.5, 'center_y': 0.2}
self.fl.add_widget(label)
self.fl.add_widget(btn)
self.fl.add_widget(sys_btn)
self.fl.add_widget(progress)
self.fl.add_widget(progress_btn1)
self.fl.add_widget(progress_btn2)
self.fl.add_widget(switch)
return self.fl
MyApp().run()
To run I used s3 screen size
python main.py -m screen:s3,portrait
Full Window:
Alert:
Action:
Thanks a lot, and sorry about my English โค๏ธ