craftonKft 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2026] [Vasiliy]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: craftonKft
3
+ Version: 0.1.0
4
+ Summary: Упрощённая библиотека-виджет для Flet
5
+ Requires-Python: >=3.9
6
+ License-File: LICENSE
7
+ Requires-Dist: flet
8
+ Requires-Dist: requests
9
+ Dynamic: license-file
@@ -0,0 +1,19 @@
1
+ from .window import screen as _screen, run
2
+ from .components import button, Text, ContN, ContC, Row
3
+ from .widgets import realtime, weather
4
+
5
+
6
+ def screen(w: int, h: int):
7
+ _screen.width = w
8
+ _screen.height = h
9
+ return _screen
10
+
11
+
12
+ screen.add = _screen.add
13
+ screen.resize = _screen.resize
14
+
15
+ __all__ = [
16
+ "screen", "run",
17
+ "button", "Text", "ContN", "ContC", "Row",
18
+ "realtime", "weather",
19
+ ]
@@ -0,0 +1,116 @@
1
+ import flet as ft
2
+ from .utils import parse_size
3
+
4
+
5
+ class button(ft.Container):
6
+ def __init__(
7
+ self,
8
+ text: str,
9
+ size: str = "100*40",
10
+ font: str = "Montserrat",
11
+ font_size: int = 16,
12
+ on_click=None,
13
+ color: str = "blue",
14
+ ):
15
+ w, h = parse_size(size) or (100, 40)
16
+ self.text_ctrl = ft.Text(
17
+ text, font_family=font, size=font_size, color="white"
18
+ )
19
+ super().__init__(
20
+ content=self.text_ctrl,
21
+ width=w,
22
+ height=h,
23
+ bgcolor=color,
24
+ border_radius=10,
25
+ alignment=ft.Alignment.CENTER,
26
+ on_click=on_click,
27
+ ink=True,
28
+ )
29
+
30
+ def resize(self, size: str):
31
+ w, h = parse_size(size) or (self.width, self.height)
32
+ self.width, self.height = w, h
33
+ if self.page:
34
+ self.update()
35
+
36
+
37
+ class Text(ft.Text):
38
+ def __init__(
39
+ self,
40
+ text: str,
41
+ size: int = 16,
42
+ font: str = "Montserrat",
43
+ color: str = "black",
44
+ ):
45
+ super().__init__(
46
+ value=text, size=size, font_family=font, color=color
47
+ )
48
+
49
+ def resize(self, size: int):
50
+ self.size = size
51
+ if self.page:
52
+ self.update()
53
+
54
+
55
+ class ContN(ft.Container):
56
+ def __init__(
57
+ self,
58
+ content=None,
59
+ size: str = None,
60
+ bordr: int = 30,
61
+ color: str = "transparent",
62
+ ):
63
+ w, h = parse_size(size) if size else (None, None)
64
+ if isinstance(content, str):
65
+ content = Text(content)
66
+ super().__init__(
67
+ content=content,
68
+ width=w,
69
+ height=h,
70
+ bgcolor=color,
71
+ border_radius=bordr,
72
+ padding=10,
73
+ )
74
+ self._items = []
75
+
76
+ def add(self, *controls):
77
+ self._items.extend(controls)
78
+ self.content = ft.Column(list(self._items), spacing=10)
79
+ return self
80
+
81
+ def resize(self, size: str):
82
+ w, h = parse_size(size) or (self.width, self.height)
83
+ self.width, self.height = w, h
84
+ if self.page:
85
+ self.update()
86
+
87
+
88
+ class ContC(ft.Container):
89
+ def __init__(self, color: str = "white", size: str = "300*400"):
90
+ w, h = parse_size(size) or (300, 400)
91
+ self._col = ft.Column(
92
+ spacing=10, scroll=ft.ScrollMode.AUTO, expand=True
93
+ )
94
+ super().__init__(
95
+ content=self._col,
96
+ width=w,
97
+ height=h,
98
+ bgcolor=color,
99
+ border_radius=20,
100
+ padding=15,
101
+ )
102
+
103
+ def add(self, *controls):
104
+ self._col.controls.extend(controls)
105
+ return self
106
+
107
+ def resize(self, size: str):
108
+ w, h = parse_size(size) or (self.width, self.height)
109
+ self.width, self.height = w, h
110
+ if self.page:
111
+ self.update()
112
+
113
+
114
+ class Row(ft.Row):
115
+ def __init__(self, *controls, **kwargs):
116
+ super().__init__(controls=list(controls), **kwargs)
@@ -0,0 +1,8 @@
1
+ def parse_size(size_str: str) -> tuple:
2
+ if not size_str:
3
+ return None
4
+ try:
5
+ w, h = str(size_str).replace("x", "*").split("*")
6
+ return float(w.strip()), float(h.strip())
7
+ except Exception:
8
+ return None
@@ -0,0 +1,73 @@
1
+ import asyncio
2
+ import datetime
3
+
4
+ import flet as ft
5
+ import requests
6
+
7
+
8
+ class realtime(ft.Text):
9
+ def __init__(
10
+ self,
11
+ country: str = "RU",
12
+ gmt: str = "GMT+3",
13
+ size: int = 20,
14
+ color: str = "black",
15
+ font: str = "Montserrat",
16
+ ):
17
+ super().__init__(
18
+ value="00:00:00", size=size, color=color, font_family=font
19
+ )
20
+ self.gmt = gmt
21
+
22
+ def did_mount(self):
23
+ self.page.run_task(self._loop)
24
+
25
+ async def _loop(self):
26
+ while True:
27
+ now = datetime.datetime.utcnow()
28
+ try:
29
+ offset = int(self.gmt.replace("GMT", "").replace("+", ""))
30
+ now += datetime.timedelta(hours=offset)
31
+ except ValueError:
32
+ pass
33
+
34
+ self.value = now.strftime("%H:%M:%S")
35
+ self.update()
36
+ await asyncio.sleep(1)
37
+
38
+
39
+ class weather(ft.Column):
40
+ def __init__(
41
+ self,
42
+ api_key: str,
43
+ city: str = "Moscow",
44
+ size: int = 16,
45
+ color: str = "black",
46
+ ):
47
+ self._text = ft.Text("Загрузка...", size=size, color=color)
48
+ super().__init__(controls=[self._text])
49
+ self.api_key = api_key
50
+ self.city = city
51
+
52
+ def did_mount(self):
53
+ self.page.run_task(self._fetch)
54
+
55
+ async def _fetch(self):
56
+ url = (
57
+ f"http://api.openweathermap.org/data/2.5/weather"
58
+ f"?q={self.city}&appid={self.api_key}&units=metric&lang=ru"
59
+ )
60
+ try:
61
+ res = await asyncio.to_thread(requests.get, url)
62
+ data = res.json()
63
+ if data.get("cod") == 200:
64
+ temp = data["main"]["temp"]
65
+ desc = data["weather"][0]["description"]
66
+ self._text.value = (
67
+ f"{self.city}: {temp}°C, {desc.capitalize()}"
68
+ )
69
+ else:
70
+ self._text.value = "Ошибка API"
71
+ except Exception:
72
+ self._text.value = "Ошибка сети"
73
+ self.update()
@@ -0,0 +1,58 @@
1
+ import flet as ft
2
+
3
+ from .components import ContC
4
+
5
+
6
+ class Screen:
7
+ def __init__(self):
8
+ self.width = 300
9
+ self.height = 400
10
+ self._root = None
11
+ self._page = None
12
+ self._drag = ft.WindowDragArea(
13
+ content=ft.Container(height=20, bgcolor="transparent"),
14
+ maximizable=False,
15
+ )
16
+
17
+ def resize(self, w: int, h: int):
18
+ self.width = w
19
+ self.height = h
20
+ if self._page:
21
+ self._page.window.width = w
22
+ self._page.window.height = h
23
+ if self._root:
24
+ self._root.width = w
25
+ self._root.height = h
26
+ self._page.update()
27
+
28
+ def add(self, *controls):
29
+ self._root = ft.Container(
30
+ content=ft.Column([self._drag] + list(controls), spacing=0),
31
+ width=self.width,
32
+ height=self.height,
33
+ bgcolor="transparent",
34
+ border_radius=20,
35
+ )
36
+ if self._page:
37
+ self._page.add(self._root)
38
+ self._page.update()
39
+
40
+
41
+ screen = Screen()
42
+
43
+
44
+ def run():
45
+ def main(page: ft.Page):
46
+ screen._page = page
47
+ page.window.frameless = True
48
+ page.window.skip_task_bar = True
49
+ page.window.always_on_top = True
50
+ page.window.width = screen.width
51
+ page.window.height = screen.height
52
+ page.window.bgcolor = ft.Colors.TRANSPARENT
53
+ page.bgcolor = ft.Colors.TRANSPARENT
54
+
55
+ if screen._root:
56
+ page.add(screen._root)
57
+
58
+ ft.run(main)
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: craftonKft
3
+ Version: 0.1.0
4
+ Summary: Упрощённая библиотека-виджет для Flet
5
+ Requires-Python: >=3.9
6
+ License-File: LICENSE
7
+ Requires-Dist: flet
8
+ Requires-Dist: requests
9
+ Dynamic: license-file
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ pyproject.toml
3
+ craftonKft/__init__.py
4
+ craftonKft/components.py
5
+ craftonKft/utils.py
6
+ craftonKft/widgets.py
7
+ craftonKft/window.py
8
+ craftonKft.egg-info/PKG-INFO
9
+ craftonKft.egg-info/SOURCES.txt
10
+ craftonKft.egg-info/dependency_links.txt
11
+ craftonKft.egg-info/requires.txt
12
+ craftonKft.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ flet
2
+ requests
@@ -0,0 +1 @@
1
+ craftonKft
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "craftonKft"
7
+ version = "0.1.0"
8
+ description = "Упрощённая библиотека-виджет для Flet"
9
+ requires-python = ">=3.9"
10
+ dependencies = ["flet", "requests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+