Получаю данную ошибку: TypeError: generator() takes 1 positional argument but 2 were given
Я хочу чтобы при нажатии на кнопку в консоль писался hello world, но что-то идёт не так. Заранее спасибо!
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.config import Config
Config.set('graphics', 'resizable', 0)
Config.set('graphics', 'height', 500)
Config.set('graphics', 'width', 500)
class PasswordGeneratorApp(App):
def generator(self):
print('Hello world!')
def build(self):
appbuild = GridLayout()
appbuild.add_widget( Button(text = "сгенерировать", background_normal = "", background_color = [.96, .77, .15, 1], on_press = self.generator))
return appbuild
if __name__ == "__main__":
PasswordGeneratorApp().run()
Ошибка:
Traceback (most recent call last):
File "pass.py", line 26, in <module>
PasswordGeneratorApp().run()
File "C:\Python365\lib\site-packages\kivy\app.py", line 828, in run
runTouchApp()
File "C:\Python365\lib\site-packages\kivy\base.py", line 504, in runTouchApp
EventLoop.window.mainloop()
File "C:\Python365\lib\site-packages\kivy\core\window\window_sdl2.py", line 663, in mainloop
self._mainloop()
File "C:\Python365\lib\site-packages\kivy\core\window\window_sdl2.py", line 405, in _mainloop
EventLoop.idle()
File "C:\Python365\lib\site-packages\kivy\base.py", line 342, in idle
self.dispatch_input()
File "C:\Python365\lib\site-packages\kivy\base.py", line 327, in dispatch_input
post_dispatch_input(*pop(0))
File "C:\Python365\lib\site-packages\kivy\base.py", line 233, in post_dispatch_input
listener.dispatch('on_motion', etype, me)
File "kivy\_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:8191)
File "C:\Python365\lib\site-packages\kivy\core\window\__init__.py", line 1188, in on_motion
self.dispatch('on_touch_down', me)
File "kivy\_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:8191)
File "C:\Python365\lib\site-packages\kivy\core\window\__init__.py", line 1204, in on_touch_down
if w.dispatch('on_touch_down', touch):
File "kivy\_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:8191)
File "C:\Python365\lib\site-packages\kivy\uix\widget.py", line 457, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy\_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:8191)
File "C:\Python365\lib\site-packages\kivy\uix\behaviors\button.py", line 151, in on_touch_down
self.dispatch('on_press')
File "kivy\_event.pyx", line 714, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:8146)
File "kivy\_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy\_event.c:14035)
File "kivy\_event.pyx", line 1149, in kivy._event.EventObservers._dispatch (kivy\_event.c:13564)
TypeError: generator() takes 1 positional argument but 2 were given