Last active
August 29, 2015 14:07
-
-
Save quapka/beb8ac8e0e862f38867e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MyScreenManager>: | |
orientation: 'vertical' | |
canvas.before: | |
Color: | |
rgba: 1,1,1,1 | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
MainMenuScreen: | |
FilmMenuScreen: | |
FilmDescriptionScreen: | |
MapScreen: | |
<MainMenuScreen>: | |
name: 'MainMenuScreen' | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
size_hint_y: None | |
height: root.height / 7 | |
text: 'Main Menu' | |
font_size: self.height / 2 | |
color: [0.5, 0.3, 0.81, 0.9] | |
GridLayout: | |
cols: 2 | |
rows: 2 | |
Button: | |
#text: 'Films' | |
background_normal: 'pictures/film1.jpg' | |
background_down: 'pictures/film1.jpg' | |
border: 30, 30, 30, 30 | |
font_size: self.height / 3 | |
on_release: app.root.current = 'FilmMenuScreen' | |
Button: | |
text: 'Credits' | |
font_size: self.height / 3 | |
Button: | |
text: 'Map' | |
font_size: self.height / 3 | |
on_release: app.root.current = 'MapScreen' | |
Button: | |
text: 'Settings' | |
font_size: self.height / 3 | |
<FilmMenuScreen> | |
name: 'FilmMenuScreen' | |
ScrollView: | |
size_hint_y: None | |
height: root.height | |
GridLayout: | |
id: film_box | |
cols:1 | |
size_hint_y: None | |
height: self.minimum_height | |
Label: | |
size_hint_y: None | |
height: root.height / 7 | |
text: 'Film menu' | |
font_size: self.height / 2 | |
color: [0.5, 0.3, 0.81, 0.9]# [0,0,1,1] | |
BoxLayout: | |
Button: | |
size_hint_y: None | |
height: root.height / 7 | |
text: 'Go back' | |
font_size: self.height / 2 | |
on_release: app.root.current = 'MainMenuScreen' | |
<MapScreen> | |
name: 'MapScreen' | |
GridLayout: | |
cols: 1 | |
rows: 2 | |
Image: | |
source: 'pictures/map.png' | |
allow_strech: True | |
keep_ratio: False | |
Button: | |
size_hint_y: None | |
height: root.height / 7 | |
text: 'Go back' | |
font_size: self.height / 2 | |
on_release: app.root.current = 'MainMenuScreen' | |
<FilmDescriptionScreen>: | |
name: 'FilmDescriptionScreen' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from kivy.app import App | |
from kivy.uix.button import Button | |
from kivy.uix.textinput import TextInput | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.label import Label | |
from kivy.uix.screenmanager import ScreenManager, Screen | |
from kivy.uix.scrollview import ScrollView | |
from kivy.clock import Clock | |
from functools import partial | |
import json | |
class FFDMApp(App): | |
def build(self): | |
sm = MyScreenManager() | |
return sm | |
class MyScreenManager(ScreenManager): | |
pass | |
class MainMenuScreen(Screen): | |
pass | |
class FilmMenuScreen(Screen): | |
def __init__(self, **kvargs): | |
super(FilmMenuScreen, self).__init__(**kvargs) | |
Clock.schedule_once(self.add_films, 0.1) | |
def add_films(self, *args): | |
with open('films.json', 'r') as f: | |
films_database = json.load(f) | |
for film in films_database: | |
button = Button(text = film, | |
size_hint_y = None) | |
button.font_size = button.height / 2 | |
button.bind(on_press = partial(self.show_description_screen, 25)) | |
self.ids.film_box.add_widget(button) | |
def show_description_screen(self, *args): | |
self.manager.current = 'FilmDescriptionScreen' | |
class FilmDescriptionScreen(Screen): | |
pass | |
class MapScreen(Screen): | |
pass | |
if __name__ == '__main__': | |
FFDMApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment