我使用的是:MacOS Big Sur,KivyMd版本-v0.104.2.dev(我试过使用稳定版本,但它仍然不能解决问题)和Python版本3.9.4。
除MDIconButton外,与KivyMD按钮(MDFlatButton、MDFilledRoundFlatIconButton、MDRaisedButton等)相关的任何内容都不起作用。
当我运行任何带有KivyMD按钮的代码时,它会给我这个错误(甚至当我尝试单击厨房Flume中的按钮选项时,窗口关闭并在终端中给我以下错误):
[INFO ] [Logger ] Record log in /Users/chaithanya/.kivy/logs/kivy_21-05-10_11.txt
[INFO ] [Kivy ] v2.1.0.dev0
[INFO ] [Kivy ] Installed at "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.9.4 (v3.9.4:1f2e3088f3, Apr 4 2021, 12:32:44)
[Clang 6.0 (clang-600.0.57)]
[INFO ] [Python ] Interpreter at "/Library/Frameworks/Python.framework/Versions/3.9/bin/python3"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL ES 2" graphics system
[INFO ] [GL ] Backend used <sdl2>
[INFO ] [GL ] OpenGL version <b'2.1 INTEL-16.1.12'>
[INFO ] [GL ] OpenGL vendor <b'Intel Inc.'>
[INFO ] [GL ] OpenGL renderer <b'Intel Iris OpenGL Engine'>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <b'1.20'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Loader ] using a thread pool of 2 workers
[INFO ] [KivyMD ] 0.104.2.dev0, git-8f83652, 2021-05-10 (installed at "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivymd/__init__.py")
[INFO ] [Text ] Provider: sdl2
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Clipboard ] Provider: sdl2(['clipboard_nspaste'] ignored)
[INFO ] [Base ] Start application main loop
[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 702, in _apply_rule
setattr(widget_set, key, value)
File "kivy/weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy/properties.pyx", line 520, in kivy.properties.Property.__set__
File "kivy/properties.pyx", line 555, in kivy.properties.Property.set
File "kivy/properties.pyx", line 1264, in kivy.properties.BoundedNumericProperty.check
TypeError: Cannot convert kivy.properties.NumericPropertyStorage to kivy.properties.BoundedNumericPropertyStorage
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/chaithanya/KivyMD/demos/kitchen_sink/main.py", line 144, in <module>
KitchenSinkApp().run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/app.py", line 955, in run
runTouchApp()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/base.py", line 580, in runTouchApp
EventLoop.mainloop()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/base.py", line 345, in mainloop
self.idle()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/base.py", line 389, in idle
self.dispatch_input()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/base.py", line 340, in dispatch_input
post_dispatch_input(*pop(0))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/base.py", line 306, in post_dispatch_input
wid.dispatch('on_touch_up', me)
File "kivy/_event.pyx", line 719, in kivy._event.EventDispatcher.dispatch
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivymd/uix/list.py", line 854, in on_touch_up
super().on_touch_up(touch)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivymd/uix/behaviors/ripple_behavior.py", line 296, in on_touch_up
return super().on_touch_up(touch)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/behaviors/button.py", line 179, in on_touch_up
self.dispatch('on_release')
File "kivy/_event.pyx", line 719, in kivy._event.EventDispatcher.dispatch
File "/Users/chaithanya/KivyMD/demos/kitchen_sink/main.py", line 86, in <lambda>
"on_release": lambda x=name_item_example: self.set_example_screen(
File "/Users/chaithanya/KivyMD/demos/kitchen_sink/main.py", line 108, in set_example_screen
screen_object = eval(self.data_screens[name_screen]["Factory"])
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/relativelayout.py", line 274, in __init__
super(RelativeLayout, self).__init__(**kw)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/floatlayout.py", line 65, in __init__
super(FloatLayout, self).__init__(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/layout.py", line 76, in __init__
super(Layout, self).__init__(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivymd/uix/behaviors/backgroundcolor_behavior.py", line 189, in __init__
super().__init__(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivymd/uix/behaviors/backgroundcolor_behavior.py", line 147, in __init__
super().__init__(**kwarg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivymd/uix/behaviors/elevation.py", line 847, in __init__
super().__init__(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/widget.py", line 359, in __init__
self.apply_class_lang_rules(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/widget.py", line 463, in apply_class_lang_rules
Builder.apply(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 542, in apply
self._apply_rule(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 664, in _apply_rule
self._apply_rule(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 664, in _apply_rule
self._apply_rule(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 664, in _apply_rule
self._apply_rule(
[Previous line repeated 1 more time]
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 662, in _apply_rule
child.apply_class_lang_rules(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/uix/widget.py", line 463, in apply_class_lang_rules
Builder.apply(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 542, in apply
self._apply_rule(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 711, in _apply_rule
raise BuilderException(rule.ctx, rule.line,
kivy.lang.builder.BuilderException: Parser: File "<inline>", line 16:
...
14: size_hint: None, None
15: height: dp(20) + lbl_txt.texture_size[1]
>> 16: width: lbl_txt.texture_size[0] + dp(24)
17:
18: MDLabel:
...
TypeError: Cannot convert kivy.properties.NumericPropertyStorage to kivy.properties.BoundedNumericPropertyStorage
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy/lang/builder.py", line 702, in _apply_rule
setattr(widget_set, key, value)
File "kivy/weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy/properties.pyx", line 520, in kivy.properties.Property.__set__
File "kivy/properties.pyx", line 555, in kivy.properties.Property.set
File "kivy/properties.pyx", line 1264, in kivy.properties.BoundedNumericProperty.check
下面是我正在运行的代码,在我添加按钮之前,一切都很好:
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager,Screen
##from kivy.core.window import Window
##Window.size = (280, 500)
login = '''
FloatLayout:
MDLabel:
pos_hint:{'center_x':.9,'center_y':.85}
text:'LOGIN'
font_size:80
MDTextField:
id:user
hint_text:'Username'
pos_hint:{'center_x':.5,'center_y':.75}
size_hint:.5,.1
MDTextField:
id:passw
hint_text:'Password'
password:True
pos_hint:{'center_x':.5,'center_y':.65}
size_hint:.5,.1
MDRoundFlatButton:
text:'Login'
pos_hint:{'center_x':.5,'center_y':.55}
size_hint:.2,.1
'''
class LoginApp(MDApp):
def build(self):
return Builder.load_string(login)
if __name__ == '__main__':
LoginApp().run()
2条答案
按热度按时间von4xj4u1#
我卸载了Kivy和KivyMD,并安装了两者的稳定版本,现在它工作正常。
bwntbbo32#
如果你试图返回一个字符串,请使用f '{}'来解决这个问题。这很容易。最好的