Skip to content

Commit b844bf4

Browse files
committed
python: fix missing examples.counter.generated
1 parent fc38400 commit b844bf4

File tree

6 files changed

+138
-1
lines changed

6 files changed

+138
-1
lines changed

api/python/slint/tests/codegen/examples/counter/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Generated by slint.codegen from counter.slint
2+
from __future__ import annotations
3+
4+
import importlib.resources as _resources
5+
import os
6+
import types
7+
from contextlib import nullcontext as _nullcontext
8+
from pathlib import Path
9+
from typing import Any
10+
11+
import slint
12+
13+
__all__ = ['CounterWindow']
14+
15+
_MODULE_DIR = Path(__file__).parent
16+
17+
_SLINT_RESOURCE = 'counter.slint'
18+
19+
def _load() -> types.SimpleNamespace:
20+
"""Load the compiled Slint module for this package."""
21+
package = __package__ or (__spec__.parent if __spec__ else None)
22+
if package:
23+
ctx = _resources.as_file(_resources.files(package).joinpath(_SLINT_RESOURCE))
24+
else:
25+
ctx = _nullcontext(Path(__file__).with_name(_SLINT_RESOURCE))
26+
with ctx as slint_path:
27+
include_paths: list[os.PathLike[Any] | Path] = None
28+
library_paths: dict[str, os.PathLike[Any] | Path] | None = None
29+
return slint.load_file(
30+
path=slint_path,
31+
quiet=True,
32+
style=None,
33+
include_paths=include_paths,
34+
library_paths=library_paths,
35+
translation_domain=None,
36+
)
37+
38+
_module = _load()
39+
40+
CounterWindow = _module.CounterWindow
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import annotations
2+
3+
import enum
4+
5+
from typing import Any, Callable
6+
7+
import slint
8+
9+
__all__ = ['CounterWindow']
10+
11+
class CounterWindow(slint.Component):
12+
def __init__(self, **kwargs: Any) -> None:
13+
...
14+
counter: int
15+
request_increase: Callable[[], None]
16+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Generated by slint.codegen from counter.slint
2+
from __future__ import annotations
3+
4+
import importlib.resources as _resources
5+
import os
6+
import types
7+
from contextlib import nullcontext as _nullcontext
8+
from pathlib import Path
9+
from typing import Any
10+
11+
import slint
12+
13+
__all__ = ['CounterWindow']
14+
15+
_MODULE_DIR = Path(__file__).parent
16+
17+
_SLINT_RESOURCE = 'counter.slint'
18+
19+
def _load() -> types.SimpleNamespace:
20+
"""Load the compiled Slint module for this package."""
21+
package = __package__ or (__spec__.parent if __spec__ else None)
22+
if package:
23+
ctx = _resources.as_file(_resources.files(package).joinpath(_SLINT_RESOURCE))
24+
else:
25+
ctx = _nullcontext(Path(__file__).with_name(_SLINT_RESOURCE))
26+
with ctx as slint_path:
27+
include_paths: list[os.PathLike[Any] | Path] = None
28+
library_paths: dict[str, os.PathLike[Any] | Path] | None = None
29+
return slint.load_file(
30+
path=slint_path,
31+
quiet=True,
32+
style=None,
33+
include_paths=include_paths,
34+
library_paths=library_paths,
35+
translation_domain=None,
36+
)
37+
38+
_module = _load()
39+
40+
CounterWindow = _module.CounterWindow
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import annotations
2+
3+
import enum
4+
5+
from typing import Any, Callable
6+
7+
import slint
8+
9+
__all__ = ['CounterWindow']
10+
11+
class CounterWindow(slint.Component):
12+
def __init__(self, **kwargs: Any) -> None:
13+
...
14+
counter: int
15+
request_increase: Callable[[], None]
16+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export component CounterWindow inherits Window {
2+
width: 240px;
3+
height: 120px;
4+
5+
in-out property <int> counter: 0;
6+
callback request_increase();
7+
8+
Rectangle {
9+
width: parent.width;
10+
height: parent.height;
11+
background: #2b2b2b;
12+
border-radius: 12px;
13+
14+
Text {
15+
text: "Count: " + root.counter;
16+
color: white;
17+
font-size: 24px;
18+
horizontal-alignment: center;
19+
vertical-alignment: center;
20+
}
21+
22+
TouchArea {
23+
clicked => root.request_increase();
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)