kivy_graph_examples
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| kivy_graph_examples [2020/01/18 12:32] – ↷ Nom de la page changé de kivy_graph_example à kivy_graph_examples serge | kivy_graph_examples [2020/10/28 12:17] (Version actuelle) – ↷ Liens modifiés en raison d'un déplacement. serge | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Kivy: Graph example | + | ====== Kivy: Exemples de Kivy Garden |
| <WRAP center round box 60% centeralign> | <WRAP center round box 60% centeralign> | ||
| **{{tagpage> | **{{tagpage> | ||
| - | **[[http:// | + | **[[http:// |
| + | </ | ||
| + | <WRAP center round box 40% centeralign> | ||
| + | **[[les_pages_kivy_en_details|Les pages Kivy en détails]]** | ||
| </ | </ | ||
| - | Retour à [[kivy_garden|Kivy Garden]] | + | Retour à **[[kivy_garden|Kivy Garden]]** |
| =====Ressources===== | =====Ressources===== | ||
| * Cet exemple est instiré de **[[https:// | * Cet exemple est instiré de **[[https:// | ||
| - | * [[kivy_plyer|La page du wiki sur plyer]] | + | |
| + | * **[[https:// | ||
| + | * **[[https:// | ||
| + | |||
| + | Les exemples sont disponible dans le projet Smart Citizen: https:// | ||
| + | =====Exemple très simple===== | ||
| + | Pour expliquer, inutile d' | ||
| + | |||
| + | {{ media_06: | ||
| + | |||
| + | <code python graphexemple.py> | ||
| + | #! / | ||
| + | # -*- coding: utf-8 -*- | ||
| + | |||
| + | """ | ||
| + | Inspiré de: | ||
| + | https:// | ||
| + | """ | ||
| + | |||
| + | from math import sin | ||
| + | |||
| + | import kivy | ||
| + | kivy.require(' | ||
| + | from kivy.app import App | ||
| + | from kivy.properties import ObjectProperty | ||
| + | from kivy.uix.boxlayout import BoxLayout | ||
| + | from kivy_garden.graph import Graph, MeshLinePlot | ||
| + | |||
| + | |||
| + | class GraphExample(BoxLayout): | ||
| + | |||
| + | graph = ObjectProperty() | ||
| + | |||
| + | def __init__(self, | ||
| + | |||
| + | super().__init__(**kwargs) | ||
| + | |||
| + | plot = MeshLinePlot(color=[1, | ||
| + | plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] | ||
| + | |||
| + | # Recherche des widgets | ||
| + | print([type(widget) for widget in self.walk(loopback=True)]) | ||
| + | |||
| + | # Appel du widget avec l'id graph | ||
| + | self.ids.graph.add_plot(plot) | ||
| + | |||
| + | |||
| + | class GraphExampleApp(App): | ||
| + | def build(self): | ||
| + | return GraphExample() | ||
| + | |||
| + | if __name__ == ' | ||
| + | GraphExampleApp().run() | ||
| + | </ | ||
| + | |||
| + | <code python graphexemple.kv> | ||
| + | #:kivy 1.11.1 | ||
| + | |||
| + | < | ||
| + | BoxLayout: | ||
| + | orientation: | ||
| + | padding: 20 | ||
| + | |||
| + | Graph: | ||
| + | size_hint_y: | ||
| + | id: graph | ||
| + | background_color: | ||
| + | border_color: | ||
| + | xlabel: ' | ||
| + | ylabel: ' | ||
| + | x_ticks_minor: | ||
| + | x_ticks_major: | ||
| + | y_ticks_major: | ||
| + | y_grid_label: | ||
| + | x_grid_label: | ||
| + | padding: 5 | ||
| + | x_grid: True | ||
| + | y_grid: True | ||
| + | xmin:0 | ||
| + | xmax:100 | ||
| + | ymin:-1 | ||
| + | ymax:1 | ||
| + | </ | ||
| + | |||
| + | =====Le même exemple avec la sinusoïde qui glisse===== | ||
| + | * **[[https:// | ||
| + | |||
| + | |||
| + | {{tag> kivy python sb }} | ||
| - | {{tag> | ||
kivy_graph_examples.1579350747.txt.gz · Dernière modification : de serge
