I am trying to use canvas. I didn't create .kv files. It should show up a white line.
from kivy.graphics import Line
from kivy.uix.widget import Widget
# Canvas from the code
class CanvasExample3App(App):
class CanvasEx3(Widget):
def __init__(self, **kwargs):
super().__init__(**kwargs)
with self.canvas:
Line(points=(0, 0, 300, 500), width=2)
CanvasExample3App().run()
I changed you code a bit and it works.
You should use build method. It Initializes the application and always return root widget or widget tree. Also you can find more information in Kivy documentation here and here.
from kivy.graphics import Line
from kivy.app import App
from kivy.uix.widget import Widget
# Canvas from the code
class CanvasExample3App(App):
def build(self):
return CanvasEx3()
class CanvasEx3(Widget):
def __init__(self, **kwargs):
super().__init__(**kwargs)
with self.canvas:
Line(points=(0, 0, 300, 500), width=2)
CanvasExample3App().run()