班级重复

时间:2019-05-27 08:33:43

标签: python class kivy

我正在使用python和kivy进行学校项目。我对类和继承不是很熟悉。我在包含“ pass”的python文件中创建了一个类。该类继承了kivy的属性(ListItemButton),然后在kivy文件中使用此属性在其中创建“ ListView”和适配器。我的kivy应用程序运行良好,但是可视的工作室代码向我显示了错误“类'Boom'pylint的重复基数(重复基数)”,我不知道为什么。

我尝试将类名称从“ ToDoListButton”更改为“ Boom”。只是尝试,但是没有用。

"""this is python file"""
from kivy.uix.listview import ListItemButton

class Boom(ListItemButton):
    pass
"""this is kivy file"""
#: import main thelist
#: import ListAdapter kivy.adapters.listadapter.ListAdapter
#: import ListItemButton kivy.uix.listview.ListItemButton

<TodoList> """this is another class for a window in the app"""
        ListView:
            id: thelist
            adapter:    ListAdapter(data=["study"], cls=main.Boom)

该应用程序按预期方式运行,但此错误“ Boom'pylint类的重复基数(重复基数)”仍在Visual Studio代码中显示。

1 个答案:

答案 0 :(得分:0)

这意味着ListItemButton已经定义。只要您的Kivy App运行正常,就可以忽略该错误。可能是来自pylint的故障。如果您使用PyCharm,则不会得到这个。

尝试删除class Boom,import语句,#: import main thelist,并将cls=main.Boom替换为cls=ListItemButton

自从开始项目以来,您可能要使用RecycleView来代替,因为ListView自1.10.0版以来已被弃用,而在1.11.0版中已被完全删除。

相关问题