mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 04:18:14 +00:00
Python: Create a property type wrapper for component instances
Map properties and callbacks to attributes with getters and setters. cc #4134
This commit is contained in:
parent
6d2144deb1
commit
3c9b57ecf8
4 changed files with 130 additions and 6 deletions
|
|
@ -20,3 +20,21 @@ def test_load_file(caplog):
|
|||
def test_load_file_fail():
|
||||
with pytest.raises(CompileError, match="Could not compile non-existent.slint"):
|
||||
load_file("non-existent.slint")
|
||||
|
||||
|
||||
def test_load_file_wrapper():
|
||||
module = load_file(os.path.join(os.path.dirname(
|
||||
__spec__.origin), "test_load_file.slint"), quiet=False)
|
||||
|
||||
instance = module.App()
|
||||
|
||||
assert instance.hello == "World"
|
||||
instance.hello = "Ok"
|
||||
assert instance.hello == "Ok"
|
||||
|
||||
instance.say_hello = lambda x: "from here: " + x
|
||||
assert instance.say_hello("wohoo") == "from here: wohoo"
|
||||
|
||||
assert instance.MyGlobal.global_prop == "This is global"
|
||||
|
||||
del instance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue