Search code examples
androidpythoncanvaskivyqpython

Kivy fills canvas objects with another widget's text


I just started learning Kivy (an mobile app development in general), and created this app just to illustrate my biggest problem with it.

The app should show an ellipse and a label "there should be an ellipse above" below it.

main.py file:

#qpy:kivy
import kivy
kivy.require('1.10.0')
from kivy.app import App
from kivy.uix.widget import Widget
class Test(Widget):
    pass


class TestApp(App):
    def build(self):
        return Test()


if __name__ == '__main__':
    TestApp().run()

test.kv file:

#:kivy 1.10.0     
<Test>:    
    canvas:
        Ellipse:
            pos: 0, root.height / 2
            size: 500, 200
    Label:
        font_size: 80
        center_x: root.width / 2
        center_y: root.height / 4
        text: "There should be an ellipse above"

In Ubuntu, this works perfectly, but in Qpython and Android, I see this on my phone screen: https://drive.google.com/file/d/1lbCfbvbm96lBG1VXdEMRuEU2ApD8jA4c/view

The ellipse is filled with the text "There should be an ellipse above" and stretched to fit the shape of the "ellipse". If I remove the label, the "ellipse" disappears too. The same problem appears with every canvas item.

EDIT: Solved this in really impractical way. If I create a .jpg file containing just the color I want, save it in the same folder as the main and kv files, and type this below the "Ellipse:" line, it works. But there must be a better solution, right?

source: 'white.jpg'

Solution

  • This looks like a weird bug, probably arising from some opengl issue around binding the texture ids.

    Do Kivy apps from the play store have this kind of issue? And have you only run this in qpython? It might be interesting to try with Kivy master, as qpython's Kivy version may be (certainly used to be) quite old.