Kivy:"XXXX"的实例没有"绑定"成员



我正在Kivy中编写一个程序,每当我试图将函数绑定到Button或任何其他小部件时,我都会从pylint得到以下问题:"Button"的实例没有"绑定"成员"线变红了。我对Kivy完全陌生,这真的让我很困扰。

当我执行程序时,它运行得很好,编译器似乎对我的绑定没有任何问题。我做错了什么?我是不是错过了导入或其他什么,或者我的环境有什么问题?

随信附上我作为示例编写的代码片段。

from kivy.app import App
from kivy.uix.button import Button
class MainApp(App):
def build(self):
button = Button(text='Hello from Kivy',
size_hint=(.5, .5),
pos_hint={'center_x': .5, 'center_y': .5})
button.bind(on_press=self.on_press_button)
return button
def on_press_button(self, instance):
print('You pressed the button!')
if __name__ == '__main__':
app = MainApp()
app.run()

您使用的任何linter都可能找不到绑定方法,因为它来自cython代码。您需要对其进行不同的配置(如果可能的话(,或者使用不同的过梁。

最新更新