split project to modules and experiment with mapview flower
This commit is contained in:
parent
6c57d78a2e
commit
355a9de14b
12 changed files with 295 additions and 278 deletions
32
.gitignore
vendored
32
.gitignore
vendored
|
@ -57,19 +57,6 @@ coverage.xml
|
||||||
*.mo
|
*.mo
|
||||||
*.pot
|
*.pot
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|
||||||
|
@ -112,20 +99,5 @@ ENV/
|
||||||
env.bak/
|
env.bak/
|
||||||
venv.bak/
|
venv.bak/
|
||||||
|
|
||||||
# Spyder project settings
|
# MapView Cache
|
||||||
.spyderproject
|
cache/
|
||||||
.spyproject
|
|
||||||
|
|
||||||
# Rope project settings
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# mkdocs documentation
|
|
||||||
/site
|
|
||||||
|
|
||||||
# mypy
|
|
||||||
.mypy_cache/
|
|
||||||
.dmypy.json
|
|
||||||
dmypy.json
|
|
||||||
|
|
||||||
# Pyre type checker
|
|
||||||
.pyre/
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ A map-based social gardening
|
||||||
- `./setup_venv.sh pre` - same as above, for `python 3.8` in `ubuntu 20.04` where we cannot use the stable `kivy 1.11.1` yet
|
- `./setup_venv.sh pre` - same as above, for `python 3.8` in `ubuntu 20.04` where we cannot use the stable `kivy 1.11.1` yet
|
||||||
|
|
||||||
- `source venv/bin/activate` - enter the virtual environment
|
- `source venv/bin/activate` - enter the virtual environment
|
||||||
|
- `garden install mapview`
|
||||||
|
|
||||||
- `./build.sh` - run buildozer inside the virtual env to build and deploy
|
- `./build.sh` - run buildozer inside the virtual env to build and deploy
|
||||||
- `./cleanup.sh` - removes the work dirs from the local repo
|
- `./cleanup.sh` - removes the work dirs from the local repo
|
||||||
|
|
18
forestmapview.kv
Normal file
18
forestmapview.kv
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#:import MapView kivy.garden.mapview.MapView
|
||||||
|
#:import GpsBlinker gpsblinker.GpsBlinker
|
||||||
|
#:include gpsblinker.kv
|
||||||
|
|
||||||
|
<ForestMapView>:
|
||||||
|
lat: 42.131331
|
||||||
|
lon: 24.747571
|
||||||
|
zoom: 18
|
||||||
|
on_zoom:
|
||||||
|
self.zoom = 15 if self.zoom < 15 else self.zoom
|
||||||
|
on_lat:
|
||||||
|
pass
|
||||||
|
on_lon:
|
||||||
|
pass
|
||||||
|
GpsBlinker:
|
||||||
|
lat: root.lat
|
||||||
|
lon: root.lon
|
||||||
|
id: blinker
|
4
forestmapview.py
Normal file
4
forestmapview.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from kivy.garden.mapview import MapView
|
||||||
|
|
||||||
|
class ForestMapView(MapView):
|
||||||
|
pass
|
70
game.py
Normal file
70
game.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
from kivy.uix.widget import Widget
|
||||||
|
|
||||||
|
def collides(rect1, rect2):
|
||||||
|
r1x = rect1[0][0]
|
||||||
|
r1y = rect1[0][1]
|
||||||
|
r2x = rect2[0][0]
|
||||||
|
r2y = rect2[0][1]
|
||||||
|
r1w = rect1[1][0]
|
||||||
|
r1h = rect1[1][1]
|
||||||
|
r2w = rect2[1][0]
|
||||||
|
r2h = rect2[1][1]
|
||||||
|
|
||||||
|
if (r1x < r2x + r2w and r1x + r1w > r2x and r1y < r2y + r2h and r1y + r1h > r2y):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
class GameWidget(Widget):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self._keyboard = Window.request_keyboard(self._on_keyboard_closed, self)
|
||||||
|
self._keyboard.bind(on_key_down=self._on_key_down)
|
||||||
|
self._keyboard.bind(on_key_up=self._on_key_up)
|
||||||
|
|
||||||
|
self.nearbyobj = []
|
||||||
|
|
||||||
|
#for obj in range(10):
|
||||||
|
|
||||||
|
with self.canvas:
|
||||||
|
self.player = Rectangle(source="assets/images/player.png", pos=(0,0), size=(100,100))
|
||||||
|
self.enemy = Rectangle(pos=(300,300), size=(80,80))
|
||||||
|
|
||||||
|
self.keysPressed = set()
|
||||||
|
|
||||||
|
Clock.schedule_interval(self.move_step,0)
|
||||||
|
|
||||||
|
def _on_keyboard_closed(self):
|
||||||
|
self._keyboard.unbind(on_key_down=self._on_key_down)
|
||||||
|
self._keyboard.unbind(on_key_up=self._on_key_up)
|
||||||
|
self._keyboard = None
|
||||||
|
|
||||||
|
def _on_key_down(self, keyboard, keycode, text, modifiers):
|
||||||
|
self.keysPressed.add(text)
|
||||||
|
|
||||||
|
def _on_key_up(self,keyboard,keycode):
|
||||||
|
text = keycode[1]
|
||||||
|
if text in self.keysPressed:
|
||||||
|
self.keysPressed.remove(text)
|
||||||
|
|
||||||
|
def move_step(self,dt):
|
||||||
|
currentx = self.player.pos[0]
|
||||||
|
currenty = self.player.pos[1]
|
||||||
|
|
||||||
|
step_size = 200 * dt
|
||||||
|
|
||||||
|
if "w" in self.keysPressed:
|
||||||
|
currenty += step_size
|
||||||
|
if "s" in self.keysPressed:
|
||||||
|
currenty -= step_size
|
||||||
|
if "a" in self.keysPressed:
|
||||||
|
currentx -= step_size
|
||||||
|
if "d" in self.keysPressed:
|
||||||
|
currentx += step_size
|
||||||
|
|
||||||
|
self.player.pos = (currentx, currenty)
|
||||||
|
|
||||||
|
if collides((self.player.pos,self.player.size),(self.enemy.pos,self.size)):
|
||||||
|
print("X")
|
||||||
|
else:
|
||||||
|
print('.')
|
1
gpsblinker.kv
Normal file
1
gpsblinker.kv
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<GpsBlinker>:
|
7
gpsblinker.py
Normal file
7
gpsblinker.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from kivy.garden.mapview import MapMarker
|
||||||
|
|
||||||
|
class GpsBlinker(MapMarker):
|
||||||
|
def blink(self):
|
||||||
|
# Animantion that changes the blink size and opacity
|
||||||
|
# When the animation completes, reset the animation, then repeat
|
||||||
|
pass
|
12
gpshelper.py
Normal file
12
gpshelper.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from kivy.app import App
|
||||||
|
|
||||||
|
class GpsHelper():
|
||||||
|
def run(self):
|
||||||
|
# Start blinking the GpsBlinker
|
||||||
|
|
||||||
|
# Get a reference to GpsBlinker, then call blink()
|
||||||
|
#gps_blinker = App.get_running_app().root.ids.mapview.ids.blinker
|
||||||
|
#gps_blinker.blink()
|
||||||
|
|
||||||
|
# Request permission on Android
|
||||||
|
pass
|
140
main.kv
140
main.kv
|
@ -1,137 +1,5 @@
|
||||||
#: import sm kivy.uix.screenmanager
|
#:include forestmapview.kv
|
||||||
#: import CheckBox kivy.uix.checkbox
|
|
||||||
|
|
||||||
<CustLabel@Label>
|
ForestMapView:
|
||||||
color: 1, 1, 1, 1
|
orientation: 'vertical'
|
||||||
|
id: mapview
|
||||||
<CustomPopup>:
|
|
||||||
size_hint: .5, .5
|
|
||||||
auto_dismiss: False
|
|
||||||
title: "The Popup"
|
|
||||||
Button:
|
|
||||||
text: "Close"
|
|
||||||
on_press: root.dismiss()
|
|
||||||
|
|
||||||
SampleBoxLayout:
|
|
||||||
|
|
||||||
<SampleBoxLayout>:
|
|
||||||
orientation: "vertical"
|
|
||||||
padding: 10
|
|
||||||
spacing: 10
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .22
|
|
||||||
CustLabel:
|
|
||||||
text: "Are you over 18"
|
|
||||||
size_hint_x: .80
|
|
||||||
CheckBox:
|
|
||||||
on_active: root.checkbox_18_clicked(self, self.active)
|
|
||||||
size_hint_x: .55
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .55
|
|
||||||
CustLabel:
|
|
||||||
text: "Favorite Color"
|
|
||||||
size_hint_x: .265
|
|
||||||
CheckBox:
|
|
||||||
group: "fav_color"
|
|
||||||
value: root.blue
|
|
||||||
size_hint_x: .05
|
|
||||||
CustLabel:
|
|
||||||
text: "Blue"
|
|
||||||
size_hint_x: .15
|
|
||||||
CheckBox:
|
|
||||||
group: "fav_color"
|
|
||||||
value: root.red
|
|
||||||
size_hint_x: .05
|
|
||||||
CustLabel:
|
|
||||||
text: "Red"
|
|
||||||
size_hint_x: .15
|
|
||||||
CheckBox:
|
|
||||||
group: "fav_color"
|
|
||||||
value: root.green
|
|
||||||
size_hint_x: .05
|
|
||||||
CustLabel:
|
|
||||||
text: "Green"
|
|
||||||
size_hint_x: .15
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
height: 30
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .25
|
|
||||||
CustLabel:
|
|
||||||
text: str(slider_id.value)
|
|
||||||
Slider:
|
|
||||||
id: slider_id
|
|
||||||
min: -100
|
|
||||||
max: 100
|
|
||||||
value: 0
|
|
||||||
step: 1
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .25
|
|
||||||
CustLabel:
|
|
||||||
text: "On / Off"
|
|
||||||
Switch:
|
|
||||||
id: switch_id
|
|
||||||
on_active: root.switch_on(self, self.active)
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
height: 30
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .25
|
|
||||||
Button:
|
|
||||||
text: "Open Popup"
|
|
||||||
on_press: root.open_popup()
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .25
|
|
||||||
Spinner:
|
|
||||||
text: "First"
|
|
||||||
values: ["First", "Second", "Third"]
|
|
||||||
id: spinner_id
|
|
||||||
on_text: root.spinner_clicked(spinner_id.text)
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: 30
|
|
||||||
|
|
||||||
BoxLayout:
|
|
||||||
orientation: "horizontal"
|
|
||||||
size_hint_x: .25
|
|
||||||
TabbedPanel:
|
|
||||||
do_default_tab: False
|
|
||||||
TabbedPanelItem:
|
|
||||||
text: "1st Tab"
|
|
||||||
Label:
|
|
||||||
text: "Content of First Panel"
|
|
||||||
color: 1, 1, 1, 1
|
|
||||||
TabbedPanelItem:
|
|
||||||
text: "2nd Tab"
|
|
||||||
Label:
|
|
||||||
text: "Content of Second Panel"
|
|
||||||
color: 1, 1, 1, 1
|
|
||||||
TabbedPanelItem:
|
|
||||||
text: "3rd Tab"
|
|
||||||
Label:
|
|
||||||
text: "Content of Third Panel"
|
|
||||||
color: 1, 1, 1, 1
|
|
||||||
|
|
||||||
<ScreenManagement>:
|
|
||||||
transition: sm.FadeTransition()
|
|
||||||
MainScreen:
|
|
||||||
AboutScreen:
|
|
||||||
|
|
||||||
<MainScreen>:
|
|
||||||
|
|
||||||
<AboutScreen>:
|
|
130
main.py
130
main.py
|
@ -1,5 +1,8 @@
|
||||||
|
# Import system modules
|
||||||
from random import randrange
|
from random import randrange
|
||||||
|
|
||||||
|
# Import Kivy modules
|
||||||
|
#from kivy.app import App
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
|
@ -7,14 +10,17 @@ from kivy.lang import Builder
|
||||||
from kivy.uix.screenmanager import Screen, ScreenManager
|
from kivy.uix.screenmanager import Screen, ScreenManager
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
from kivy.uix.popup import Popup
|
|
||||||
from kivy.uix.widget import Widget
|
|
||||||
|
|
||||||
from kivy.properties import ObjectProperty
|
|
||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
|
|
||||||
from kivy.graphics import Rectangle
|
from kivy.graphics import Rectangle
|
||||||
|
|
||||||
|
# Import local modules
|
||||||
|
from forestmapview import ForestMapView
|
||||||
|
from gpshelper import GpsHelper
|
||||||
|
from settings import SampleBoxLayout
|
||||||
|
from game import GameWidget
|
||||||
|
|
||||||
Builder.load_string("""
|
Builder.load_string("""
|
||||||
<ScreenOne>:
|
<ScreenOne>:
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
@ -41,125 +47,25 @@ class ScreenOne(Screen):
|
||||||
class ScreenTwo(Screen):
|
class ScreenTwo(Screen):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
screen_manager = ScreenManager()
|
|
||||||
screen_manager.add_widget(ScreenOne(name="screen_one"))
|
|
||||||
screen_manager.add_widget(ScreenTwo(name="screen_two"))
|
|
||||||
|
|
||||||
def collides(rect1, rect2):
|
|
||||||
r1x = rect1[0][0]
|
|
||||||
r1y = rect1[0][1]
|
|
||||||
r2x = rect2[0][0]
|
|
||||||
r2y = rect2[0][1]
|
|
||||||
r1w = rect1[1][0]
|
|
||||||
r1h = rect1[1][1]
|
|
||||||
r2w = rect2[1][0]
|
|
||||||
r2h = rect2[1][1]
|
|
||||||
|
|
||||||
if (r1x < r2x + r2w and r1x + r1w > r2x and r1y < r2y + r2h and r1y + r1h > r2y):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
class GameWidget(Widget):
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super().__init__(**kwargs)
|
|
||||||
self._keyboard = Window.request_keyboard(self._on_keyboard_closed, self)
|
|
||||||
self._keyboard.bind(on_key_down=self._on_key_down)
|
|
||||||
self._keyboard.bind(on_key_up=self._on_key_up)
|
|
||||||
|
|
||||||
self.nearbyobj = []
|
|
||||||
|
|
||||||
#for obj in range(10):
|
|
||||||
|
|
||||||
with self.canvas:
|
|
||||||
self.player = Rectangle(source="assets/images/player.png", pos=(0,0), size=(100,100))
|
|
||||||
self.enemy = Rectangle(pos=(300,300), size=(80,80))
|
|
||||||
|
|
||||||
self.keysPressed = set()
|
|
||||||
|
|
||||||
Clock.schedule_interval(self.move_step,0)
|
|
||||||
|
|
||||||
def _on_keyboard_closed(self):
|
|
||||||
self._keyboard.unbind(on_key_down=self._on_key_down)
|
|
||||||
self._keyboard.unbind(on_key_up=self._on_key_up)
|
|
||||||
self._keyboard = None
|
|
||||||
|
|
||||||
def _on_key_down(self, keyboard, keycode, text, modifiers):
|
|
||||||
self.keysPressed.add(text)
|
|
||||||
|
|
||||||
def _on_key_up(self,keyboard,keycode):
|
|
||||||
text = keycode[1]
|
|
||||||
if text in self.keysPressed:
|
|
||||||
self.keysPressed.remove(text)
|
|
||||||
|
|
||||||
def move_step(self,dt):
|
|
||||||
currentx = self.player.pos[0]
|
|
||||||
currenty = self.player.pos[1]
|
|
||||||
|
|
||||||
step_size = 200 * dt
|
|
||||||
|
|
||||||
if "w" in self.keysPressed:
|
|
||||||
currenty += step_size
|
|
||||||
if "s" in self.keysPressed:
|
|
||||||
currenty -= step_size
|
|
||||||
if "a" in self.keysPressed:
|
|
||||||
currentx -= step_size
|
|
||||||
if "d" in self.keysPressed:
|
|
||||||
currentx += step_size
|
|
||||||
|
|
||||||
self.player.pos = (currentx, currenty)
|
|
||||||
|
|
||||||
if collides((self.player.pos,self.player.size),(self.enemy.pos,self.size)):
|
|
||||||
print("X")
|
|
||||||
else:
|
|
||||||
print('.')
|
|
||||||
|
|
||||||
class GlobalForest(App):
|
class GlobalForest(App):
|
||||||
def build(self):
|
def build(self):
|
||||||
#return Label(text='Hello world')
|
#return Label(text='Hello world')
|
||||||
return GameWidget()
|
return GameWidget()
|
||||||
|
|
||||||
class CustomPopup(Popup):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class SampleBoxLayout(BoxLayout):
|
|
||||||
checkbox_is_active = ObjectProperty(False)
|
|
||||||
def checkbox_18_clicked(self, instance, value):
|
|
||||||
if value is True:
|
|
||||||
print("Checkbox Checked")
|
|
||||||
else:
|
|
||||||
print("Checkbox is Unchecked")
|
|
||||||
|
|
||||||
blue = ObjectProperty(True)
|
|
||||||
red = ObjectProperty(False)
|
|
||||||
green = ObjectProperty(False)
|
|
||||||
|
|
||||||
def switch_on(self, instance, value):
|
|
||||||
if value is True:
|
|
||||||
print("Switch On")
|
|
||||||
else:
|
|
||||||
print("Switch Off")
|
|
||||||
|
|
||||||
def open_popup(self):
|
|
||||||
the_popup = CustomPopup()
|
|
||||||
the_popup.open()
|
|
||||||
|
|
||||||
def spinner_clicked(self, value):
|
|
||||||
print("Spinner Value " + value)
|
|
||||||
|
|
||||||
class MainApp(App):
|
class MainApp(App):
|
||||||
def build(self):
|
def build(self):
|
||||||
#Window.clearcolor = (1, 1, 1, 1)
|
pass
|
||||||
return screen_manager
|
#Window.clearcolor = (0, 0, 0, 0)
|
||||||
|
#return SampleBoxLayout()
|
||||||
|
|
||||||
global app, screens
|
def on_start(self):
|
||||||
app = self
|
#Initialize GPS
|
||||||
screens = {'main_screen': MainScreen(name='main_screen'),
|
GpsHelper().run()
|
||||||
'about_screen': AboutScreen(name='about_screen')}
|
|
||||||
self.screen_manager = ScreenManager
|
|
||||||
self.main()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
#screen_manager = ScreenManager()
|
||||||
|
#screen_manager.add_widget(ScreenOne(name="screen_one"))
|
||||||
|
#screen_manager.add_widget(ScreenTwo(name="screen_two"))
|
||||||
#app = GlobalForest()
|
#app = GlobalForest()
|
||||||
app = MainApp()
|
app = MainApp()
|
||||||
app.run()
|
app.run()
|
||||||
|
|
127
settings.kv
Normal file
127
settings.kv
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#: import CheckBox kivy.uix.checkbox
|
||||||
|
|
||||||
|
<CustLabel@Label>
|
||||||
|
color: 1, 1, 1, 1
|
||||||
|
|
||||||
|
<CustomPopup>:
|
||||||
|
size_hint: .5, .5
|
||||||
|
auto_dismiss: False
|
||||||
|
title: "The Popup"
|
||||||
|
Button:
|
||||||
|
text: "Close"
|
||||||
|
on_press: root.dismiss()
|
||||||
|
|
||||||
|
SampleBoxLayout:
|
||||||
|
|
||||||
|
<SampleBoxLayout>:
|
||||||
|
orientation: "vertical"
|
||||||
|
padding: 10
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .22
|
||||||
|
CustLabel:
|
||||||
|
text: "Are you over 18"
|
||||||
|
size_hint_x: .80
|
||||||
|
CheckBox:
|
||||||
|
on_active: root.checkbox_18_clicked(self, self.active)
|
||||||
|
size_hint_x: .55
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .55
|
||||||
|
CustLabel:
|
||||||
|
text: "Favorite Color"
|
||||||
|
size_hint_x: .265
|
||||||
|
CheckBox:
|
||||||
|
group: "fav_color"
|
||||||
|
value: root.blue
|
||||||
|
size_hint_x: .05
|
||||||
|
CustLabel:
|
||||||
|
text: "Blue"
|
||||||
|
size_hint_x: .15
|
||||||
|
CheckBox:
|
||||||
|
group: "fav_color"
|
||||||
|
value: root.red
|
||||||
|
size_hint_x: .05
|
||||||
|
CustLabel:
|
||||||
|
text: "Red"
|
||||||
|
size_hint_x: .15
|
||||||
|
CheckBox:
|
||||||
|
group: "fav_color"
|
||||||
|
value: root.green
|
||||||
|
size_hint_x: .05
|
||||||
|
CustLabel:
|
||||||
|
text: "Green"
|
||||||
|
size_hint_x: .15
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
height: 30
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .25
|
||||||
|
CustLabel:
|
||||||
|
text: str(slider_id.value)
|
||||||
|
Slider:
|
||||||
|
id: slider_id
|
||||||
|
min: -100
|
||||||
|
max: 100
|
||||||
|
value: 0
|
||||||
|
step: 1
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .25
|
||||||
|
CustLabel:
|
||||||
|
text: "On / Off"
|
||||||
|
Switch:
|
||||||
|
id: switch_id
|
||||||
|
on_active: root.switch_on(self, self.active)
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
height: 30
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .25
|
||||||
|
Button:
|
||||||
|
text: "Open Popup"
|
||||||
|
on_press: root.open_popup()
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .25
|
||||||
|
Spinner:
|
||||||
|
text: "First"
|
||||||
|
values: ["First", "Second", "Third"]
|
||||||
|
id: spinner_id
|
||||||
|
on_text: root.spinner_clicked(spinner_id.text)
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: 30
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_x: .25
|
||||||
|
TabbedPanel:
|
||||||
|
do_default_tab: False
|
||||||
|
TabbedPanelItem:
|
||||||
|
text: "1st Tab"
|
||||||
|
Label:
|
||||||
|
text: "Content of First Panel"
|
||||||
|
color: 1, 1, 1, 1
|
||||||
|
TabbedPanelItem:
|
||||||
|
text: "2nd Tab"
|
||||||
|
Label:
|
||||||
|
text: "Content of Second Panel"
|
||||||
|
color: 1, 1, 1, 1
|
||||||
|
TabbedPanelItem:
|
||||||
|
text: "3rd Tab"
|
||||||
|
Label:
|
||||||
|
text: "Content of Third Panel"
|
||||||
|
color: 1, 1, 1, 1
|
31
settings.py
Normal file
31
settings.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
|
from kivy.uix.popup import Popup
|
||||||
|
from kivy.properties import ObjectProperty
|
||||||
|
|
||||||
|
class CustomPopup(Popup):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class SampleBoxLayout(BoxLayout):
|
||||||
|
checkbox_is_active = ObjectProperty(False)
|
||||||
|
def checkbox_18_clicked(self, instance, value):
|
||||||
|
if value is True:
|
||||||
|
print("Checkbox Checked")
|
||||||
|
else:
|
||||||
|
print("Checkbox is Unchecked")
|
||||||
|
|
||||||
|
blue = ObjectProperty(True)
|
||||||
|
red = ObjectProperty(False)
|
||||||
|
green = ObjectProperty(False)
|
||||||
|
|
||||||
|
def switch_on(self, instance, value):
|
||||||
|
if value is True:
|
||||||
|
print("Switch On")
|
||||||
|
else:
|
||||||
|
print("Switch Off")
|
||||||
|
|
||||||
|
def open_popup(self):
|
||||||
|
the_popup = CustomPopup()
|
||||||
|
the_popup.open()
|
||||||
|
|
||||||
|
def spinner_clicked(self, value):
|
||||||
|
print("Spinner Value " + value)
|
Loading…
Reference in a new issue