python - How to import graph from another class in Kivy? -


i import graph nicegraph class .kv file, have not idea, how that.

i readed documentation, couldn't find using class in class.

here's try.

class nicegraph(boxlayout):     graph = graph(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)     plot = meshlineplot(color=[1, 0, 0, 1])     plot.points = [(x, sin(x / 10.)) x in range(0, 101)]     graph.add_plot(plot)  class kivytesting(boxlayout):     pass  class kivytestingapp(app):     def build(self):         return kivytesting()  kivy_testing_app = kivytestingapp() kivy_testing_app.run() 

and there's .kv file

<kivytesting>:     orientation: 'vertical'     padding: 10     slider_colors: 0, 0, 0     canvas.before:         color:             rgb: root.slider_colors         rectangle:             pos: root.pos             size: root.size      boxlayout:         size_hint_y: 200         slider:             size_hint_x: 2             max: 1             value: 0             on_value: root.slider_colors[0] = self.value         slider:             size_hint_x: 2             max: 1             min: 0             value: 0             on_value: root.slider_colors[1] = self.value         slider:             size_hint_x: 2             max: 1             min: 0             value: 0             on_value: root.slider_colors[2] = self.value      boxlayout:         size_hint_y: 600         nicegraph:             graph: 

try using

class nicegraph(boxlayout):     global graph      graph = graph(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)     plot = meshlineplot(color=[1, 0, 0, 1])     plot.points = [(x, sin(x / 10.)) x in range(0, 101)]     graph.add_plot(plot)   class kivytesting(boxlayout):     graph1 = graph 

and work root.graph1 object in <kivytesting>:


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -