mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 04:18:14 +00:00
Python: Use kwargs passed to the instance constructors
And set properties, like in JavaScript.
This commit is contained in:
parent
a3b7a6da50
commit
2234878453
2 changed files with 18 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue