mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
Upgrade to PyO3 0.24
The main change is that Rust paths are mapped to pathlib.Path, which changes our API (stricter).
This commit is contained in:
parent
0c51f69b0a
commit
826ad7a865
10 changed files with 51 additions and 51 deletions
|
@ -5,6 +5,7 @@ import pytest
|
|||
from slint import slint as native
|
||||
from slint.slint import Image, Color, Brush
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_property_access() -> None:
|
||||
|
@ -42,7 +43,7 @@ def test_property_access() -> None:
|
|||
callback test-callback();
|
||||
}
|
||||
""",
|
||||
os.path.join(os.path.dirname(__file__), "main.slint"),
|
||||
Path(__file__).parent / "main.slint",
|
||||
).component("Test")
|
||||
assert compdef is not None
|
||||
|
||||
|
@ -92,7 +93,7 @@ def test_property_access() -> None:
|
|||
imageval = instance.get_property("imageprop")
|
||||
assert imageval.width == 320
|
||||
assert imageval.height == 480
|
||||
assert "cat.jpg" in imageval.path
|
||||
assert "cat.jpg" in imageval.path.name
|
||||
|
||||
with pytest.raises(RuntimeError, match="The image cannot be loaded"):
|
||||
Image.load_from_path("non-existent.png")
|
||||
|
@ -108,7 +109,7 @@ def test_property_access() -> None:
|
|||
)
|
||||
imageval = instance.get_property("imageprop")
|
||||
assert imageval.size == (36, 36)
|
||||
assert "humidity.png" in imageval.path
|
||||
assert "humidity.png" in str(imageval.path)
|
||||
|
||||
with pytest.raises(
|
||||
TypeError, match="'int' object cannot be converted to 'PyString'"
|
||||
|
@ -157,7 +158,7 @@ def test_callbacks() -> None:
|
|||
callback void-callback();
|
||||
}
|
||||
""",
|
||||
"",
|
||||
Path(""),
|
||||
).component("Test")
|
||||
assert compdef is not None
|
||||
|
||||
|
@ -192,7 +193,7 @@ def test_callbacks() -> None:
|
|||
if __name__ == "__main__":
|
||||
import slint
|
||||
|
||||
module = slint.load_file("../../demos/printerdemo/ui/printerdemo.slint")
|
||||
module = slint.load_file(Path("../../demos/printerdemo/ui/printerdemo.slint"))
|
||||
instance = module.MainWindow()
|
||||
instance.PrinterQueue.start_job = lambda title: print(f"new print job {title}")
|
||||
instance.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue