python kivy settings frezzes GUI to be updated

Viewed 20

I have problem with kivy settings. After settings is opened the button action is not recongnized properly. I do test on linux computer with Kivy v2.1.0 and Python v3.8.10, and on android phone. Got same result.

How to reproduce error:

Run program

Click update time Button
    -observe label name is changed
    -observe time is printed to console

Click Open config button
Click Close button on default config

Click update time Button
    -observe label name is NOT changed, but should be
    -observe time is corectly printed to console

The program source:

## Filename: main.py 

from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.widget import Widget

import time

class MyMain(Widget):

    def UpdateTimestamp(self):
        self.label1.text=str(time.time())
        print(time.time())

class CaaIoTApp(App):

    def build(self):
        return MyMain()

    def close_settings(self, settings=None):
        #The settings panel has been closed.
        super(CaaIoTApp, self).close_settings(settings)

if __name__ == "__main__":
    CaaIoTApp().run()

and kv file:

# Filename: caaiot.kv

<MyMain>:
    label1:label1

    BoxLayout:
        orientation:'vertical'
        size: root.width, root.height

        Label:
            id: label1
            text:"label1"

        Button:
            text:"Open config"
            on_release: app.open_settings()

        Button:
            text:"Update time (will work until you open config)"
            on_press: root.UpdateTimestamp()
1 Answers

After hours of searching I found that there is missing import. I got no error without that but it's needed. So I need to add:

from kivy.uix.settings import SettingsWithSpinner
Related