Python: Use kwargs passed to the instance constructors

And set properties, like in JavaScript.
This commit is contained in:
Simon Hausmann 2024-03-07 17:49:00 +01:00
parent a3b7a6da50
commit 2234878453
2 changed files with 18 additions and 0 deletions

View file

@ -38,3 +38,18 @@ def test_load_file_wrapper():
assert instance.MyGlobal.global_prop == "This is global"
del instance
def test_constructor_kwargs():
module = load_file(os.path.join(os.path.dirname(
__spec__.origin), "test_load_file.slint"), quiet=False)
def early_say_hello(arg):
return "early:" + arg
instance = module.App(hello="Set early", say_hello=early_say_hello)
assert instance.hello == "Set early"
assert instance.invoke_say_hello("test") == "early:test"
del instance