Created
May 27, 2015 21:20
-
-
Save matham/51492fab129ebc8a0925 to your computer and use it in GitHub Desktop.
pres
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
#:import color kivy.utils.get_color_from_hex | |
#:import sp kivy.metrics.sp | |
#:import sin math.sin | |
#:import chain itertools.chain | |
#:set title_color '009688' | |
#:set title_underline 'b2dfdb' | |
#:set subtitle_color '00bcd4' | |
#:set subtitle_underline 'b2ebf2' | |
#:set default_color (0, 0, 0, 1) | |
#:set background_color 'e0f7fa' | |
#:set content_color '000000' | |
#:set font_size 35 | |
<Title@Label> | |
size_hint_y: None | |
height: self.texture_size[1] + sp(20) | |
color1: title_color | |
color2: title_underline | |
font_size: sp(25) | |
canvas.before: | |
Color: | |
rgba: color(root.color1) if root.color1 else default_color | |
Rectangle: | |
size: self.size | |
pos: self.pos | |
Color: | |
rgba: color(root.color2) if root.color2 else default_color | |
Rectangle: | |
pos: self.pos | |
size: self.width, sp(5) | |
<SubTitle@FloatLayout+Title>: | |
color1: subtitle_color | |
color2: subtitle_underline | |
<PresButton@ButtonBehavior+SubTitle>: | |
<ContentLabel@Label>: | |
color: color(content_color) | |
font_size: sp(24) | |
size: self.texture_size | |
size_hint_y: None | |
<CodeLabel@Label> | |
code: '' | |
text: self.code .replace('\t', 'Â ' * 4) | |
font_size: sp(20) | |
canvas.before: | |
Color: | |
rgba: 0, 0, 0, 1 | |
Rectangle: | |
size: self.size | |
pos: self.pos | |
<Spacer@Widget> | |
<RootRule@BoxLayout>: | |
orientation: 'vertical' | |
canvas.before: | |
Color: | |
rgba: color(background_color) | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
Title: | |
text: 'Présentation Kivy - PyCon FR - 26/10/2014' | |
SubTitle: | |
text: sm.current | |
PresButton: | |
pos_hint: {'center_y': .5, 'x': 0} | |
size_hint_x: None | |
width: self.height | |
text: '�' | |
on_press: | |
sm.transition.direction = 'right' | |
sm.current = sm.previous() | |
PresButton: | |
pos_hint: {'center_y': .5, 'right': 1} | |
size_hint_x: None | |
width: self.height | |
text: '→' | |
on_press: | |
sm.transition.direction = 'left' | |
sm.current = sm.next() | |
ScreenManager: | |
id: sm | |
Screen: | |
name: 'Présentation' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
'''Gabriel Pettier | |
Développeur python | |
Contributeur puis Core-Développeur Kivy depuis 2010 | |
 | |
http://tshirtman.fr | |
http://github.com/tshirtman | |
http://twitter.com/tshirtman | |
 | |
http://tangibledisplay.com | |
Développement d'interactions tangibles | |
''' | |
Spacer | |
Screen: | |
name: 'Kivy' | |
BoxLayout: | |
orientation: 'vertical' | |
FloatLayout: | |
id: logo_container | |
size_hint_y: None | |
height: logo.texture_size[1] * 2 | |
Scatter: | |
size_hint: None, None | |
size: logo.size | |
center: logo_container.center | |
Image: | |
id: logo | |
size: self.texture_size | |
source: 'data/logo/kivy-icon-256.png' | |
ContentLabel: | |
text: | |
'''Bibliothèque de Widgets orientés multitouch | |
‣ Développé majoritairement en pur Python, le reste en | |
Cython pour les performances. | |
‣ Multiplatforme: Windows, OSX, Linux, Android et IOS | |
supportés. | |
‣ API graphique directement basée sur OpenGL ES 2.0. | |
‣ Projet Libre et collaboratif, licence MIT. | |
''' | |
Spacer | |
Screen: | |
name: 'Concepts' | |
GridLayout: | |
size_hint: 1, None | |
pos_hint: {'center': (.5, .5)} | |
size_hint: .5, 1 | |
cols: 1 | |
height: self.minimum_height | |
ContentLabel: | |
text_size: self.width, None | |
text: | |
""" | |
‣ Instruction | |
→ Permet d'indiquer un ordre au GPU | |
""" | |
ContentLabel: | |
text_size: self.width, None | |
text: | |
""" | |
‣ Évènement | |
→ Propage une information à tous les acteurs concernés | |
""" | |
Spacer | |
Screen: | |
name: 'Instruction exemple' | |
BoxLayout: | |
orientation: 'vertical' | |
BoxLayout: | |
CodeLabel: | |
code: | |
''' | |
with widget.canvas: | |
\tColor(1, 0, 0, 1, mode='rgba') | |
\tRectangle(pos=widget.pos, size=widget.size) | |
\tColor(.5, .5, .5, 1, mode='rgba') | |
\tEllipse(pos=widget.pos, size=widget.size) | |
''' | |
Widget: | |
canvas: | |
Color: | |
rgba: 1, 0, 0, 1 | |
Rectangle: | |
size: self.size | |
pos: self.pos | |
Color: | |
rgba: .5, .5, .5, 1 | |
Ellipse: | |
pos: self.pos | |
size: self.size | |
Screen: | |
name: 'Évènement' | |
BoxLayout: | |
CodeLabel: | |
code: | |
''' | |
def function(*args): | |
\tprint(args) | |
 | |
widget.bind(on_touch_down=function) | |
''' | |
ContentLabel: | |
text: 'touch me\n' | |
font_size: 15 | |
text_size: self.width, None | |
on_touch_down: self.text += '\n%s' % (','.join(str(x) for x in args)) | |
Screen: | |
name: 'Properties' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
'''Permet de lier les attributs des objets à des | |
évènements. | |
‣ StringProperty | |
‣ NumericProperty | |
‣ ObjectProperty | |
‣ AliasProperty | |
‣ etc… | |
Doit être déclaré sur des sous-classes d'EventDispatcher, | |
qui implémentent le pattern "Observer". Ainsi, il est | |
possible à l'objet de réaliser des actions quand ses | |
propriétés changent de valeur. | |
''' | |
CodeLabel: | |
code: | |
''' | |
class ClassWithProperties(EventDispatcher): | |
\tname = StringProperty('') | |
\tcount = NumericProperty(0) | |
 | |
def on_name(self, value): | |
\tprint "my name changed to %s" % value | |
''' | |
Screen: | |
name: 'Widgets' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
''' | |
‣ Hérite d'EventDispatcher | |
‣ Contient un Canvas (groupe d'instructions). | |
Propose un certain nombre d'évènements par défaut, | |
notamment: | |
‣ on_touch_down | |
‣ on_touch_move | |
‣ on_touch_up | |
''' | |
size_hint_y: None | |
height: self.texture_size[1] | |
BoxLayout: | |
CodeLabel: | |
font_size: sp(20) | |
text: | |
''' | |
class MyWidget(Widget): | |
   active = BooleanProperty(False) | |
 | |
    def __init__(self, **kwargs): | |
        super(MyWidget, self).__init__(**kwargs) | |
        self.bind(on_pos=self.update, on_size=self.update) | |
        with self.canvas: | |
            self.color = Color(1, 1, 1, 1, mode='rgba') | |
            self.rectangle = Rectangle(pos=self.pos, size=self.size) | |
 | |
    def on_active(self, active): | |
        if self.active: | |
            self.color.rgba = (.5, .5, 0, 1) | |
        else: | |
            self.coler.rgba = (1, 1, 1, 1) | |
 | |
    def update(self, *args): | |
        self.rect.pos = self.pos | |
        self.rect.size = self.size | |
 | |
    def on_touch_down(self, touch): | |
        if self.collide_point(*touch.pos): | |
            self.active = not self.active | |
''' | |
font_size: sp(14) | |
Widget: | |
active: False | |
on_touch_down: | |
if self.collide_point(*args[1].pos): self.active = not self.active | |
canvas: | |
Color: | |
rgba: (.5, .5, 0, 1) if self.active else (1, 1, 1, 1) | |
Rectangle: | |
pos: self.pos | |
size: self.size | |
Screen: | |
name: 'Layouts' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
''' | |
Les Widgets sont par défaut complètement libres de leur | |
placement et de leur tailles, qui sont absolues (origine | |
bas-gauche de l'écran). | |
 | |
Certains widgets sont spécialisés dans le placement et le | |
dimensionnement de leurs sous widgets (enfants). | |
 | |
‣ FloatLayout | |
‣ BoxLayout | |
‣ AnchorLayout | |
‣ GridLayout | |
‣ StackLayout | |
‣ etc… | |
''' | |
Spacer | |
Screen: | |
name: 'Layouts - 2 - Hints' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
''' | |
La taille/position des widgets enfants d'un Layout est | |
généralement contrôlée via les propriétés size_hint et | |
pos_hint, qui sont relative au Layout. | |
''' | |
BoxLayout: | |
CodeLabel: | |
text: | |
''' | |
f = FloatLayout() | |
f.add_widget( | |
    Button( | |
        size_hint=(.2, .1), | |
        pos_hint={'center': (.5, .5)}) | |
''' | |
FloatLayout: | |
Button: | |
size_hint: .2, .1 | |
pos_hint: {'center': (.5, .5)} | |
text: 'a button' | |
ContentLabel: | |
text: | |
''' | |
La taille peut être définie arbitrairement en | |
désactivant size_hint dans les directions souhaités: | |
''' | |
BoxLayout: | |
CodeLabel: | |
text: | |
''' | |
f = FloatLayout() | |
f.add_widget( | |
    Button( | |
        size_hint_x=None, | |
        pos_hint={'center': (.5, .5)}, | |
        size_hint_y=.1, | |
        width=250, | |
        text='another button')) | |
''' | |
FloatLayout: | |
Button: | |
size_hint_x: None | |
pos_hint: {'center': (.5, .5)} | |
size_hint_y: .1 | |
width: 250 | |
text: 'another button' | |
Screen: | |
name: 'Le language KV' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
font_size: sp(25) | |
text: | |
''' | |
Python: | |
‣ super pour la logique | |
‣ moins pour la déclaration d'arbres de widgets. | |
Kv: | |
‣ Syntaxe déclarative | |
‣ Détection des dépendances et créations de | |
   branchements automatiques | |
''' | |
BoxLayout: | |
CodeLabel: | |
text: | |
''' | |
w = Widget() | |
with w.canvas: | |
    Color(1, 0, 1, 1, mode='rgba') | |
    rect = Rectangle(pos=w.pos, size=w.size) | |
 | |
def update(self, *args): | |
    rect.pos = w.pos | |
    rect.size = w.size | |
 | |
w.bind(pos=update, size=update) | |
''' | |
ContentLabel: | |
text: 'vs' | |
size_hint_x: None | |
width: self.texture_size[0] * 2 | |
pos_hint: {'center_y': .5} | |
CodeLabel: | |
text: | |
''' | |
from kivy.lang import Builder | |
 | |
KV = """ | |
Widget: | |
    canvas: | |
        Color: | |
            rgba: 1, 0, 1, 1 | |
        Rectangle: | |
            pos: self.pos | |
            size: self.size | |
""" | |
 | |
Builder.load_string(KV) | |
''' | |
Screen: | |
name: 'Le language KV - 2 - Bindings' | |
GridLayout: | |
cols: 2 | |
ContentLabel: | |
text: | |
''' | |
1. Callback: | |
''' | |
CodeLabel: | |
text: | |
''' | |
Widget: | |
    on_pos: | |
        print('my pos is %s' % self.pos) | |
Button: | |
    on_press: | |
        print("I've been pressed") | |
''' | |
Spacer | |
Spacer | |
ContentLabel: | |
text: | |
''' | |
2. Dépendance: | |
''' | |
CodeLabel: | |
text: | |
''' | |
Widget: | |
    canvas.before: | |
        Rectangle: | |
            pos: self.pos | |
            size: self.size | |
''' | |
Screen: | |
name: 'Le language KV - 3 - règles' | |
GridLayout: | |
pos_hint: {'center': (.5, .5)} | |
cols: 2 | |
spacing: 10 | |
ContentLabel: | |
text: | |
''' | |
‣ root rule: Ce qui sera retourné par le loader | |
 une seule autorisée par chaine/fichier. | |
''' | |
text_size: self.size | |
CodeLabel: | |
size_hint_x: .5 | |
text: | |
''' | |
MyWidget: | |
    Label: | |
        text: 'example' | |
''' | |
ContentLabel: | |
text: | |
''' | |
‣ règle de classe: permet de configurer le style et le | |
   contenus de toutes les instances d'une classe. | |
''' | |
text_size: self.size | |
CodeLabel: | |
size_hint_x: .5 | |
text: | |
''' | |
<Widget>: | |
    Label: | |
        text: 'example' | |
''' | |
ContentLabel: | |
text: | |
''' | |
‣ Classes dynamiques: permet de créer une classe en KV, | |
   en déclarant l'héritage avec '@'. | |
''' | |
text_size: self.size | |
CodeLabel: | |
size_hint_x: .5 | |
text: | |
''' | |
<MyWidget@Widget>: | |
    Label: | |
        text: 'example' | |
''' | |
Screen: | |
name: 'Le language KV - 4 - Identifiants' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
''' | |
Utilisation d'id et ids pour référencer d'autres widgets | |
''' | |
BoxLayout: | |
CodeLabel: | |
text: | |
''' | |
BoxLayout: | |
    orientation: 'vertical' | |
    TextInput: | |
        id: ti | |
    Label: | |
        text: ti.text | |
''' | |
BoxLayout: | |
orientation: 'vertical' | |
TextInput: | |
id: ti_ | |
Label: | |
color: default_color | |
text: ti_.text | |
Spacer: | |
size_hint_y: None | |
height: 10 | |
BoxLayout: | |
CodeLabel: | |
text: | |
''' | |
<MyWidget@BoxLayout>: | |
    Button: | |
        id: btn | |
        text: 'push me' | |
 | |
BoxLayout: | |
    Label: | |
        text: '' | |
    MyWidget: | |
        id: box | |
''' | |
BoxLayout: | |
MyWidget: | |
id: box | |
Label: | |
color: default_color | |
text: '' | |
Screen: | |
name: 'Le language KV - 5 - directives' | |
GridLayout: | |
cols: 2 | |
spacing: 10 | |
CodeLabel: | |
code: | |
''' | |
—:import sin math.sin | |
—:import chain itertools.chain | |
Widget: | |
    canvas: | |
        Color: | |
            rgba: 0, 0, 0, 1 | |
        Line: | |
            points: | |
                list(chain(*zip( | |
                [self.x + x * self.width / 100. | |
                for x in range(100)], | |
                [self.center_y + sin(y/10.) * 100 | |
                for y in range(100)]))) | |
'''.replace('—', '#') | |
Widget: | |
canvas: | |
Color: | |
rgba: 0, 0, 0, 1 | |
Line: | |
points: | |
list(chain(*zip( | |
[self.x + x * self.width / 100. for x in range(100)], | |
[self.center_y + sin(y/10.) * 100 for y in range(100)]))) | |
CodeLabel: | |
code: | |
''' | |
—:set font_size 35 | |
—:set default_color (0, 0, 0, 1) | |
 | |
Label: | |
    font_size: font_size | |
    text: "hello world" | |
    color: default_color | |
'''.replace('—', '#') | |
size_hint_y: None | |
height: self.texture_size[1] | |
Label: | |
font_size: font_size | |
text: "hello world" | |
color: default_color | |
size_hint_y: None | |
height: self.texture_size[1] | |
CodeLabel: | |
code: | |
''' | |
—:include somefile.kv | |
 | |
SomeWidgetDefinedInSomeFile: | |
    text: "Hey" | |
'''.replace('—', '#') | |
size_hint_y: None | |
height: self.texture_size[1] | |
Label: | |
color: default_color | |
text: 'Hey' | |
size_hint_y: None | |
height: self.texture_size[1] | |
Screen: | |
name: 'Application' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
''' | |
Deux manière de lancer une application: | |
‣ runTouchApp | |
 | |
‣ App().run() | |
''' | |
BoxLayout: | |
spacing: 2 | |
CodeLabel: | |
code: | |
''' | |
from kivy.base import runTouchApp | |
from kivy.uix.label import Label | |
 | |
runTouchApp( | |
    Label( | |
        text='hello world')) | |
''' | |
CodeLabel: | |
code: | |
''' | |
from kivy.app import App | |
from kivy.uix.label import Label | |
 | |
class HelloWorld(App): | |
    def build(self): | |
        return Label( | |
            text='hello world') | |
 | |
HelloWorld().run() | |
''' | |
Screen: | |
name: 'Applications - 2 - avantages' | |
ContentLabel: | |
pos_hint: {'center': (.5, .5)} | |
text: | |
''' | |
‣ App offre de nombreuses fonctions utilitaires | |
   (on_pause, on_stop, on_resume, build_config, build_settings…) | |
 | |
‣ App charge le fichier kv associé à la | |
   classe (convention de nommage 'HelloWorldApp → | |
   helloworld.kv) dans la methode build par défaut, et le | |
   fichier de configuration (helloworld.ini) si existant. | |
 | |
‣ App est un EventDispatcher → peut servir de contrôleur | |
   principal (accessible depuis kv via le mot clé "app"). | |
''' | |
Screen: | |
name: 'Utilitaires' | |
ContentLabel: | |
pos_hint: {'center': (.5, .5)} | |
text: | |
''' | |
‣ Clock | |
   Permet de planifier des taches répétitives | |
   (schedule_interval) ou non (schedule_once) | |
‣ Animation | |
   Transitionne la valeur d'une NumericProperty ou | |
   ListProperty (contenant un nombre fixe de valeurs | |
   Numériques) d'une valeur à une autre, dans un temps donné, | |
   via une fonction de transition configurable. | |
‣ UrlRequest | |
   urllib wrapper pour simplifier le travail en arrière | |
   plan (event lors du succès/échec) | |
etc | |
''' | |
Screen: | |
name: 'Exemples: kivycatalog' | |
Screen: | |
name: 'Outils' | |
ContentLabel: | |
font_size: sp(25) | |
text: | |
''' | |
Kivy vient avec un certains nombre d'outils pour faciliter | |
le développement, les connaître peut vous faire gagner | |
beaucoup de temps. | |
‣ Modules: | |
Permettent de modifier le comportement d'une application kivy: | |
→ Inspector | |
→ Monitor | |
→ Recorder | |
→ Monitor | |
→ Screen | |
 | |
‣ Garden | |
Modules communautaires à importer directement dans votre | |
projet | |
→ garden.graph | |
→ garden.pi | |
→ garden.ddd | |
→ etc… | |
''' | |
Screen: | |
name: 'Exemples: garden' | |
Screen: | |
name: 'Questions ?' | |
Label: | |
id: question | |
text: '?' | |
font_size: 50 + abs(50 * sin(10)) | |
color: default_color | |
canvas.before: | |
PushMatrix | |
Rotate: | |
origin: self.center | |
angle: 10 * 50 | |
canvas.after: | |
PopMatrix | |
Screen: | |
name: 'Bonus: Nouveautés 1.9' | |
BoxLayout: | |
orientation: 'vertical' | |
ContentLabel: | |
text: | |
''' | |
‣ SDL2 provider (good bye pygame!) | |
‣ ffpyplayer video provider (ffmpeg) | |
‣ EffectWidget (shaders) | |
‣ Window's KeyboardHeight property (android) | |
‣ support SVG! | |
‣ Rebind in kv | |
‣ Tesselator | |
 | |
+ nombreuses corrections et ajouts mineurs. | |
''' | |
Spacer | |
SubTitle: | |
text: | |
'%s/%s - %s:%s' % ( | |
1 + sm.screen_names.index(sm.current) if sm.current else 0, | |
len(sm.screens), int(10 // 60), str(int(10 % | |
60)).zfill(2)) | |
font_size: sp(15) | |
<MyWidget@BoxLayout>: | |
Button: | |
id: btn | |
text: 'push me' |
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
# -*- coding: utf-8 -*- | |
# Compiled from G:\Python\dev2\pycon-fr-2014-kivy-master\pres.kv at 2015-05-27 01:58:34.799000 | |
__version__ = "1.9.1-dev" | |
__source_file__ = r"G:\Python\dev2\pycon-fr-2014-kivy-master\pres.kv" | |
__source_hash__ = b"e1d13263b33af3e09c4d119021375bdc4b5dddaa2a9a7fce5b6546f2c655f6b3" | |
import kivy.metrics as Metrics | |
from kivy.factory import Factory | |
from kivy.lang import ( | |
Builder, ParserSelectorName, _handlers, ProxyApp, delayed_call_fn) | |
from kivy import require | |
from functools import partial | |
from kivy.event import EventDispatcher, Observable | |
app = ProxyApp() | |
pt = Metrics.pt | |
inch = Metrics.inch | |
cm = Metrics.cm | |
mm = Metrics.mm | |
dp = Metrics.dp | |
sp = Metrics.sp | |
_mc = [None, ] * 8 | |
def rebind_callback(bound, i, instance, value): | |
# bound[i] and p cannot be None b/c it dispatched | |
s, e, pidx, p, key, _, _, _ = bound[i] | |
# we need to rebind all children of root (p.key). First check if the value | |
# actually changed - i.e. whether p.key is the same as `value`. p.key is | |
# the parent of p.key.x and is stored as the parent of the first child of | |
# p.key, so find the first child of p.key (p.key.x) and use its 1st child | |
# `s` is the first direct child of p.key (s, e) are all the (indirect) | |
# children | |
try: | |
if value == bound[s][3]: | |
return | |
except ReferenceError: | |
pass | |
# now, everything must have a non-None parent idx since p.key is the root | |
# also, since p.key was rebind, every node below it will have bound[node] | |
# not be None, even if it was not bound in case it would have rebind | |
# now unbind all the children, and along the way set each parent value | |
# to be the new parent in the p.key.x.y.z... tree. cache the values here. | |
# keys are the index of the parent | |
parent = {} | |
p = getattr(p, key) # next parent | |
if p is None or not isinstance(object, ('EventDispatcher', 'Observable')): | |
parent[i] = p, None, None, None, None | |
else: | |
parent[i] = p, p.proxy_ref, p.fast_bind, p.property, p.rebind_property | |
dispatch = [None, ] * (e - s) | |
for k, node in enumerate(range(s, e)): | |
node_s, node_e, pidx, p, key, bid, f, args = blist = bound[i] | |
# node_s/e being None means it's a leaf with no children | |
if bid: # unbind parent's rebind | |
try: | |
p.unbind_uid(key, bid) | |
except ReferenceError: | |
pass | |
p, pref, bind, prop_get, rebind_prop = parent[pidx] | |
# decide whether we can bind to this object | |
if bind is not None and node_s is None: # a leaf | |
blist[3] = pref | |
uid = blist[5] = bind(key, f, *args) | |
if uid: # it is a kivy prop | |
prop = prop_get(key) | |
dispatch[k] = ( | |
node, p, prop.dispatch_stale, prop.dispatch_count(p)) | |
continue | |
elif bind is not None and rebind_prop(key): # a rebind node | |
blist[3] = pref | |
blist[5] = bind(key, f, *args) | |
if uid: # it is a kivy prop | |
prop = prop_get(key) | |
dispatch[k] = ( | |
node, p, prop.dispatch_stale, prop.dispatch_count(p)) | |
else: # either no obj, or obj but no rebind and it's not a leaf | |
blist[3] = blist[5] = None | |
if node_s is None: | |
continue | |
# if the key is a leaf, don't save the key as a parent b/c it has no | |
# children, hence the continue above | |
if node not in parent: | |
if p is None: # our parent is already None | |
parent[node] = (None, None, None, None, None) | |
else: | |
p = getattr(p, key) # next parent | |
if p is None or not isinstance(object, (EventDispatcher, )): | |
parent[node] = p, None, None, None, None | |
else: | |
parent[node] = ( | |
p, p.proxy_ref, p.fast_bind, p.property, | |
p.rebind_property) | |
for item in dispatch: | |
if item is None: | |
continue | |
i, p, dispatch_stale, count = item | |
try: | |
if p == bound[i][3]: | |
dispatch_stale(p, count) | |
except ReferenceError: | |
pass | |
# directives | |
try: | |
import kivy.utils.get_color_from_hex as color | |
except ImportError: | |
from kivy.utils import get_color_from_hex as color | |
try: | |
import kivy.metrics.sp as sp | |
except ImportError: | |
from kivy.metrics import sp as sp | |
try: | |
import math.sin as sin | |
except ImportError: | |
from math import sin as sin | |
try: | |
import itertools.chain as chain | |
except ImportError: | |
from itertools import chain as chain | |
title_color = '009688' | |
title_underline = 'b2dfdb' | |
subtitle_color = '00bcd4' | |
subtitle_underline = 'b2ebf2' | |
default_color = (0, 0, 0, 1) | |
background_color = 'e0f7fa' | |
content_color = '000000' | |
font_size = 35 | |
def height_h0(root, *args): | |
root.height = root.texture_size[1] + sp(20) | |
def rgba_h1(g1, root, *args): | |
root = root.__self__ | |
g1.rgba = color(root.color1) if root.color1 else default_color | |
def size_h2(g2, root, *args): | |
g2.size = root.size | |
def pos_h3(g2, root, *args): | |
g2.pos = root.pos | |
def rgba_h4(g3, root, *args): | |
root = root.__self__ | |
g3.rgba = color(root.color2) if root.color2 else default_color | |
def pos_h5(g4, root, *args): | |
g4.pos = root.pos | |
def size_h6(g4, root, *args): | |
g4.size = root.width, sp(5) | |
# <Title@Label> L13 | |
_mc[0] = set() | |
def _r0(root, builder_created): | |
bfuncs = [] if builder_created is None else builder_created | |
cls_Color = Factory.Color | |
cls_Rectangle = Factory.Rectangle | |
root_canvas_before_add = root.canvas.before.add | |
g1 = cls_Color() | |
root_canvas_before_add(g1) | |
g2 = cls_Rectangle() | |
root_canvas_before_add(g2) | |
g3 = cls_Color() | |
root_canvas_before_add(g3) | |
g4 = cls_Rectangle() | |
root_canvas_before_add(g4) | |
if root.__class__ not in _mc[0]: | |
root_create_property = root.create_property | |
if not hasattr(root, "size_hint_y"): | |
root_create_property("size_hint_y", (None)) | |
if not hasattr(root, "height"): | |
root_create_property("height", (None)) | |
if not hasattr(root, "color1"): | |
root_create_property("color1", (None)) | |
if not hasattr(root, "color2"): | |
root_create_property("color2", (None)) | |
if not hasattr(root, "font_size"): | |
root_create_property("font_size", (None)) | |
_mc[0].add(root.__class__) | |
root.size_hint_y = None | |
root.color1 = title_color | |
root.color2 = title_underline | |
root.font_size = sp(25) | |
root.height = root.texture_size[1] + sp(20) | |
if builder_created is None: | |
bfuncs = [f() for f in bfuncs] | |
bfuncs.append(_b0(app, g1, g2, g3, g4, root)) | |
bfuncs = [f() for f in reversed(bfuncs)] | |
for children in reversed(bfuncs): | |
for child in children: | |
child.dispatch("on_kv_apply", root) | |
else: | |
bfuncs.append(partial(_b0, app, g1, g2, g3, g4, root)) | |
def _b0(app, g1, g2, g3, g4, root): | |
g2_ref = g2.proxy_ref | |
g4_ref = g4.proxy_ref | |
root_ref = root.proxy_ref | |
delayed_rgba_h1 = [rgba_h1, g1.proxy_ref, root_ref, None] | |
delayed_call_fn(delayed_rgba_h1, None, None) | |
delayed_size_h2 = [size_h2, g2_ref, root_ref, None] | |
delayed_call_fn(delayed_size_h2, None, None) | |
delayed_pos_h3 = [pos_h3, g2_ref, root_ref, None] | |
delayed_call_fn(delayed_pos_h3, None, None) | |
delayed_rgba_h4 = [rgba_h4, g3.proxy_ref, root_ref, None] | |
delayed_call_fn(delayed_rgba_h4, None, None) | |
delayed_pos_h5 = [pos_h5, g4_ref, root_ref, None] | |
delayed_call_fn(delayed_pos_h5, None, None) | |
delayed_size_h6 = [size_h6, g4_ref, root_ref, None] | |
delayed_call_fn(delayed_size_h6, None, None) | |
root_bound = bound = [None, ] * 7 | |
bind = root.fast_bind | |
bound[0] = [None, None, None, root_ref, "texture_size", bind("texture_size", height_h0, root_ref), height_h0, (root_ref, )] | |
bound[1] = [None, None, None, root_ref, "color1", bind("color1", delayed_call_fn, delayed_rgba_h1), delayed_call_fn, (delayed_rgba_h1, )] | |
bound[2] = [None, None, None, root_ref, "size", bind("size", delayed_call_fn, delayed_size_h2), delayed_call_fn, (delayed_size_h2, )] | |
bound[3] = [None, None, None, root_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h3), delayed_call_fn, (delayed_pos_h3, )] | |
bound[4] = [None, None, None, root_ref, "color2", bind("color2", delayed_call_fn, delayed_rgba_h4), delayed_call_fn, (delayed_rgba_h4, )] | |
bound[5] = [None, None, None, root_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h5), delayed_call_fn, (delayed_pos_h5, )] | |
bound[6] = [None, None, None, root_ref, "width", bind("width", delayed_call_fn, delayed_size_h6), delayed_call_fn, (delayed_size_h6, )] | |
_handlers[g3.uid].append((bound, (4, ))) | |
_handlers[g4.uid].append((bound, (5, 6))) | |
_handlers[root.uid].append((bound, (0, ))) | |
_handlers[g2.uid].append((bound, (2, 3))) | |
_handlers[g1.uid].append((bound, (1, ))) | |
return tuple | |
# <SubTitle@FloatLayout+Title> L31 | |
_mc[1] = set() | |
def _r1(root, builder_created): | |
if root.__class__ not in _mc[1]: | |
root_create_property = root.create_property | |
if not hasattr(root, "color1"): | |
root_create_property("color1", (None)) | |
if not hasattr(root, "color2"): | |
root_create_property("color2", (None)) | |
_mc[1].add(root.__class__) | |
root.color1 = subtitle_color | |
root.color2 = subtitle_underline | |
# <PresButton@ButtonBehavior+SubTitle> L35 | |
def _r2(root, builder_created): | |
pass | |
def size_h7(root, *args): | |
root.size = root.texture_size | |
# <ContentLabel@Label> L37 | |
_mc[3] = set() | |
def _r3(root, builder_created): | |
bfuncs = [] if builder_created is None else builder_created | |
if root.__class__ not in _mc[3]: | |
root_create_property = root.create_property | |
if not hasattr(root, "color"): | |
root_create_property("color", (None)) | |
if not hasattr(root, "font_size"): | |
root_create_property("font_size", (None)) | |
if not hasattr(root, "size"): | |
root_create_property("size", (None)) | |
if not hasattr(root, "size_hint_y"): | |
root_create_property("size_hint_y", (None)) | |
_mc[3].add(root.__class__) | |
root.color = color(content_color) | |
root.font_size = sp(24) | |
root.size_hint_y = None | |
root.size = root.texture_size | |
if builder_created is None: | |
bfuncs = [f() for f in bfuncs] | |
bfuncs.append(_b3(app, root)) | |
bfuncs = [f() for f in reversed(bfuncs)] | |
for children in reversed(bfuncs): | |
for child in children: | |
child.dispatch("on_kv_apply", root) | |
else: | |
bfuncs.append(partial(_b3, app, root)) | |
def _b3(app, root): | |
root_ref = root.proxy_ref | |
root_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, root_ref, "texture_size", root.fast_bind("texture_size", size_h7, root_ref), size_h7, (root_ref, )] | |
_handlers[root.uid].append((bound, (0, ))) | |
return tuple | |
def text_h8(root, *args): | |
root.text = root.code .replace('\t', 'Â ' * 4) | |
def size_h9(g2, root, *args): | |
g2.size = root.size | |
def pos_h10(g2, root, *args): | |
g2.pos = root.pos | |
# <CodeLabel@Label> L43 | |
_mc[4] = set() | |
def _r4(root, builder_created): | |
bfuncs = [] if builder_created is None else builder_created | |
root_canvas_before_add = root.canvas.before.add | |
g1 = Factory.Color() | |
root_canvas_before_add(g1) | |
g2 = Factory.Rectangle() | |
root_canvas_before_add(g2) | |
if root.__class__ not in _mc[4]: | |
root_create_property = root.create_property | |
if not hasattr(root, "code"): | |
root_create_property("code", ('')) | |
if not hasattr(root, "text"): | |
root_create_property("text", (None)) | |
if not hasattr(root, "font_size"): | |
root_create_property("font_size", (None)) | |
_mc[4].add(root.__class__) | |
root.code = '' | |
root.font_size = sp(20) | |
g1.rgba = 0, 0, 0, 1 | |
root.text = root.code .replace('\t', 'Â ' * 4) | |
if builder_created is None: | |
bfuncs = [f() for f in bfuncs] | |
bfuncs.append(_b4(app, g1, g2, root)) | |
bfuncs = [f() for f in reversed(bfuncs)] | |
for children in reversed(bfuncs): | |
for child in children: | |
child.dispatch("on_kv_apply", root) | |
else: | |
bfuncs.append(partial(_b4, app, g1, g2, root)) | |
def _b4(app, g1, g2, root): | |
g2_ref = g2.proxy_ref | |
root_ref = root.proxy_ref | |
delayed_size_h9 = [size_h9, g2_ref, root_ref, None] | |
delayed_call_fn(delayed_size_h9, None, None) | |
delayed_pos_h10 = [pos_h10, g2_ref, root_ref, None] | |
delayed_call_fn(delayed_pos_h10, None, None) | |
root_bound = bound = [None, ] * 3 | |
bind = root.fast_bind | |
bound[0] = [None, None, None, root_ref, "code", bind("code", text_h8, root_ref), text_h8, (root_ref, )] | |
bound[1] = [None, None, None, root_ref, "size", bind("size", delayed_call_fn, delayed_size_h9), delayed_call_fn, (delayed_size_h9, )] | |
bound[2] = [None, None, None, root_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h10), delayed_call_fn, (delayed_pos_h10, )] | |
_handlers[root.uid].append((bound, (0, ))) | |
_handlers[g2.uid].append((bound, (1, 2))) | |
return tuple | |
# <Spacer@Widget> L55 | |
def _r5(root, builder_created): | |
pass | |
def text_h11(w2, w5_sm, *args): | |
w2.text = w5_sm.current | |
def width_h12(w3, *args): | |
w3.width = w3.height | |
def width_h13(w4, *args): | |
w4.width = w4.height | |
def height_h14(w12_logo_container, w14_logo, *args): | |
w12_logo_container.height = w14_logo.texture_size[1] * 2 | |
def size_h15(w13, w14_logo, *args): | |
w13.size = w14_logo.size | |
def center_h16(w12_logo_container, w13, *args): | |
w13.center = w12_logo_container.center | |
def size_h17(w14_logo, *args): | |
w14_logo.size = w14_logo.texture_size | |
def height_h18(w18, *args): | |
w18.height = w18.minimum_height | |
def text_size_h19(w19, *args): | |
w19.text_size = w19.width, None | |
def text_size_h20(w20, *args): | |
w20.text_size = w20.width, None | |
def size_h21(g28, w26, *args): | |
g28.size = w26.size | |
def pos_h22(g28, w26, *args): | |
g28.pos = w26.pos | |
def pos_h23(g30, w26, *args): | |
g30.pos = w26.pos | |
def size_h24(g30, w26, *args): | |
g30.size = w26.size | |
def text_size_h25(w34, *args): | |
w34.text_size = w34.width, None | |
def height_h26(w41, *args): | |
w41.height = w41.texture_size[1] | |
def rgba_h27(g45, w44, *args): | |
g45.rgba = (.5, .5, 0, 1) if w44.active else (1, 1, 1, 1) | |
def pos_h28(g46, w44, *args): | |
g46.pos = w44.pos | |
def size_h29(g46, w44, *args): | |
g46.size = w44.size | |
def width_h30(w68, *args): | |
w68.width = w68.texture_size[0] * 2 | |
def text_size_h31(w80, *args): | |
w80.text_size = w80.size | |
def text_size_h32(w82, *args): | |
w82.text_size = w82.size | |
def text_size_h33(w84, *args): | |
w84.text_size = w84.size | |
def text_h34(w92_ti_, w93, *args): | |
w93.text = w92_ti_.text | |
def points_h35(g105, w103, *args): | |
w103 = w103.__self__ | |
g105.points = list(chain(*zip( | |
[w103.x + x * w103.width / 100. for x in range(100)], | |
[w103.center_y + sin(y/10.) * 100 for y in range(100)]))) | |
def height_h36(w106, *args): | |
w106.height = w106.texture_size[1] | |
def height_h37(w107, *args): | |
w107.height = w107.texture_size[1] | |
def height_h38(w108, *args): | |
w108.height = w108.texture_size[1] | |
def height_h39(w109, *args): | |
w109.height = w109.texture_size[1] | |
def origin_h40(g127, w125_question, *args): | |
g127.origin = w125_question.center | |
def text_h41(w133, w5_sm, *args): | |
w5_sm = w5_sm.__self__ | |
w133.text = '%s/%s - %s:%s' % ( | |
1 + w5_sm.screen_names.index(w5_sm.current) if w5_sm.current else 0, | |
len(w5_sm.screens), int(10 // 60), str(int(10 % | |
60)).zfill(2)) | |
def pos_h42(g135, root, *args): | |
g135.pos = root.pos | |
def size_h43(g135, root, *args): | |
g135.size = root.size | |
def on_on_press_h0(w5_sm, *args): | |
w5_sm = w5_sm.__self__ | |
w5_sm.transition.direction = 'right' | |
w5_sm.current = w5_sm.previous() | |
def on_on_press_h1(w5_sm, *args): | |
w5_sm = w5_sm.__self__ | |
w5_sm.transition.direction = 'left' | |
w5_sm.current = w5_sm.next() | |
def on_on_touch_down_h2(w34, *args): | |
w34.text += '\n%s' % (','.join(str(x) for x in args)) | |
def on_on_touch_down_h3(w44, *args): | |
w44 = w44.__self__ | |
if w44.collide_point(*args[1].pos): w44.active = not w44.active | |
# <RootRule@BoxLayout> L57 | |
_mc[6] = set() | |
def _r6(root, builder_created): | |
bfuncs = [] if builder_created is None else builder_created | |
cls_SubTitle = Factory.SubTitle | |
cls_PresButton = Factory.PresButton | |
cls_Screen = Factory.Screen | |
cls_BoxLayout = Factory.BoxLayout | |
cls_ContentLabel = Factory.ContentLabel | |
cls_Spacer = Factory.Spacer | |
cls_FloatLayout = Factory.FloatLayout | |
cls_GridLayout = Factory.GridLayout | |
cls_CodeLabel = Factory.CodeLabel | |
cls_Widget = Factory.Widget | |
cls_Color = Factory.Color | |
cls_Rectangle = Factory.Rectangle | |
cls_Button = Factory.Button | |
cls_Label = Factory.Label | |
root_canvas_before_add = root.canvas.before.add | |
w1 = Factory.Title(parent=root, __builder_created=bfuncs) | |
w2 = cls_SubTitle(parent=root, __builder_created=bfuncs) | |
w3 = cls_PresButton(parent=w2, __builder_created=bfuncs) | |
w4 = cls_PresButton(parent=w2, __builder_created=bfuncs) | |
w5_sm = Factory.ScreenManager(parent=root, __builder_created=bfuncs) | |
w6 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w7 = cls_BoxLayout(parent=w6, __builder_created=bfuncs) | |
w8 = cls_ContentLabel(parent=w7, __builder_created=bfuncs) | |
w9 = cls_Spacer(parent=w7, __builder_created=bfuncs) | |
w10 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w11 = cls_BoxLayout(parent=w10, __builder_created=bfuncs) | |
w12_logo_container = cls_FloatLayout(parent=w11, __builder_created=bfuncs) | |
w13 = Factory.Scatter(parent=w12_logo_container, __builder_created=bfuncs) | |
w14_logo = Factory.Image(parent=w13, __builder_created=bfuncs) | |
w15 = cls_ContentLabel(parent=w11, __builder_created=bfuncs) | |
w16 = cls_Spacer(parent=w11, __builder_created=bfuncs) | |
w17 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w18 = cls_GridLayout(parent=w17, __builder_created=bfuncs) | |
w19 = cls_ContentLabel(parent=w18, __builder_created=bfuncs) | |
w20 = cls_ContentLabel(parent=w18, __builder_created=bfuncs) | |
w21 = cls_Spacer(parent=w18, __builder_created=bfuncs) | |
w22 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w23 = cls_BoxLayout(parent=w22, __builder_created=bfuncs) | |
w24 = cls_BoxLayout(parent=w23, __builder_created=bfuncs) | |
w25 = cls_CodeLabel(parent=w24, __builder_created=bfuncs) | |
w26 = cls_Widget(parent=w24, __builder_created=bfuncs) | |
w26_canvas_root_add = w26.canvas.add | |
g27 = cls_Color() | |
w26_canvas_root_add(g27) | |
g28 = cls_Rectangle() | |
w26_canvas_root_add(g28) | |
g29 = cls_Color() | |
w26_canvas_root_add(g29) | |
g30 = Factory.Ellipse() | |
w26_canvas_root_add(g30) | |
w31 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w32 = cls_BoxLayout(parent=w31, __builder_created=bfuncs) | |
w33 = cls_CodeLabel(parent=w32, __builder_created=bfuncs) | |
w34 = cls_ContentLabel(parent=w32, __builder_created=bfuncs) | |
w35 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w36 = cls_BoxLayout(parent=w35, __builder_created=bfuncs) | |
w37 = cls_ContentLabel(parent=w36, __builder_created=bfuncs) | |
w38 = cls_CodeLabel(parent=w36, __builder_created=bfuncs) | |
w39 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w40 = cls_BoxLayout(parent=w39, __builder_created=bfuncs) | |
w41 = cls_ContentLabel(parent=w40, __builder_created=bfuncs) | |
w42 = cls_BoxLayout(parent=w40, __builder_created=bfuncs) | |
w43 = cls_CodeLabel(parent=w42, __builder_created=bfuncs) | |
w44 = cls_Widget(parent=w42, __builder_created=bfuncs) | |
w44_canvas_root_add = w44.canvas.add | |
g45 = cls_Color() | |
w44_canvas_root_add(g45) | |
g46 = cls_Rectangle() | |
w44_canvas_root_add(g46) | |
w47 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w48 = cls_BoxLayout(parent=w47, __builder_created=bfuncs) | |
w49 = cls_ContentLabel(parent=w48, __builder_created=bfuncs) | |
w50 = cls_Spacer(parent=w48, __builder_created=bfuncs) | |
w51 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w52 = cls_BoxLayout(parent=w51, __builder_created=bfuncs) | |
w53 = cls_ContentLabel(parent=w52, __builder_created=bfuncs) | |
w54 = cls_BoxLayout(parent=w52, __builder_created=bfuncs) | |
w55 = cls_CodeLabel(parent=w54, __builder_created=bfuncs) | |
w56 = cls_FloatLayout(parent=w54, __builder_created=bfuncs) | |
w57 = cls_Button(parent=w56, __builder_created=bfuncs) | |
w58 = cls_ContentLabel(parent=w52, __builder_created=bfuncs) | |
w59 = cls_BoxLayout(parent=w52, __builder_created=bfuncs) | |
w60 = cls_CodeLabel(parent=w59, __builder_created=bfuncs) | |
w61 = cls_FloatLayout(parent=w59, __builder_created=bfuncs) | |
w62 = cls_Button(parent=w61, __builder_created=bfuncs) | |
w63 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w64 = cls_BoxLayout(parent=w63, __builder_created=bfuncs) | |
w65 = cls_ContentLabel(parent=w64, __builder_created=bfuncs) | |
w66 = cls_BoxLayout(parent=w64, __builder_created=bfuncs) | |
w67 = cls_CodeLabel(parent=w66, __builder_created=bfuncs) | |
w68 = cls_ContentLabel(parent=w66, __builder_created=bfuncs) | |
w69 = cls_CodeLabel(parent=w66, __builder_created=bfuncs) | |
w70 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w71 = cls_GridLayout(parent=w70, __builder_created=bfuncs) | |
w72 = cls_ContentLabel(parent=w71, __builder_created=bfuncs) | |
w73 = cls_CodeLabel(parent=w71, __builder_created=bfuncs) | |
w74 = cls_Spacer(parent=w71, __builder_created=bfuncs) | |
w75 = cls_Spacer(parent=w71, __builder_created=bfuncs) | |
w76 = cls_ContentLabel(parent=w71, __builder_created=bfuncs) | |
w77 = cls_CodeLabel(parent=w71, __builder_created=bfuncs) | |
w78 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w79 = cls_GridLayout(parent=w78, __builder_created=bfuncs) | |
w80 = cls_ContentLabel(parent=w79, __builder_created=bfuncs) | |
w81 = cls_CodeLabel(parent=w79, __builder_created=bfuncs) | |
w82 = cls_ContentLabel(parent=w79, __builder_created=bfuncs) | |
w83 = cls_CodeLabel(parent=w79, __builder_created=bfuncs) | |
w84 = cls_ContentLabel(parent=w79, __builder_created=bfuncs) | |
w85 = cls_CodeLabel(parent=w79, __builder_created=bfuncs) | |
w86 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w87 = cls_BoxLayout(parent=w86, __builder_created=bfuncs) | |
w88 = cls_ContentLabel(parent=w87, __builder_created=bfuncs) | |
w89 = cls_BoxLayout(parent=w87, __builder_created=bfuncs) | |
w90 = cls_CodeLabel(parent=w89, __builder_created=bfuncs) | |
w91 = cls_BoxLayout(parent=w89, __builder_created=bfuncs) | |
w92_ti_ = Factory.TextInput(parent=w91, __builder_created=bfuncs) | |
w93 = cls_Label(parent=w91, __builder_created=bfuncs) | |
w94 = cls_Spacer(parent=w87, __builder_created=bfuncs) | |
w95 = cls_BoxLayout(parent=w87, __builder_created=bfuncs) | |
w96 = cls_CodeLabel(parent=w95, __builder_created=bfuncs) | |
w97 = cls_BoxLayout(parent=w95, __builder_created=bfuncs) | |
w98_box = Factory.MyWidget(parent=w97, __builder_created=bfuncs) | |
w99 = cls_Label(parent=w97, __builder_created=bfuncs) | |
w100 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w101 = cls_GridLayout(parent=w100, __builder_created=bfuncs) | |
w102 = cls_CodeLabel(parent=w101, __builder_created=bfuncs) | |
w103 = cls_Widget(parent=w101, __builder_created=bfuncs) | |
w103_canvas_root_add = w103.canvas.add | |
g104 = cls_Color() | |
w103_canvas_root_add(g104) | |
g105 = Factory.Line() | |
w103_canvas_root_add(g105) | |
w106 = cls_CodeLabel(parent=w101, __builder_created=bfuncs) | |
w107 = cls_Label(parent=w101, __builder_created=bfuncs) | |
w108 = cls_CodeLabel(parent=w101, __builder_created=bfuncs) | |
w109 = cls_Label(parent=w101, __builder_created=bfuncs) | |
w110 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w111 = cls_BoxLayout(parent=w110, __builder_created=bfuncs) | |
w112 = cls_ContentLabel(parent=w111, __builder_created=bfuncs) | |
w113 = cls_BoxLayout(parent=w111, __builder_created=bfuncs) | |
w114 = cls_CodeLabel(parent=w113, __builder_created=bfuncs) | |
w115 = cls_CodeLabel(parent=w113, __builder_created=bfuncs) | |
w116 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w117 = cls_ContentLabel(parent=w116, __builder_created=bfuncs) | |
w118 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w119 = cls_ContentLabel(parent=w118, __builder_created=bfuncs) | |
w120 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w121 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w122 = cls_ContentLabel(parent=w121, __builder_created=bfuncs) | |
w123 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w124 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w125_question = cls_Label(parent=w124, __builder_created=bfuncs) | |
w125_question_canvas_before_add = w125_question.canvas.before.add | |
g126 = Factory.PushMatrix() | |
w125_question_canvas_before_add(g126) | |
g127 = Factory.Rotate() | |
w125_question_canvas_before_add(g127) | |
g128 = Factory.PopMatrix() | |
w125_question.canvas.after.add(g128) | |
w129 = cls_Screen(parent=w5_sm, __builder_created=bfuncs) | |
w130 = cls_BoxLayout(parent=w129, __builder_created=bfuncs) | |
w131 = cls_ContentLabel(parent=w130, __builder_created=bfuncs) | |
w132 = cls_Spacer(parent=w130, __builder_created=bfuncs) | |
w133 = cls_SubTitle(parent=root, __builder_created=bfuncs) | |
g134 = cls_Color() | |
root_canvas_before_add(g134) | |
g135 = cls_Rectangle() | |
root_canvas_before_add(g135) | |
if root.__class__ not in _mc[6]: | |
if not hasattr(root, "orientation"): | |
root.create_property("orientation", ('vertical')) | |
if not hasattr(w1, "text"): | |
w1.create_property("text", ('Présentation Kivy - PyCon FR - 26/10/2014')) | |
if not hasattr(w2, "text"): | |
w2.create_property("text", (None)) | |
w3_create_property = w3.create_property | |
if not hasattr(w3, "pos_hint"): | |
w3_create_property("pos_hint", ({'center_y': .5, 'x': 0})) | |
if not hasattr(w3, "size_hint_x"): | |
w3_create_property("size_hint_x", (None)) | |
if not hasattr(w3, "width"): | |
w3_create_property("width", (None)) | |
if not hasattr(w3, "text"): | |
w3_create_property("text", ('�')) | |
w4_create_property = w4.create_property | |
if not hasattr(w4, "pos_hint"): | |
w4_create_property("pos_hint", ({'center_y': .5, 'right': 1})) | |
if not hasattr(w4, "size_hint_x"): | |
w4_create_property("size_hint_x", (None)) | |
if not hasattr(w4, "width"): | |
w4_create_property("width", (None)) | |
if not hasattr(w4, "text"): | |
w4_create_property("text", ('→')) | |
if not hasattr(w6, "name"): | |
w6.create_property("name", ('Présentation')) | |
if not hasattr(w7, "orientation"): | |
w7.create_property("orientation", ('vertical')) | |
if not hasattr(w8, "text"): | |
w8.create_property("text", ('''Gabriel Pettier | |
Développeur python | |
Contributeur puis Core-Développeur Kivy depuis 2010 | |
 | |
http://tshirtman.fr | |
http://github.com/tshirtman | |
http://twitter.com/tshirtman | |
 | |
http://tangibledisplay.com | |
Développement d'interactions tangibles | |
''')) | |
if not hasattr(w10, "name"): | |
w10.create_property("name", ('Kivy')) | |
if not hasattr(w11, "orientation"): | |
w11.create_property("orientation", ('vertical')) | |
w12_logo_container_create_property = w12_logo_container.create_property | |
if not hasattr(w12_logo_container, "size_hint_y"): | |
w12_logo_container_create_property("size_hint_y", (None)) | |
if not hasattr(w12_logo_container, "height"): | |
w12_logo_container_create_property("height", (None)) | |
w13_create_property = w13.create_property | |
if not hasattr(w13, "size_hint"): | |
w13_create_property("size_hint", (None)) | |
if not hasattr(w13, "size"): | |
w13_create_property("size", (None)) | |
if not hasattr(w13, "center"): | |
w13_create_property("center", (None)) | |
w14_logo_create_property = w14_logo.create_property | |
if not hasattr(w14_logo, "size"): | |
w14_logo_create_property("size", (None)) | |
if not hasattr(w14_logo, "source"): | |
w14_logo_create_property("source", ('data/logo/kivy-icon-256.png')) | |
if not hasattr(w15, "text"): | |
w15.create_property("text", ('''Bibliothèque de Widgets orientés multitouch | |
‣ Développé majoritairement en pur Python, le reste en | |
Cython pour les performances. | |
‣ Multiplatforme: Windows, OSX, Linux, Android et IOS | |
supportés. | |
‣ API graphique directement basée sur OpenGL ES 2.0. | |
‣ Projet Libre et collaboratif, licence MIT. | |
''')) | |
if not hasattr(w17, "name"): | |
w17.create_property("name", ('Concepts')) | |
w18_create_property = w18.create_property | |
if not hasattr(w18, "size_hint"): | |
w18_create_property("size_hint", (.5, 1)) | |
if not hasattr(w18, "pos_hint"): | |
w18_create_property("pos_hint", ({'center': (.5, .5)})) | |
if not hasattr(w18, "cols"): | |
w18_create_property("cols", (1)) | |
if not hasattr(w18, "height"): | |
w18_create_property("height", (None)) | |
w19_create_property = w19.create_property | |
if not hasattr(w19, "text_size"): | |
w19_create_property("text_size", (None)) | |
if not hasattr(w19, "text"): | |
w19_create_property("text", (""" | |
‣ Instruction | |
→ Permet d'indiquer un ordre au GPU | |
""")) | |
w20_create_property = w20.create_property | |
if not hasattr(w20, "text_size"): | |
w20_create_property("text_size", (None)) | |
if not hasattr(w20, "text"): | |
w20_create_property("text", (""" | |
‣ Évènement | |
→ Propage une information à tous les acteurs concernés | |
""")) | |
if not hasattr(w22, "name"): | |
w22.create_property("name", ('Instruction exemple')) | |
if not hasattr(w23, "orientation"): | |
w23.create_property("orientation", ('vertical')) | |
if not hasattr(w25, "code"): | |
w25.create_property("code", (''' | |
with widget.canvas: | |
\tColor(1, 0, 0, 1, mode='rgba') | |
\tRectangle(pos=widget.pos, size=widget.size) | |
\tColor(.5, .5, .5, 1, mode='rgba') | |
\tEllipse(pos=widget.pos, size=widget.size) | |
''')) | |
if not hasattr(w31, "name"): | |
w31.create_property("name", ('Évènement')) | |
if not hasattr(w33, "code"): | |
w33.create_property("code", (''' | |
def function(*args): | |
\tprint(args) | |
 | |
widget.bind(on_touch_down=function) | |
''')) | |
w34_create_property = w34.create_property | |
if not hasattr(w34, "text"): | |
w34_create_property("text", ('touch me\n')) | |
if not hasattr(w34, "font_size"): | |
w34_create_property("font_size", (15)) | |
if not hasattr(w34, "text_size"): | |
w34_create_property("text_size", (None)) | |
if not hasattr(w35, "name"): | |
w35.create_property("name", ('Properties')) | |
if not hasattr(w36, "orientation"): | |
w36.create_property("orientation", ('vertical')) | |
if not hasattr(w37, "text"): | |
w37.create_property("text", ('''Permet de lier les attributs des objets à des | |
évènements. | |
‣ StringProperty | |
‣ NumericProperty | |
‣ ObjectProperty | |
‣ AliasProperty | |
‣ etc… | |
Doit être déclaré sur des sous-classes d'EventDispatcher, | |
qui implémentent le pattern "Observer". Ainsi, il est | |
possible à l'objet de réaliser des actions quand ses | |
propriétés changent de valeur. | |
''')) | |
if not hasattr(w38, "code"): | |
w38.create_property("code", (''' | |
class ClassWithProperties(EventDispatcher): | |
\tname = StringProperty('') | |
\tcount = NumericProperty(0) | |
 | |
def on_name(self, value): | |
\tprint "my name changed to %s" % value | |
''')) | |
if not hasattr(w39, "name"): | |
w39.create_property("name", ('Widgets')) | |
if not hasattr(w40, "orientation"): | |
w40.create_property("orientation", ('vertical')) | |
w41_create_property = w41.create_property | |
if not hasattr(w41, "text"): | |
w41_create_property("text", (''' | |
‣ Hérite d'EventDispatcher | |
‣ Contient un Canvas (groupe d'instructions). | |
Propose un certain nombre d'évènements par défaut, | |
notamment: | |
‣ on_touch_down | |
‣ on_touch_move | |
‣ on_touch_up | |
''')) | |
if not hasattr(w41, "size_hint_y"): | |
w41_create_property("size_hint_y", (None)) | |
if not hasattr(w41, "height"): | |
w41_create_property("height", (None)) | |
w43_create_property = w43.create_property | |
if not hasattr(w43, "font_size"): | |
w43_create_property("font_size", (None)) | |
if not hasattr(w43, "text"): | |
w43_create_property("text", (''' | |
class MyWidget(Widget): | |
   active = BooleanProperty(False) | |
 | |
    def __init__(self, **kwargs): | |
        super(MyWidget, self).__init__(**kwargs) | |
        self.bind(on_pos=self.update, on_size=self.update) | |
        with self.canvas: | |
            self.color = Color(1, 1, 1, 1, mode='rgba') | |
            self.rectangle = Rectangle(pos=self.pos, size=self.size) | |
 | |
    def on_active(self, active): | |
        if self.active: | |
            self.color.rgba = (.5, .5, 0, 1) | |
        else: | |
            self.coler.rgba = (1, 1, 1, 1) | |
 | |
    def update(self, *args): | |
        self.rect.pos = self.pos | |
        self.rect.size = self.size | |
 | |
    def on_touch_down(self, touch): | |
        if self.collide_point(*touch.pos): | |
            self.active = not self.active | |
''')) | |
if not hasattr(w44, "active"): | |
w44.create_property("active", (None)) | |
if not hasattr(w47, "name"): | |
w47.create_property("name", ('Layouts')) | |
if not hasattr(w48, "orientation"): | |
w48.create_property("orientation", ('vertical')) | |
if not hasattr(w49, "text"): | |
w49.create_property("text", (''' | |
Les Widgets sont par défaut complètement libres de leur | |
placement et de leur tailles, qui sont absolues (origine | |
bas-gauche de l'écran). | |
 | |
Certains widgets sont spécialisés dans le placement et le | |
dimensionnement de leurs sous widgets (enfants). | |
 | |
‣ FloatLayout | |
‣ BoxLayout | |
‣ AnchorLayout | |
‣ GridLayout | |
‣ StackLayout | |
‣ etc… | |
''')) | |
if not hasattr(w51, "name"): | |
w51.create_property("name", ('Layouts - 2 - Hints')) | |
if not hasattr(w52, "orientation"): | |
w52.create_property("orientation", ('vertical')) | |
if not hasattr(w53, "text"): | |
w53.create_property("text", (''' | |
La taille/position des widgets enfants d'un Layout est | |
généralement contrôlée via les propriétés size_hint et | |
pos_hint, qui sont relative au Layout. | |
''')) | |
if not hasattr(w55, "text"): | |
w55.create_property("text", (''' | |
f = FloatLayout() | |
f.add_widget( | |
    Button( | |
        size_hint=(.2, .1), | |
        pos_hint={'center': (.5, .5)}) | |
''')) | |
w57_create_property = w57.create_property | |
if not hasattr(w57, "size_hint"): | |
w57_create_property("size_hint", (.2, .1)) | |
if not hasattr(w57, "pos_hint"): | |
w57_create_property("pos_hint", ({'center': (.5, .5)})) | |
if not hasattr(w57, "text"): | |
w57_create_property("text", ('a button')) | |
if not hasattr(w58, "text"): | |
w58.create_property("text", (''' | |
La taille peut être définie arbitrairement en | |
désactivant size_hint dans les directions souhaités: | |
''')) | |
if not hasattr(w60, "text"): | |
w60.create_property("text", (''' | |
f = FloatLayout() | |
f.add_widget( | |
    Button( | |
        size_hint_x=None, | |
        pos_hint={'center': (.5, .5)}, | |
        size_hint_y=.1, | |
        width=250, | |
        text='another button')) | |
''')) | |
w62_create_property = w62.create_property | |
if not hasattr(w62, "size_hint_x"): | |
w62_create_property("size_hint_x", (None)) | |
if not hasattr(w62, "pos_hint"): | |
w62_create_property("pos_hint", ({'center': (.5, .5)})) | |
if not hasattr(w62, "size_hint_y"): | |
w62_create_property("size_hint_y", (.1)) | |
if not hasattr(w62, "width"): | |
w62_create_property("width", (250)) | |
if not hasattr(w62, "text"): | |
w62_create_property("text", ('another button')) | |
if not hasattr(w63, "name"): | |
w63.create_property("name", ('Le language KV')) | |
if not hasattr(w64, "orientation"): | |
w64.create_property("orientation", ('vertical')) | |
w65_create_property = w65.create_property | |
if not hasattr(w65, "font_size"): | |
w65_create_property("font_size", (None)) | |
if not hasattr(w65, "text"): | |
w65_create_property("text", (''' | |
Python: | |
‣ super pour la logique | |
‣ moins pour la déclaration d'arbres de widgets. | |
Kv: | |
‣ Syntaxe déclarative | |
‣ Détection des dépendances et créations de | |
   branchements automatiques | |
''')) | |
if not hasattr(w67, "text"): | |
w67.create_property("text", (''' | |
w = Widget() | |
with w.canvas: | |
    Color(1, 0, 1, 1, mode='rgba') | |
    rect = Rectangle(pos=w.pos, size=w.size) | |
 | |
def update(self, *args): | |
    rect.pos = w.pos | |
    rect.size = w.size | |
 | |
w.bind(pos=update, size=update) | |
''')) | |
w68_create_property = w68.create_property | |
if not hasattr(w68, "text"): | |
w68_create_property("text", ('vs')) | |
if not hasattr(w68, "size_hint_x"): | |
w68_create_property("size_hint_x", (None)) | |
if not hasattr(w68, "width"): | |
w68_create_property("width", (None)) | |
if not hasattr(w68, "pos_hint"): | |
w68_create_property("pos_hint", ({'center_y': .5})) | |
if not hasattr(w69, "text"): | |
w69.create_property("text", (''' | |
from kivy.lang import Builder | |
 | |
KV = """ | |
Widget: | |
    canvas: | |
        Color: | |
            rgba: 1, 0, 1, 1 | |
        Rectangle: | |
            pos: self.pos | |
            size: self.size | |
""" | |
 | |
Builder.load_string(KV) | |
''')) | |
if not hasattr(w70, "name"): | |
w70.create_property("name", ('Le language KV - 2 - Bindings')) | |
if not hasattr(w71, "cols"): | |
w71.create_property("cols", (2)) | |
if not hasattr(w72, "text"): | |
w72.create_property("text", (''' | |
1. Callback: | |
''')) | |
if not hasattr(w73, "text"): | |
w73.create_property("text", (''' | |
Widget: | |
    on_pos: | |
        print('my pos is %s' % self.pos) | |
Button: | |
    on_press: | |
        print("I've been pressed") | |
''')) | |
if not hasattr(w76, "text"): | |
w76.create_property("text", (''' | |
2. Dépendance: | |
''')) | |
if not hasattr(w77, "text"): | |
w77.create_property("text", (''' | |
Widget: | |
    canvas.before: | |
        Rectangle: | |
            pos: self.pos | |
            size: self.size | |
''')) | |
if not hasattr(w78, "name"): | |
w78.create_property("name", ('Le language KV - 3 - règles')) | |
w79_create_property = w79.create_property | |
if not hasattr(w79, "pos_hint"): | |
w79_create_property("pos_hint", ({'center': (.5, .5)})) | |
if not hasattr(w79, "cols"): | |
w79_create_property("cols", (2)) | |
if not hasattr(w79, "spacing"): | |
w79_create_property("spacing", (10)) | |
w80_create_property = w80.create_property | |
if not hasattr(w80, "text"): | |
w80_create_property("text", (''' | |
‣ root rule: Ce qui sera retourné par le loader | |
 une seule autorisée par chaine/fichier. | |
''')) | |
if not hasattr(w80, "text_size"): | |
w80_create_property("text_size", (None)) | |
w81_create_property = w81.create_property | |
if not hasattr(w81, "size_hint_x"): | |
w81_create_property("size_hint_x", (.5)) | |
if not hasattr(w81, "text"): | |
w81_create_property("text", (''' | |
MyWidget: | |
    Label: | |
        text: 'example' | |
''')) | |
w82_create_property = w82.create_property | |
if not hasattr(w82, "text"): | |
w82_create_property("text", (''' | |
‣ règle de classe: permet de configurer le style et le | |
   contenus de toutes les instances d'une classe. | |
''')) | |
if not hasattr(w82, "text_size"): | |
w82_create_property("text_size", (None)) | |
w83_create_property = w83.create_property | |
if not hasattr(w83, "size_hint_x"): | |
w83_create_property("size_hint_x", (.5)) | |
if not hasattr(w83, "text"): | |
w83_create_property("text", (''' | |
<Widget>: | |
    Label: | |
        text: 'example' | |
''')) | |
w84_create_property = w84.create_property | |
if not hasattr(w84, "text"): | |
w84_create_property("text", (''' | |
‣ Classes dynamiques: permet de créer une classe en KV, | |
   en déclarant l'héritage avec '@'. | |
''')) | |
if not hasattr(w84, "text_size"): | |
w84_create_property("text_size", (None)) | |
w85_create_property = w85.create_property | |
if not hasattr(w85, "size_hint_x"): | |
w85_create_property("size_hint_x", (.5)) | |
if not hasattr(w85, "text"): | |
w85_create_property("text", (''' | |
<MyWidget@Widget>: | |
    Label: | |
        text: 'example' | |
''')) | |
if not hasattr(w86, "name"): | |
w86.create_property("name", ('Le language KV - 4 - Identifiants')) | |
if not hasattr(w87, "orientation"): | |
w87.create_property("orientation", ('vertical')) | |
if not hasattr(w88, "text"): | |
w88.create_property("text", (''' | |
Utilisation d'id et ids pour référencer d'autres widgets | |
''')) | |
if not hasattr(w90, "text"): | |
w90.create_property("text", (''' | |
BoxLayout: | |
    orientation: 'vertical' | |
    TextInput: | |
        id: ti | |
    Label: | |
        text: ti.text | |
''')) | |
if not hasattr(w91, "orientation"): | |
w91.create_property("orientation", ('vertical')) | |
w93_create_property = w93.create_property | |
if not hasattr(w93, "color"): | |
w93_create_property("color", (None)) | |
if not hasattr(w93, "text"): | |
w93_create_property("text", (None)) | |
w94_create_property = w94.create_property | |
if not hasattr(w94, "size_hint_y"): | |
w94_create_property("size_hint_y", (None)) | |
if not hasattr(w94, "height"): | |
w94_create_property("height", (10)) | |
if not hasattr(w96, "text"): | |
w96.create_property("text", (''' | |
<MyWidget@BoxLayout>: | |
    Button: | |
        id: btn | |
        text: 'push me' | |
 | |
BoxLayout: | |
    Label: | |
        text: '' | |
    MyWidget: | |
        id: box | |
''')) | |
w99_create_property = w99.create_property | |
if not hasattr(w99, "color"): | |
w99_create_property("color", (None)) | |
if not hasattr(w99, "text"): | |
w99_create_property("text", ('')) | |
if not hasattr(w100, "name"): | |
w100.create_property("name", ('Le language KV - 5 - directives')) | |
w101_create_property = w101.create_property | |
if not hasattr(w101, "cols"): | |
w101_create_property("cols", (2)) | |
if not hasattr(w101, "spacing"): | |
w101_create_property("spacing", (10)) | |
if not hasattr(w102, "code"): | |
w102.create_property("code", (None)) | |
w106_create_property = w106.create_property | |
if not hasattr(w106, "code"): | |
w106_create_property("code", (None)) | |
if not hasattr(w106, "size_hint_y"): | |
w106_create_property("size_hint_y", (None)) | |
if not hasattr(w106, "height"): | |
w106_create_property("height", (None)) | |
w107_create_property = w107.create_property | |
if not hasattr(w107, "font_size"): | |
w107_create_property("font_size", (None)) | |
if not hasattr(w107, "text"): | |
w107_create_property("text", ("hello world")) | |
if not hasattr(w107, "color"): | |
w107_create_property("color", (None)) | |
if not hasattr(w107, "size_hint_y"): | |
w107_create_property("size_hint_y", (None)) | |
if not hasattr(w107, "height"): | |
w107_create_property("height", (None)) | |
w108_create_property = w108.create_property | |
if not hasattr(w108, "code"): | |
w108_create_property("code", (None)) | |
if not hasattr(w108, "size_hint_y"): | |
w108_create_property("size_hint_y", (None)) | |
if not hasattr(w108, "height"): | |
w108_create_property("height", (None)) | |
w109_create_property = w109.create_property | |
if not hasattr(w109, "color"): | |
w109_create_property("color", (None)) | |
if not hasattr(w109, "text"): | |
w109_create_property("text", ('Hey')) | |
if not hasattr(w109, "size_hint_y"): | |
w109_create_property("size_hint_y", (None)) | |
if not hasattr(w109, "height"): | |
w109_create_property("height", (None)) | |
if not hasattr(w110, "name"): | |
w110.create_property("name", ('Application')) | |
if not hasattr(w111, "orientation"): | |
w111.create_property("orientation", ('vertical')) | |
if not hasattr(w112, "text"): | |
w112.create_property("text", (''' | |
Deux manière de lancer une application: | |
‣ runTouchApp | |
 | |
‣ App().run() | |
''')) | |
if not hasattr(w113, "spacing"): | |
w113.create_property("spacing", (2)) | |
if not hasattr(w114, "code"): | |
w114.create_property("code", (''' | |
from kivy.base import runTouchApp | |
from kivy.uix.label import Label | |
 | |
runTouchApp( | |
    Label( | |
        text='hello world')) | |
''')) | |
if not hasattr(w115, "code"): | |
w115.create_property("code", (''' | |
from kivy.app import App | |
from kivy.uix.label import Label | |
 | |
class HelloWorld(App): | |
    def build(self): | |
        return Label( | |
            text='hello world') | |
 | |
HelloWorld().run() | |
''')) | |
if not hasattr(w116, "name"): | |
w116.create_property("name", ('Applications - 2 - avantages')) | |
w117_create_property = w117.create_property | |
if not hasattr(w117, "pos_hint"): | |
w117_create_property("pos_hint", ({'center': (.5, .5)})) | |
if not hasattr(w117, "text"): | |
w117_create_property("text", (''' | |
‣ App offre de nombreuses fonctions utilitaires | |
   (on_pause, on_stop, on_resume, build_config, build_settings…) | |
 | |
‣ App charge le fichier kv associé à la | |
   classe (convention de nommage 'HelloWorldApp → | |
   helloworld.kv) dans la methode build par défaut, et le | |
   fichier de configuration (helloworld.ini) si existant. | |
 | |
‣ App est un EventDispatcher → peut servir de contrôleur | |
   principal (accessible depuis kv via le mot clé "app"). | |
''')) | |
if not hasattr(w118, "name"): | |
w118.create_property("name", ('Utilitaires')) | |
w119_create_property = w119.create_property | |
if not hasattr(w119, "pos_hint"): | |
w119_create_property("pos_hint", ({'center': (.5, .5)})) | |
if not hasattr(w119, "text"): | |
w119_create_property("text", (''' | |
‣ Clock | |
   Permet de planifier des taches répétitives | |
   (schedule_interval) ou non (schedule_once) | |
‣ Animation | |
   Transitionne la valeur d'une NumericProperty ou | |
   ListProperty (contenant un nombre fixe de valeurs | |
   Numériques) d'une valeur à une autre, dans un temps donné, | |
   via une fonction de transition configurable. | |
‣ UrlRequest | |
   urllib wrapper pour simplifier le travail en arrière | |
   plan (event lors du succès/échec) | |
etc | |
''')) | |
if not hasattr(w120, "name"): | |
w120.create_property("name", ('Exemples: kivycatalog')) | |
if not hasattr(w121, "name"): | |
w121.create_property("name", ('Outils')) | |
w122_create_property = w122.create_property | |
if not hasattr(w122, "font_size"): | |
w122_create_property("font_size", (None)) | |
if not hasattr(w122, "text"): | |
w122_create_property("text", (''' | |
Kivy vient avec un certains nombre d'outils pour faciliter | |
le développement, les connaître peut vous faire gagner | |
beaucoup de temps. | |
‣ Modules: | |
Permettent de modifier le comportement d'une application kivy: | |
→ Inspector | |
→ Monitor | |
→ Recorder | |
→ Monitor | |
→ Screen | |
 | |
‣ Garden | |
Modules communautaires à importer directement dans votre | |
projet | |
→ garden.graph | |
→ garden.pi | |
→ garden.ddd | |
→ etc… | |
''')) | |
if not hasattr(w123, "name"): | |
w123.create_property("name", ('Exemples: garden')) | |
if not hasattr(w124, "name"): | |
w124.create_property("name", ('Questions ?')) | |
w125_question_create_property = w125_question.create_property | |
if not hasattr(w125_question, "text"): | |
w125_question_create_property("text", ('?')) | |
if not hasattr(w125_question, "font_size"): | |
w125_question_create_property("font_size", (None)) | |
if not hasattr(w125_question, "color"): | |
w125_question_create_property("color", (None)) | |
if not hasattr(w129, "name"): | |
w129.create_property("name", ('Bonus: Nouveautés 1.9')) | |
if not hasattr(w130, "orientation"): | |
w130.create_property("orientation", ('vertical')) | |
if not hasattr(w131, "text"): | |
w131.create_property("text", (''' | |
‣ SDL2 provider (good bye pygame!) | |
‣ ffpyplayer video provider (ffmpeg) | |
‣ EffectWidget (shaders) | |
‣ Window's KeyboardHeight property (android) | |
‣ support SVG! | |
‣ Rebind in kv | |
‣ Tesselator | |
 | |
+ nombreuses corrections et ajouts mineurs. | |
''')) | |
w133_create_property = w133.create_property | |
if not hasattr(w133, "text"): | |
w133_create_property("text", (None)) | |
if not hasattr(w133, "font_size"): | |
w133_create_property("font_size", (None)) | |
_mc[6].add(root.__class__) | |
root.orientation = 'vertical' | |
w1.text = 'Présentation Kivy - PyCon FR - 26/10/2014' | |
w3.pos_hint = {'center_y': .5, 'x': 0} | |
w3.size_hint_x = None | |
w3.text = '�' | |
w4.pos_hint = {'center_y': .5, 'right': 1} | |
w4.size_hint_x = None | |
w4.text = '→' | |
w6.name = 'Présentation' | |
w7.orientation = 'vertical' | |
w8.text = '''Gabriel Pettier | |
Développeur python | |
Contributeur puis Core-Développeur Kivy depuis 2010 | |
 | |
http://tshirtman.fr | |
http://github.com/tshirtman | |
http://twitter.com/tshirtman | |
 | |
http://tangibledisplay.com | |
Développement d'interactions tangibles | |
''' | |
w10.name = 'Kivy' | |
w11.orientation = 'vertical' | |
w12_logo_container.size_hint_y = None | |
w13.size_hint = None, None | |
w14_logo.source = 'data/logo/kivy-icon-256.png' | |
w15.text = '''Bibliothèque de Widgets orientés multitouch | |
‣ Développé majoritairement en pur Python, le reste en | |
Cython pour les performances. | |
‣ Multiplatforme: Windows, OSX, Linux, Android et IOS | |
supportés. | |
‣ API graphique directement basée sur OpenGL ES 2.0. | |
‣ Projet Libre et collaboratif, licence MIT. | |
''' | |
w17.name = 'Concepts' | |
w18.size_hint = .5, 1 | |
w18.pos_hint = {'center': (.5, .5)} | |
w18.cols = 1 | |
w19.text = """ | |
‣ Instruction | |
→ Permet d'indiquer un ordre au GPU | |
""" | |
w20.text = """ | |
‣ Évènement | |
→ Propage une information à tous les acteurs concernés | |
""" | |
w22.name = 'Instruction exemple' | |
w23.orientation = 'vertical' | |
w25.code = ''' | |
with widget.canvas: | |
\tColor(1, 0, 0, 1, mode='rgba') | |
\tRectangle(pos=widget.pos, size=widget.size) | |
\tColor(.5, .5, .5, 1, mode='rgba') | |
\tEllipse(pos=widget.pos, size=widget.size) | |
''' | |
g27.rgba = 1, 0, 0, 1 | |
g29.rgba = .5, .5, .5, 1 | |
w31.name = 'Évènement' | |
w33.code = ''' | |
def function(*args): | |
\tprint(args) | |
 | |
widget.bind(on_touch_down=function) | |
''' | |
w34.text = 'touch me\n' | |
w34.font_size = 15 | |
w35.name = 'Properties' | |
w36.orientation = 'vertical' | |
w37.text = '''Permet de lier les attributs des objets à des | |
évènements. | |
‣ StringProperty | |
‣ NumericProperty | |
‣ ObjectProperty | |
‣ AliasProperty | |
‣ etc… | |
Doit être déclaré sur des sous-classes d'EventDispatcher, | |
qui implémentent le pattern "Observer". Ainsi, il est | |
possible à l'objet de réaliser des actions quand ses | |
propriétés changent de valeur. | |
''' | |
w38.code = ''' | |
class ClassWithProperties(EventDispatcher): | |
\tname = StringProperty('') | |
\tcount = NumericProperty(0) | |
 | |
def on_name(self, value): | |
\tprint "my name changed to %s" % value | |
''' | |
w39.name = 'Widgets' | |
w40.orientation = 'vertical' | |
w41.text = ''' | |
‣ Hérite d'EventDispatcher | |
‣ Contient un Canvas (groupe d'instructions). | |
Propose un certain nombre d'évènements par défaut, | |
notamment: | |
‣ on_touch_down | |
‣ on_touch_move | |
‣ on_touch_up | |
''' | |
w41.size_hint_y = None | |
w43.font_size = sp(14) | |
w43.text = ''' | |
class MyWidget(Widget): | |
   active = BooleanProperty(False) | |
 | |
    def __init__(self, **kwargs): | |
        super(MyWidget, self).__init__(**kwargs) | |
        self.bind(on_pos=self.update, on_size=self.update) | |
        with self.canvas: | |
            self.color = Color(1, 1, 1, 1, mode='rgba') | |
            self.rectangle = Rectangle(pos=self.pos, size=self.size) | |
 | |
    def on_active(self, active): | |
        if self.active: | |
            self.color.rgba = (.5, .5, 0, 1) | |
        else: | |
            self.coler.rgba = (1, 1, 1, 1) | |
 | |
    def update(self, *args): | |
        self.rect.pos = self.pos | |
        self.rect.size = self.size | |
 | |
    def on_touch_down(self, touch): | |
        if self.collide_point(*touch.pos): | |
            self.active = not self.active | |
''' | |
w44.active = False | |
w47.name = 'Layouts' | |
w48.orientation = 'vertical' | |
w49.text = ''' | |
Les Widgets sont par défaut complètement libres de leur | |
placement et de leur tailles, qui sont absolues (origine | |
bas-gauche de l'écran). | |
 | |
Certains widgets sont spécialisés dans le placement et le | |
dimensionnement de leurs sous widgets (enfants). | |
 | |
‣ FloatLayout | |
‣ BoxLayout | |
‣ AnchorLayout | |
‣ GridLayout | |
‣ StackLayout | |
‣ etc… | |
''' | |
w51.name = 'Layouts - 2 - Hints' | |
w52.orientation = 'vertical' | |
w53.text = ''' | |
La taille/position des widgets enfants d'un Layout est | |
généralement contrôlée via les propriétés size_hint et | |
pos_hint, qui sont relative au Layout. | |
''' | |
w55.text = ''' | |
f = FloatLayout() | |
f.add_widget( | |
    Button( | |
        size_hint=(.2, .1), | |
        pos_hint={'center': (.5, .5)}) | |
''' | |
w57.size_hint = .2, .1 | |
w57.pos_hint = {'center': (.5, .5)} | |
w57.text = 'a button' | |
w58.text = ''' | |
La taille peut être définie arbitrairement en | |
désactivant size_hint dans les directions souhaités: | |
''' | |
w60.text = ''' | |
f = FloatLayout() | |
f.add_widget( | |
    Button( | |
        size_hint_x=None, | |
        pos_hint={'center': (.5, .5)}, | |
        size_hint_y=.1, | |
        width=250, | |
        text='another button')) | |
''' | |
w62.size_hint_x = None | |
w62.pos_hint = {'center': (.5, .5)} | |
w62.size_hint_y = .1 | |
w62.width = 250 | |
w62.text = 'another button' | |
w63.name = 'Le language KV' | |
w64.orientation = 'vertical' | |
w65.font_size = sp(25) | |
w65.text = ''' | |
Python: | |
‣ super pour la logique | |
‣ moins pour la déclaration d'arbres de widgets. | |
Kv: | |
‣ Syntaxe déclarative | |
‣ Détection des dépendances et créations de | |
   branchements automatiques | |
''' | |
w67.text = ''' | |
w = Widget() | |
with w.canvas: | |
    Color(1, 0, 1, 1, mode='rgba') | |
    rect = Rectangle(pos=w.pos, size=w.size) | |
 | |
def update(self, *args): | |
    rect.pos = w.pos | |
    rect.size = w.size | |
 | |
w.bind(pos=update, size=update) | |
''' | |
w68.text = 'vs' | |
w68.size_hint_x = None | |
w68.pos_hint = {'center_y': .5} | |
w69.text = ''' | |
from kivy.lang import Builder | |
 | |
KV = """ | |
Widget: | |
    canvas: | |
        Color: | |
            rgba: 1, 0, 1, 1 | |
        Rectangle: | |
            pos: self.pos | |
            size: self.size | |
""" | |
 | |
Builder.load_string(KV) | |
''' | |
w70.name = 'Le language KV - 2 - Bindings' | |
w71.cols = 2 | |
w72.text = ''' | |
1. Callback: | |
''' | |
w73.text = ''' | |
Widget: | |
    on_pos: | |
        print('my pos is %s' % self.pos) | |
Button: | |
    on_press: | |
        print("I've been pressed") | |
''' | |
w76.text = ''' | |
2. Dépendance: | |
''' | |
w77.text = ''' | |
Widget: | |
    canvas.before: | |
        Rectangle: | |
            pos: self.pos | |
            size: self.size | |
''' | |
w78.name = 'Le language KV - 3 - règles' | |
w79.pos_hint = {'center': (.5, .5)} | |
w79.cols = 2 | |
w79.spacing = 10 | |
w80.text = ''' | |
‣ root rule: Ce qui sera retourné par le loader | |
 une seule autorisée par chaine/fichier. | |
''' | |
w81.size_hint_x = .5 | |
w81.text = ''' | |
MyWidget: | |
    Label: | |
        text: 'example' | |
''' | |
w82.text = ''' | |
‣ règle de classe: permet de configurer le style et le | |
   contenus de toutes les instances d'une classe. | |
''' | |
w83.size_hint_x = .5 | |
w83.text = ''' | |
<Widget>: | |
    Label: | |
        text: 'example' | |
''' | |
w84.text = ''' | |
‣ Classes dynamiques: permet de créer une classe en KV, | |
   en déclarant l'héritage avec '@'. | |
''' | |
w85.size_hint_x = .5 | |
w85.text = ''' | |
<MyWidget@Widget>: | |
    Label: | |
        text: 'example' | |
''' | |
w86.name = 'Le language KV - 4 - Identifiants' | |
w87.orientation = 'vertical' | |
w88.text = ''' | |
Utilisation d'id et ids pour référencer d'autres widgets | |
''' | |
w90.text = ''' | |
BoxLayout: | |
    orientation: 'vertical' | |
    TextInput: | |
        id: ti | |
    Label: | |
        text: ti.text | |
''' | |
w91.orientation = 'vertical' | |
w93.color = default_color | |
w94.size_hint_y = None | |
w94.height = 10 | |
w96.text = ''' | |
<MyWidget@BoxLayout>: | |
    Button: | |
        id: btn | |
        text: 'push me' | |
 | |
BoxLayout: | |
    Label: | |
        text: '' | |
    MyWidget: | |
        id: box | |
''' | |
w99.color = default_color | |
w99.text = '' | |
w100.name = 'Le language KV - 5 - directives' | |
w101.cols = 2 | |
w101.spacing = 10 | |
w102.code = ''' | |
—:import sin math.sin | |
—:import chain itertools.chain | |
Widget: | |
    canvas: | |
        Color: | |
            rgba: 0, 0, 0, 1 | |
        Line: | |
            points: | |
                list(chain(*zip( | |
                [self.x + x * self.width / 100. | |
                for x in range(100)], | |
                [self.center_y + sin(y/10.) * 100 | |
                for y in range(100)]))) | |
'''.replace('—', '#') | |
g104.rgba = 0, 0, 0, 1 | |
w106.code = ''' | |
—:set font_size 35 | |
—:set default_color (0, 0, 0, 1) | |
 | |
Label: | |
    font_size: font_size | |
    text: "hello world" | |
    color: default_color | |
'''.replace('—', '#') | |
w106.size_hint_y = None | |
w107.font_size = font_size | |
w107.text = "hello world" | |
w107.color = default_color | |
w107.size_hint_y = None | |
w108.code = ''' | |
—:include somefile.kv | |
 | |
SomeWidgetDefinedInSomeFile: | |
    text: "Hey" | |
'''.replace('—', '#') | |
w108.size_hint_y = None | |
w109.color = default_color | |
w109.text = 'Hey' | |
w109.size_hint_y = None | |
w110.name = 'Application' | |
w111.orientation = 'vertical' | |
w112.text = ''' | |
Deux manière de lancer une application: | |
‣ runTouchApp | |
 | |
‣ App().run() | |
''' | |
w113.spacing = 2 | |
w114.code = ''' | |
from kivy.base import runTouchApp | |
from kivy.uix.label import Label | |
 | |
runTouchApp( | |
    Label( | |
        text='hello world')) | |
''' | |
w115.code = ''' | |
from kivy.app import App | |
from kivy.uix.label import Label | |
 | |
class HelloWorld(App): | |
    def build(self): | |
        return Label( | |
            text='hello world') | |
 | |
HelloWorld().run() | |
''' | |
w116.name = 'Applications - 2 - avantages' | |
w117.pos_hint = {'center': (.5, .5)} | |
w117.text = ''' | |
‣ App offre de nombreuses fonctions utilitaires | |
   (on_pause, on_stop, on_resume, build_config, build_settings…) | |
 | |
‣ App charge le fichier kv associé à la | |
   classe (convention de nommage 'HelloWorldApp → | |
   helloworld.kv) dans la methode build par défaut, et le | |
   fichier de configuration (helloworld.ini) si existant. | |
 | |
‣ App est un EventDispatcher → peut servir de contrôleur | |
   principal (accessible depuis kv via le mot clé "app"). | |
''' | |
w118.name = 'Utilitaires' | |
w119.pos_hint = {'center': (.5, .5)} | |
w119.text = ''' | |
‣ Clock | |
   Permet de planifier des taches répétitives | |
   (schedule_interval) ou non (schedule_once) | |
‣ Animation | |
   Transitionne la valeur d'une NumericProperty ou | |
   ListProperty (contenant un nombre fixe de valeurs | |
   Numériques) d'une valeur à une autre, dans un temps donné, | |
   via une fonction de transition configurable. | |
‣ UrlRequest | |
   urllib wrapper pour simplifier le travail en arrière | |
   plan (event lors du succès/échec) | |
etc | |
''' | |
w120.name = 'Exemples: kivycatalog' | |
w121.name = 'Outils' | |
w122.font_size = sp(25) | |
w122.text = ''' | |
Kivy vient avec un certains nombre d'outils pour faciliter | |
le développement, les connaître peut vous faire gagner | |
beaucoup de temps. | |
‣ Modules: | |
Permettent de modifier le comportement d'une application kivy: | |
→ Inspector | |
→ Monitor | |
→ Recorder | |
→ Monitor | |
→ Screen | |
 | |
‣ Garden | |
Modules communautaires à importer directement dans votre | |
projet | |
→ garden.graph | |
→ garden.pi | |
→ garden.ddd | |
→ etc… | |
''' | |
w123.name = 'Exemples: garden' | |
w124.name = 'Questions ?' | |
w125_question.text = '?' | |
w125_question.font_size = 50 + abs(50 * sin(10)) | |
w125_question.color = default_color | |
g127.angle = 10 * 50 | |
w129.name = 'Bonus: Nouveautés 1.9' | |
w130.orientation = 'vertical' | |
w131.text = ''' | |
‣ SDL2 provider (good bye pygame!) | |
‣ ffpyplayer video provider (ffmpeg) | |
‣ EffectWidget (shaders) | |
‣ Window's KeyboardHeight property (android) | |
‣ support SVG! | |
‣ Rebind in kv | |
‣ Tesselator | |
 | |
+ nombreuses corrections et ajouts mineurs. | |
''' | |
w133.font_size = sp(15) | |
g134.rgba = color(background_color) | |
w2.text = w5_sm.current | |
w3.width = w3.height | |
w4.width = w4.height | |
w12_logo_container.height = w14_logo.texture_size[1] * 2 | |
w13.size = w14_logo.size | |
w13.center = w12_logo_container.center | |
w14_logo.size = w14_logo.texture_size | |
w18.height = w18.minimum_height | |
w19.text_size = w19.width, None | |
w20.text_size = w20.width, None | |
w34.text_size = w34.width, None | |
w41.height = w41.texture_size[1] | |
w68.width = w68.texture_size[0] * 2 | |
w80.text_size = w80.size | |
w82.text_size = w82.size | |
w84.text_size = w84.size | |
w93.text = w92_ti_.text | |
w106.height = w106.texture_size[1] | |
w107.height = w107.texture_size[1] | |
w108.height = w108.texture_size[1] | |
w109.height = w109.texture_size[1] | |
w133.text = '%s/%s - %s:%s' % ( | |
1 + w5_sm.screen_names.index(w5_sm.current) if w5_sm.current else 0, | |
len(w5_sm.screens), int(10 // 60), str(int(10 % | |
60)).zfill(2)) | |
if builder_created is None: | |
bfuncs = [f() for f in bfuncs] | |
bfuncs.append(_b6(app, g104, g105, g126, g127, g128, g134, g135, g27, g28, g29, g30, g45, g46, root, w1, w10, w100, w101, w102, w103, w106, w107, w108, w109, w11, w110, w111, w112, w113, w114, w115, w116, w117, w118, w119, w120, w121, w122, w123, w124, w125_question, w129, w12_logo_container, w13, w130, w131, w132, w133, w14_logo, w15, w16, w17, w18, w19, w2, w20, w21, w22, w23, w24, w25, w26, w3, w31, w32, w33, w34, w35, w36, w37, w38, w39, w4, w40, w41, w42, w43, w44, w47, w48, w49, w50, w51, w52, w53, w54, w55, w56, w57, w58, w59, w5_sm, w6, w60, w61, w62, w63, w64, w65, w66, w67, w68, w69, w7, w70, w71, w72, w73, w74, w75, w76, w77, w78, w79, w8, w80, w81, w82, w83, w84, w85, w86, w87, w88, w89, w9, w90, w91, w92_ti_, w93, w94, w95, w96, w97, w98_box, w99)) | |
bfuncs = [f() for f in reversed(bfuncs)] | |
for children in reversed(bfuncs): | |
for child in children: | |
child.dispatch("on_kv_apply", root) | |
else: | |
bfuncs.append(partial(_b6, app, g104, g105, g126, g127, g128, g134, g135, g27, g28, g29, g30, g45, g46, root, w1, w10, w100, w101, w102, w103, w106, w107, w108, w109, w11, w110, w111, w112, w113, w114, w115, w116, w117, w118, w119, w120, w121, w122, w123, w124, w125_question, w129, w12_logo_container, w13, w130, w131, w132, w133, w14_logo, w15, w16, w17, w18, w19, w2, w20, w21, w22, w23, w24, w25, w26, w3, w31, w32, w33, w34, w35, w36, w37, w38, w39, w4, w40, w41, w42, w43, w44, w47, w48, w49, w50, w51, w52, w53, w54, w55, w56, w57, w58, w59, w5_sm, w6, w60, w61, w62, w63, w64, w65, w66, w67, w68, w69, w7, w70, w71, w72, w73, w74, w75, w76, w77, w78, w79, w8, w80, w81, w82, w83, w84, w85, w86, w87, w88, w89, w9, w90, w91, w92_ti_, w93, w94, w95, w96, w97, w98_box, w99)) | |
def _b6(app, g104, g105, g126, g127, g128, g134, g135, g27, g28, g29, g30, g45, g46, root, w1, w10, w100, w101, w102, w103, w106, w107, w108, w109, w11, w110, w111, w112, w113, w114, w115, w116, w117, w118, w119, w120, w121, w122, w123, w124, w125_question, w129, w12_logo_container, w13, w130, w131, w132, w133, w14_logo, w15, w16, w17, w18, w19, w2, w20, w21, w22, w23, w24, w25, w26, w3, w31, w32, w33, w34, w35, w36, w37, w38, w39, w4, w40, w41, w42, w43, w44, w47, w48, w49, w50, w51, w52, w53, w54, w55, w56, w57, w58, w59, w5_sm, w6, w60, w61, w62, w63, w64, w65, w66, w67, w68, w69, w7, w70, w71, w72, w73, w74, w75, w76, w77, w78, w79, w8, w80, w81, w82, w83, w84, w85, w86, w87, w88, w89, w9, w90, w91, w92_ti_, w93, w94, w95, w96, w97, w98_box, w99): | |
g135_ref = g135.proxy_ref | |
g28_ref = g28.proxy_ref | |
g30_ref = g30.proxy_ref | |
g46_ref = g46.proxy_ref | |
root_ref = root.proxy_ref | |
w103_ref = w103.proxy_ref | |
w106_ref = w106.proxy_ref | |
w107_ref = w107.proxy_ref | |
w108_ref = w108.proxy_ref | |
w109_ref = w109.proxy_ref | |
w125_question_ref = w125_question.proxy_ref | |
w12_logo_container_ref = w12_logo_container.proxy_ref | |
w13_ref = w13.proxy_ref | |
w133_ref = w133.proxy_ref | |
w14_logo_ref = w14_logo.proxy_ref | |
w18_ref = w18.proxy_ref | |
w19_ref = w19.proxy_ref | |
w2_ref = w2.proxy_ref | |
w20_ref = w20.proxy_ref | |
w26_ref = w26.proxy_ref | |
w3_ref = w3.proxy_ref | |
w34_ref = w34.proxy_ref | |
w4_ref = w4.proxy_ref | |
w41_ref = w41.proxy_ref | |
w44_ref = w44.proxy_ref | |
w5_sm_ref = w5_sm.proxy_ref | |
w68_ref = w68.proxy_ref | |
w80_ref = w80.proxy_ref | |
w82_ref = w82.proxy_ref | |
w84_ref = w84.proxy_ref | |
w92_ti__ref = w92_ti_.proxy_ref | |
w93_ref = w93.proxy_ref | |
delayed_size_h21 = [size_h21, g28_ref, w26_ref, None] | |
delayed_call_fn(delayed_size_h21, None, None) | |
delayed_pos_h22 = [pos_h22, g28_ref, w26_ref, None] | |
delayed_call_fn(delayed_pos_h22, None, None) | |
delayed_pos_h23 = [pos_h23, g30_ref, w26_ref, None] | |
delayed_call_fn(delayed_pos_h23, None, None) | |
delayed_size_h24 = [size_h24, g30_ref, w26_ref, None] | |
delayed_call_fn(delayed_size_h24, None, None) | |
delayed_rgba_h27 = [rgba_h27, g45.proxy_ref, w44_ref, None] | |
delayed_call_fn(delayed_rgba_h27, None, None) | |
delayed_pos_h28 = [pos_h28, g46_ref, w44_ref, None] | |
delayed_call_fn(delayed_pos_h28, None, None) | |
delayed_size_h29 = [size_h29, g46_ref, w44_ref, None] | |
delayed_call_fn(delayed_size_h29, None, None) | |
delayed_points_h35 = [points_h35, g105.proxy_ref, w103_ref, None] | |
delayed_call_fn(delayed_points_h35, None, None) | |
delayed_origin_h40 = [origin_h40, g127.proxy_ref, w125_question_ref, None] | |
delayed_call_fn(delayed_origin_h40, None, None) | |
delayed_pos_h42 = [pos_h42, g135_ref, root_ref, None] | |
delayed_call_fn(delayed_pos_h42, None, None) | |
delayed_size_h43 = [size_h43, g135_ref, root_ref, None] | |
delayed_call_fn(delayed_size_h43, None, None) | |
dispatch_objs = [None, ] * 9 | |
root_bound = bound = [None, ] * 2 | |
bind = root.fast_bind | |
bound[0] = [None, None, None, root_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h42), delayed_call_fn, (delayed_pos_h42, )] | |
bound[1] = [None, None, None, root_ref, "size", bind("size", delayed_call_fn, delayed_size_h43), delayed_call_fn, (delayed_size_h43, )] | |
_handlers[g135.uid].append((bound, (0, 1))) | |
w103_bound = bound = [None, ] * 3 | |
bind = w103.fast_bind | |
bound[0] = [None, None, None, w103_ref, "x", bind("x", delayed_call_fn, delayed_points_h35), delayed_call_fn, (delayed_points_h35, )] | |
bound[1] = [None, None, None, w103_ref, "width", bind("width", delayed_call_fn, delayed_points_h35), delayed_call_fn, (delayed_points_h35, )] | |
bound[2] = [None, None, None, w103_ref, "center_y", bind("center_y", delayed_call_fn, delayed_points_h35), delayed_call_fn, (delayed_points_h35, )] | |
_handlers[g105.uid].append((bound, (0, 1, 2))) | |
w106_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w106_ref, "texture_size", w106.fast_bind("texture_size", height_h36, w106_ref), height_h36, (w106_ref, )] | |
_handlers[w106.uid].append((bound, (0, ))) | |
w107_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w107_ref, "texture_size", w107.fast_bind("texture_size", height_h37, w107_ref), height_h37, (w107_ref, )] | |
_handlers[w107.uid].append((bound, (0, ))) | |
w108_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w108_ref, "texture_size", w108.fast_bind("texture_size", height_h38, w108_ref), height_h38, (w108_ref, )] | |
_handlers[w108.uid].append((bound, (0, ))) | |
w109_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w109_ref, "texture_size", w109.fast_bind("texture_size", height_h39, w109_ref), height_h39, (w109_ref, )] | |
_handlers[w109.uid].append((bound, (0, ))) | |
w125_question_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w125_question_ref, "center", w125_question.fast_bind("center", delayed_call_fn, delayed_origin_h40), delayed_call_fn, (delayed_origin_h40, )] | |
_handlers[g127.uid].append((bound, (0, ))) | |
w12_logo_container_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w12_logo_container_ref, "center", w12_logo_container.fast_bind("center", center_h16, w12_logo_container_ref, w13_ref), center_h16, [w12_logo_container_ref, w13_ref]] | |
if bound[0][5]: | |
prop = w12_logo_container.property("center") | |
dispatch_objs[0] = [w12_logo_container, prop, prop.dispatch_count(w12_logo_container)] | |
_handlers[w13.uid].append((bound, (0, ))) | |
w14_logo_bound = bound = [None, ] * 3 | |
bind = w14_logo.fast_bind | |
w14_logo_get_prop = w14_logo.property | |
bound[0] = [None, None, None, w14_logo_ref, "texture_size", bind("texture_size", height_h14, w12_logo_container_ref, w14_logo_ref), height_h14, [w12_logo_container_ref, w14_logo_ref]] | |
bound[1] = [None, None, None, w14_logo_ref, "size", bind("size", size_h15, w13_ref, w14_logo_ref), size_h15, [w13_ref, w14_logo_ref]] | |
if bound[1][5]: | |
prop = w14_logo_get_prop("size") | |
dispatch_objs[1] = [w14_logo, prop, prop.dispatch_count(w14_logo)] | |
bound[2] = [None, None, None, w14_logo_ref, "texture_size", bind("texture_size", size_h17, w14_logo_ref), size_h17, (w14_logo_ref, )] | |
if bound[2][5]: | |
prop = w14_logo_get_prop("texture_size") | |
dispatch_objs[2] = [w14_logo, prop, prop.dispatch_count(w14_logo)] | |
_handlers[w12_logo_container.uid].append((bound, (0, ))) | |
_handlers[w13.uid].append((bound, (1, ))) | |
_handlers[w14_logo.uid].append((bound, (2, ))) | |
w18_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w18_ref, "minimum_height", w18.fast_bind("minimum_height", height_h18, w18_ref), height_h18, (w18_ref, )] | |
_handlers[w18.uid].append((bound, (0, ))) | |
w19_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w19_ref, "width", w19.fast_bind("width", text_size_h19, w19_ref), text_size_h19, (w19_ref, )] | |
_handlers[w19.uid].append((bound, (0, ))) | |
w20_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w20_ref, "width", w20.fast_bind("width", text_size_h20, w20_ref), text_size_h20, (w20_ref, )] | |
_handlers[w20.uid].append((bound, (0, ))) | |
w26_bound = bound = [None, ] * 4 | |
bind = w26.fast_bind | |
bound[0] = [None, None, None, w26_ref, "size", bind("size", delayed_call_fn, delayed_size_h21), delayed_call_fn, (delayed_size_h21, )] | |
bound[1] = [None, None, None, w26_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h22), delayed_call_fn, (delayed_pos_h22, )] | |
bound[2] = [None, None, None, w26_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h23), delayed_call_fn, (delayed_pos_h23, )] | |
bound[3] = [None, None, None, w26_ref, "size", bind("size", delayed_call_fn, delayed_size_h24), delayed_call_fn, (delayed_size_h24, )] | |
_handlers[g30.uid].append((bound, (2, 3))) | |
_handlers[g28.uid].append((bound, (0, 1))) | |
w3_bound = bound = [None, ] * 1 | |
bind = w3.fast_bind | |
bind("on_press", on_on_press_h0, w5_sm_ref) | |
prop = w3.property("on_press", quiet=True) | |
if prop is not None: | |
dispatch_objs[3] = [w3, prop, prop.dispatch_count(w3)] | |
bound[0] = [None, None, None, w3_ref, "height", bind("height", width_h12, w3_ref), width_h12, (w3_ref, )] | |
_handlers[w3.uid].append((bound, (0, ))) | |
w34_bound = bound = [None, ] * 1 | |
bind = w34.fast_bind | |
bind("on_touch_down", on_on_touch_down_h2, w34_ref) | |
prop = w34.property("on_touch_down", quiet=True) | |
if prop is not None: | |
dispatch_objs[4] = [w34, prop, prop.dispatch_count(w34)] | |
bound[0] = [None, None, None, w34_ref, "width", bind("width", text_size_h25, w34_ref), text_size_h25, (w34_ref, )] | |
_handlers[w34.uid].append((bound, (0, ))) | |
w4_bound = bound = [None, ] * 1 | |
bind = w4.fast_bind | |
bind("on_press", on_on_press_h1, w5_sm_ref) | |
prop = w4.property("on_press", quiet=True) | |
if prop is not None: | |
dispatch_objs[5] = [w4, prop, prop.dispatch_count(w4)] | |
bound[0] = [None, None, None, w4_ref, "height", bind("height", width_h13, w4_ref), width_h13, (w4_ref, )] | |
_handlers[w4.uid].append((bound, (0, ))) | |
w41_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w41_ref, "texture_size", w41.fast_bind("texture_size", height_h26, w41_ref), height_h26, (w41_ref, )] | |
_handlers[w41.uid].append((bound, (0, ))) | |
w44_bound = bound = [None, ] * 3 | |
bind = w44.fast_bind | |
bind("on_touch_down", on_on_touch_down_h3, w44_ref) | |
prop = w44.property("on_touch_down", quiet=True) | |
if prop is not None: | |
dispatch_objs[6] = [w44, prop, prop.dispatch_count(w44)] | |
bound[0] = [None, None, None, w44_ref, "active", bind("active", delayed_call_fn, delayed_rgba_h27), delayed_call_fn, (delayed_rgba_h27, )] | |
bound[1] = [None, None, None, w44_ref, "pos", bind("pos", delayed_call_fn, delayed_pos_h28), delayed_call_fn, (delayed_pos_h28, )] | |
bound[2] = [None, None, None, w44_ref, "size", bind("size", delayed_call_fn, delayed_size_h29), delayed_call_fn, (delayed_size_h29, )] | |
_handlers[g45.uid].append((bound, (0, ))) | |
_handlers[g46.uid].append((bound, (1, 2))) | |
w5_sm_bound = bound = [None, ] * 5 | |
bind = w5_sm.fast_bind | |
bound[0] = [None, None, None, w5_sm_ref, "current", bind("current", text_h11, w2_ref, w5_sm_ref), text_h11, [w2_ref, w5_sm_ref]] | |
bound[1] = [None, None, None, w5_sm_ref, "screens", bind("screens", text_h41, w133_ref, w5_sm_ref), text_h41, [w133_ref, w5_sm_ref]] | |
bound[2] = [None, None, None, w5_sm_ref, "current", bind("current", text_h41, w133_ref, w5_sm_ref), text_h41, [w133_ref, w5_sm_ref]] | |
if w5_sm.rebind_property("screen_names"): | |
bound[3] = [4, 5, None, w5_sm_ref, "screen_names", bind("screen_names", rebind_callback, bound, 3), rebind_callback, (bound, 3)] | |
if bound[3][5]: | |
prop = w5_sm.property("screen_names") | |
dispatch_objs[7] = [w5_sm, prop, prop.dispatch_count(w5_sm)] | |
else: | |
bound[3] = [4, 5, None, None, "screen_names", None, rebind_callback, (bound, 3)] | |
obj_w5_sm_screen_names = w5_sm.screen_names | |
if obj_w5_sm_screen_names is not None and isinstance(obj_w5_sm_screen_names, (EventDispatcher, Observable)): | |
bind = obj_w5_sm_screen_names.fast_bind | |
bound[4] = [None, None, 3, obj_w5_sm_screen_names.proxy_ref, "index", bind("index", text_h41, w133_ref, w5_sm_ref), text_h41, [w133_ref, w5_sm_ref]] | |
if bound[3] is not None and bound[4] is None: | |
bound[4] = [None, None, 3, None, "index", None, text_h41, [w133_ref, w5_sm_ref]] | |
_handlers[w133.uid].append((bound, (1, 2, 4))) | |
_handlers[w2.uid].append((bound, (0, ))) | |
w68_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w68_ref, "texture_size", w68.fast_bind("texture_size", width_h30, w68_ref), width_h30, (w68_ref, )] | |
_handlers[w68.uid].append((bound, (0, ))) | |
w80_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w80_ref, "size", w80.fast_bind("size", text_size_h31, w80_ref), text_size_h31, (w80_ref, )] | |
_handlers[w80.uid].append((bound, (0, ))) | |
w82_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w82_ref, "size", w82.fast_bind("size", text_size_h32, w82_ref), text_size_h32, (w82_ref, )] | |
_handlers[w82.uid].append((bound, (0, ))) | |
w84_bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w84_ref, "size", w84.fast_bind("size", text_size_h33, w84_ref), text_size_h33, (w84_ref, )] | |
_handlers[w84.uid].append((bound, (0, ))) | |
w92_ti__bound = bound = [None, ] * 1 | |
bound[0] = [None, None, None, w92_ti__ref, "text", w92_ti_.fast_bind("text", text_h34, w92_ti__ref, w93_ref), text_h34, [w92_ti__ref, w93_ref]] | |
if bound[0][5]: | |
prop = w92_ti_.property("text") | |
dispatch_objs[8] = [w92_ti_, prop, prop.dispatch_count(w92_ti_)] | |
_handlers[w93.uid].append((bound, (0, ))) | |
return partial(_d6, w19_bound, w18_bound, w92_ti__bound, w125_question_bound, w5_sm_bound, w103_bound, w3_bound, w106_bound, w107_bound, w108_bound, w109_bound, w84_bound, w12_logo_container_bound, w80_bound, w82_bound, w26_bound, w20_bound, w41_bound, w68_bound, w44_bound, w14_logo_bound, w4_bound, w34_bound, root_bound, dispatch_objs, (w1, w2, w3, w4, w5_sm, w6, w7, w8, w9, w10, w11, w12_logo_container, w13, w14_logo, w15, w16, w17, w18, w19, w20, w21, w22, w23, w24, w25, w26, w31, w32, w33, w34, w35, w36, w37, w38, w39, w40, w41, w42, w43, w44, w47, w48, w49, w50, w51, w52, w53, w54, w55, w56, w57, w58, w59, w60, w61, w62, w63, w64, w65, w66, w67, w68, w69, w70, w71, w72, w73, w74, w75, w76, w77, w78, w79, w80, w81, w82, w83, w84, w85, w86, w87, w88, w89, w90, w91, w92_ti_, w93, w94, w95, w96, w97, w98_box, w99, w100, w101, w102, w103, w106, w107, w108, w109, w110, w111, w112, w113, w114, w115, w116, w117, w118, w119, w120, w121, w122, w123, w124, w125_question, w129, w130, w131, w132, w133)) | |
def _d6(w19_bound, w18_bound, w92_ti__bound, w125_question_bound, w5_sm_bound, w103_bound, w3_bound, w106_bound, w107_bound, w108_bound, w109_bound, w84_bound, w12_logo_container_bound, w80_bound, w82_bound, w26_bound, w20_bound, w41_bound, w68_bound, w44_bound, w14_logo_bound, w4_bound, w34_bound, root_bound, dispatch_objs, widgets): | |
if dispatch_objs[0] is not None: | |
obj, prop, count = dispatch_objs[0] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[1] is not None: | |
obj, prop, count = dispatch_objs[1] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[2] is not None: | |
obj, prop, count = dispatch_objs[2] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[3] is not None: | |
obj, prop, count = dispatch_objs[3] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[4] is not None: | |
obj, prop, count = dispatch_objs[4] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[5] is not None: | |
obj, prop, count = dispatch_objs[5] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[6] is not None: | |
obj, prop, count = dispatch_objs[6] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[7] is not None: | |
obj, prop, count = dispatch_objs[7] | |
prop.dispatch_stale(obj, count) | |
if dispatch_objs[8] is not None: | |
obj, prop, count = dispatch_objs[8] | |
prop.dispatch_stale(obj, count) | |
return widgets | |
# <MyWidget@BoxLayout> L790 | |
_mc[7] = set() | |
def _r7(root, builder_created): | |
bfuncs = [] if builder_created is None else builder_created | |
w1_btn = Factory.Button(parent=root, __builder_created=bfuncs) | |
if root.__class__ not in _mc[7]: | |
if not hasattr(w1_btn, "text"): | |
w1_btn.create_property("text", ('push me')) | |
_mc[7].add(root.__class__) | |
w1_btn.text = 'push me' | |
if builder_created is None: | |
bfuncs = [f() for f in bfuncs] | |
bfuncs.append(_b7(app, root, w1_btn)) | |
bfuncs = [f() for f in reversed(bfuncs)] | |
for children in reversed(bfuncs): | |
for child in children: | |
child.dispatch("on_kv_apply", root) | |
else: | |
bfuncs.append(partial(_b7, app, root, w1_btn)) | |
def _b7(app, root, w1_btn): | |
return tuple | |
# register dynamic classes | |
Factory.register("PresButton", baseclasses="ButtonBehavior+SubTitle") | |
Factory.register("ContentLabel", baseclasses="Label") | |
Factory.register("SubTitle", baseclasses="FloatLayout+Title") | |
Factory.register("Title", baseclasses="Label") | |
Factory.register("Spacer", baseclasses="Widget") | |
Factory.register("CodeLabel", baseclasses="Label") | |
Factory.register("RootRule", baseclasses="BoxLayout") | |
Factory.register("MyWidget", baseclasses="BoxLayout") | |
# registration (selector, rule, avoid_previous_rules) | |
rules = ( | |
(ParserSelectorName("title"), _r0, False), | |
(ParserSelectorName("subtitle"), _r1, False), | |
(ParserSelectorName("presbutton"), _r2, False), | |
(ParserSelectorName("contentlabel"), _r3, False), | |
(ParserSelectorName("codelabel"), _r4, False), | |
(ParserSelectorName("spacer"), _r5, False), | |
(ParserSelectorName("rootrule"), _r6, False), | |
(ParserSelectorName("mywidget"), _r7, False), | |
) | |
def get_root(): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment