kivy_graph_examples
Ceci est une ancienne révision du document !
Table des matières
Kivy: Exemples de Kivy Garden Graph
Ressources
- Cet exemple est instiré de accelerometer using graph qui est un exemple de https://github.com/kivy/plyer
Exemple très simple
Pour expliquer, inutile d'introduire les Nombres Complexes (y = a + b*i) avec i*i = -1 ou les arctg(ln(0.154236987))!
- graphexemple.py
#! /usr/bin/env python3 # -*- coding: utf-8 -*- """ Inspiré de: https://github.com/kivy/plyer/tree/master/examples/accelerometer/using_graph """ from math import sin import kivy kivy.require('1.11.1') 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, **kwargs): super().__init__(**kwargs) plot = MeshLinePlot(color=[1, 0, 0, 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__ == '__main__': GraphExampleApp().run()
- graphexemple.kv
#:kivy 1.11.1 <GraphExample>: BoxLayout: orientation: 'vertical' padding: 20 Graph: size_hint_y: 0.8 id: graph background_color: 0, 1, 1, 1 border_color: 1, 1, 0, 1 xlabel: 'X' ylabel: 'Y' x_ticks_minor: 5 x_ticks_major: 25 y_ticks_major: 1 y_grid_label: True x_grid_label: True padding: 5 x_grid: True y_grid: True xmin:0 xmax:100 ymin:-1 ymax:1
kivy_graph_examples.1579351631.txt.gz · Dernière modification : 2020/01/18 12:47 de serge