0

I am testing Kivymd Hot reload. It works well, but when I type pos_hint: {""} , then Kivy gives me an error.

Code(This code is from Kivymd docs):

from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
#:import KivyLexer kivy.extras.highlight.KivyLexer
#:import HotReloadViewer kivymd.utils.hot_reload_viewer.HotReloadViewer


BoxLayout:

    CodeInput:
        lexer: KivyLexer()
        style_name: "native"
        on_text: app.update_kv_file(self.text)
        size_hint_x: .6

    HotReloadViewer:
        size_hint_x: .4
        path: app.path_to_kv_file
        errors: True
        errors_text_color: 1, 0, 0, 1
        errors_background_color: app.theme_cls.bg_light
'''


class Example(MDApp):
    path_to_kv_file = "kv_file.kv"

    def build(self):
        self.theme_cls.theme_style = "Light"
        return Builder.load_string(KV)

    def update_kv_file(self, text):
        with open(self.path_to_kv_file, "w") as kv_file:
            kv_file.write(text)

Example().run()

Error:

 AttributeError: 'str' object has no attribute 'items'

Why this error and How to solve this Error?

I'm using Python 3.8. Thanks

Superjay
  • 447
  • 1
  • 7
  • 25

1 Answers1

0

The pos_hint should be a dictionary, but {""} is not a legal dictionary. If you want an empty dictionary, use pos_hint: {}.

John Anderson
  • 35,991
  • 4
  • 13
  • 36