Search code examples
pythonpython-3.xkivy

Kivy: Spinner import changes application size


i have a really strange problem. Since half a year i'm writing an application using kivy. The application will run on a Raspberry Pi with a touch screen. So for developing and checking if the layout looks fine i'm setting the application size to the touchscreen resolution at the very beginning of my code:

if __name__ == '__main__':

    Config.set('graphics', 'width', '1280')
    Config.set('graphics', 'height', '800')

Until now i just used the pure spinner class, without any problems. But now i need to create a custom spinner but i can't get it to work, even with the most basic code:

my_spinner.py:

from kivy.lang import Builder
from kivy.uix.spinner import Spinner

Builder.load_file('my_spinner.kv')


class MySpinner(Spinner):

    pass

my_spinner.kv:

#:kivy 1.11.1

<MySpinner>:

As soon as i just add

#:import MySpinner my_spinner.MySpinner

to any other kv-file the application size changes. Respectively, the Config.set() seems to be ignored. Does anyone have a clue what's going on here? To me this makes absolutely no sense. (I hope these snippets are enough. The project is quiet huge and complex.)

Thanks in advance

Edit: This happens just with the spinner class. If 'MySpinner' inherits the button class, it works fine.


Solution

  • Years passed by and I'm still working on the same application. Today I had the same problem, as soon as I added

    from kivy.uix.textinput import TextInput
    

    to my code the Config.set() got ignored. I could fix this by replaying the Config.set() by Window.size as described here.