kivy.lang.builder无法创建“设置”页面

时间:2018-08-14 09:23:44

标签: python kivy settings builder

我的应用程序运行良好,直到我开始收到无法确定的错误消息。

似乎引导我进入“设置”页面的构建器,尽管我没有对其进行修改,但脚本无法再找到属性root.width

对于这种情况可能会开始发生的原因有何想法?

这是带有应用程序的课程

class sdcProductionApp(App):
    def __init__(self, *args, **kwargs):
        super(sdcProductionApp, self).__init__(*args, **kwargs)

    def build(self):
        self.settings_cls = SettingsWithSidebar
        self.use_kivy_settings = False
        self.config = ConfigParser()
        self.config.read('sdc.ini')

        s = Settings()
        s.add_json_panel('Fixed Setting', self.config, data=build_settings_json)
        s.add_json_panel('Variable Settings', self.config, data=prod_settings_json)
        s.add_json_panel('Development Modes', self.config, data=dev_settings_json)

        s.on_close = self.start_programm
        s.on_config_change = self.s_on_config_change

        self.root = BoxLayout()
        self.root.add_widget(s)

        return s

编译后,它突出显示了行s = Settings()并给出以下错误消息

   File "C:\Users\fscotto\Documents\Projects\sdc_sacac_cti\src\sdc_sacac_cti\sdcProductionApp.py", line 107, in <module>
 sdcProductionApp().run()
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\app.py", line 802, in run
 root = self.build()
   File "C:\Users\fscotto\Documents\Projects\sdc_sacac_cti\src\sdc_sacac_cti\sdcProductionApp.py", line 68, in build
 s = Settings()
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\uix\settings.py", line 930, in __init__
 self.add_interface()
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\uix\settings.py", line 960, in add_interface
 interface = cls()
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\uix\settings.py", line 706, in __init__
 super(InterfaceWithSidebar, self).__init__(*args, **kwargs)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\uix\boxlayout.py", line 131, in __init__
 super(BoxLayout, self).__init__(**kwargs)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\uix\layout.py", line 76, in __init__
 super(Layout, self).__init__(**kwargs)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\uix\widget.py", line 345, in __init__
 Builder.apply(self, ignored_consts=self._kwargs_applied_init)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 451, in apply
 self._apply_rule(widget, rule, rule, ignored_consts=ignored_consts)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 566, in _apply_rule
 self.apply(child)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 451, in apply
 self._apply_rule(widget, rule, rule, ignored_consts=ignored_consts)
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 612, in _apply_rule
 e), cause=tb)
   kivy.lang.builder.BuilderException: Parser: File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\data\style.kv", line 949:
 ...
     947:        id: button
     948:        size_hint: None, None
 >>  949:        width: root.width - dp(20)
     950:        height: max(50, self.texture_size[1] + dp(20))
     951:        pos: root.x + dp(10), root.y + dp(10)
 ...
 BuilderException: Parser: File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\data\style.kv", line 949:
 ...
     947:        id: button
     948:        size_hint: None, None
 >>  949:        width: root.width - dp(20)
     950:        height: max(50, self.texture_size[1] + dp(20))
     951:        pos: root.x + dp(10), root.y + dp(10)
 ...
  AttributeError: 'module' object has no attribute 'width'
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 249, in create_handler
 return eval(value, idmap), bound_list
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\data\style.kv", line 949, in <module>
 width: root.width - dp(20)

   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 597, in _apply_rule
 rctx['ids'])
   File "C:\Users\fscotto\Anaconda2\lib\site-packages\kivy\lang\builder.py", line 254, in create_handler
 cause=tb)

0 个答案:

没有答案