类的重复基

2024-05-19 03:02:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个学校的项目,使用python和kivy。我对阶级和继承不是很熟悉。我在python文件中创建了一个包含“pass”的类。这个类继承了kivy的属性(ListItemButton),然后我在kivy文件中使用这个属性来创建一个“ListView”和一个适配器。我的kivy应用程序运行良好,但visualstudio代码显示错误“duplicatebases for class'Boom'pylint(duplicatebases)”,我不知道为什么。你知道吗

我试过把类名从“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)

该应用程序按其预期工作,但此错误“Duplicate bases for class'Boom'pylint(Duplicate bases)”仍显示在VisualStudio代码中。你知道吗


Tags: 文件代码importfor属性is错误pass
1条回答
网友
1楼 · 发布于 2024-05-19 03:02:26

这意味着已经定义了ListItemButton。只要你的Kivy应用程序运行正常,你就可以忽略这个错误。可能是pylint的故障。如果你使用PyCharm,你不会得到这个。你知道吗

尝试删除class Boom,import语句,#: import main thelist,并用cls=ListItemButton替换cls=main.Boom。你知道吗

由于您正在启动项目,您可能希望改用RecycleView,因为^{}从1.10.0版开始就被弃用,在1.11.0版中被完全删除。你知道吗

相关问题 更多 >

    热门问题