popup - Why are parentheses needed in Kivy but not in Python? -
popup - Why are parentheses needed in Kivy but not in Python? -
if want add together on_press
event popup in program, can straight in python or using kv language.
if utilize python, example
from kivy.app import app kivy.uix.popup import popup kivy.uix.button import button class somepopup(popup): pass class somebox(box): popup = somepopup() popup.title = 'anything' popup.content = button(text='anytext', on_press=popup.dismiss)
and in kv language, supposing create same popup, be.
<somepopup> title: 'anything' content: popupcontent button: id: popupcontent text: 'anytext' on_press: root.dismiss()
so, in python, have utilize on_press=popup.dismiss
, in kv language on_press: root_dismiss()
i don't understand why in kivy language should utilize parentheses , not in python. help me please?
although both accomplish same things, kv , python them in different ways.
in python, when button(text='anytext', on_press=popup.dismiss)
, you're telling kivy: when press occurs, phone call popup.dismiss
method. is, you're passing object (a class method in case) kivy phone call @ right time.
in kv, when on_press: root.dismiss()
, when press event occurs, kivy execute whatever text after colon (root.dismiss()
in case). need phone call root.dismiss()
in text.
python popup kivy
Comments
Post a Comment