RobinsSea
RobinsSea

Reputation: 135

KivyMD on a Mac: running kitchen_sink raises an error in kivytoast.py

On a Macbook Pro (Catalina), Python 3.8, interested in developing Android apps in Kivy using KivyMD. I took the following steps to install KivyMD:

All this ran seamlessly with no hitch or errors. pip freeze shows the following installed items:

I was following a Codemy video tutorial and noticed that the presenter's pip freeze showed 4 more entries:

Cd'ed into the /demos/kitchen_sink folder, ran 'python3 main.py' which failed, raising this error, the last few lines of the traceback appear to focus on a file called kivytoast.py:

   File "main.py", line 144, in <module>
     KitchenSinkApp().run()
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 949, in run
     self._run_prepare()
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 944, in _run_prepare
     self.dispatch('on_start')
   File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
   File "main.py", line 65, in on_start
     Builder.load_file(
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 306, in load_file
     return self.load_string(data, **kwargs)
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 373, in load_string
     parser = Parser(content=string, filename=fn)
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 402, in __init__
     self.parse(content)
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 508, in parse
     self.execute_directives()
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 472, in execute_directives
     mod = __import__(package)
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/__init__.py", line 11, in <module>
     from .kivytoast import toast
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/__init__.py", line 3, in <module>
     from .kivytoast import toast
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 72, in <module>
     class Toast(BaseDialog):
   File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 90, in Toast
     self, instance_label: Label, texture_size: list[int, int]
 TypeError: 'type' object is not subscriptable

Still somewhat of a novice, and not really sure how to proceed from here. ETA: I brought this up in VSCode and the last word:

list[int, int]

was squiggly-underlined, indicating it's the offending item. I have no idea what 'type' object is not subscriptable means or how to fix it.

Thanks to all who read and ponder this problem.

Upvotes: 1

Views: 248

Answers (1)

TheAdmin
TheAdmin

Reputation: 78

I'm on the same course right now and just got to that file with the same issue. I followed the path to the 'kivytoast.py' file and changed the following line (line 89):

    def label_check_texture_size(self, instance_label: Label, texture_size: list([int, int])) -> NoReturn:

The kivymd devs seemed to have made a mistake and did list[int, int] instead of list([int,int]). You could also just leave it as [int,int] and it would work the same since it is alread in list format. Goodluck with the rest of your course!

Upvotes: 1

Related Questions