Why is this code is making two copies of the widgets?

37 views Asked by At

This makes two tabs for each TabbedPanelItem plus the default tab. Why does this happen and how do I prevent it?

Kivy: :

    TabbedPanelItem:
        text: 'List'

    TabbedPanelItem:
        text: 'Add/Edit'

    TabbedPanelItem:
        text: 'Delete'

Python:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.tabbedpanel import TabbedPanel

presentation = Builder.load_file('my.kv')

class Panel(TabbedPanel):
    pass

class MyApp(App):
    def build(self):
        return Panel()

if __name__ == '__main__':
    MyApp().run()
1

There are 1 answers

0
inclement On

Your kv file is being loaded twice, once by your explicit Builder.load_file and once implicitly because it has the same name as your App class (but lowercase and without the App, as expected for the default kv file to be loaded).

Remove the explicit Builder.load_file and it should work.