recanvas 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,74 @@
1
+ # This workflow will upload a Python Package to PyPI when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ release-build:
20
+ runs-on: ubuntu-latest
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.9"
28
+
29
+ - name: Build release distributions
30
+ run: |
31
+ # NOTE: put your own distribution build steps here.
32
+ python -m pip install --upgrade pip
33
+ python -m pip install build setuptools setuptools_scm wheel
34
+ python -m build
35
+
36
+ - name: Upload distributions
37
+ uses: actions/upload-artifact@v4
38
+ with:
39
+ name: release-dists
40
+ path: dist/
41
+
42
+ pypi-publish:
43
+ runs-on: ubuntu-latest
44
+ needs:
45
+ - release-build
46
+ permissions:
47
+ # IMPORTANT: this permission is mandatory for trusted publishing
48
+ id-token: write
49
+
50
+ # Dedicated environments with protections for publishing are strongly recommended.
51
+ # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
52
+ environment:
53
+ name: pypi
54
+ # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
55
+ # url: https://pypi.org/p/YOURPROJECT
56
+ #
57
+ # ALTERNATIVE: if your GitHub Release name is the PyPI project version string
58
+ # ALTERNATIVE: exactly, uncomment the following line instead:
59
+ # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
60
+
61
+ steps:
62
+ - name: Retrieve release distributions
63
+ uses: actions/download-artifact@v4
64
+ with:
65
+ name: release-dists
66
+ path: dist/
67
+
68
+ - name: Publish release distributions to PyPI
69
+ uses: pypa/gh-action-pypi-publish@release/v1
70
+ with:
71
+ user: __token__
72
+ packages-dir: dist/
73
+ password: ${{ secrets.API_TOKEN }}
74
+
@@ -0,0 +1 @@
1
+ src/recanvas/_version.py
recanvas-1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 makssem13
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.
recanvas-1.0/PKG-INFO ADDED
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: recanvas
3
+ Version: 1.0
4
+ Summary: Tkinter Canvas but PIL
5
+ Author-email: Semenii Maksym <maks20sem@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: Pillow
13
+ Dynamic: license-file
14
+
15
+ # Recanvas
16
+ Recanvas is a Python library made to simplify using canvas for things it isn't good at. Just read code, there isn't a lot.
recanvas-1.0/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # Recanvas
2
+ Recanvas is a Python library made to simplify using canvas for things it isn't good at. Just read code, there isn't a lot.
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.3", "setuptools_scm"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "recanvas"
7
+ authors = [
8
+ { name="Semenii Maksym", email="maks20sem@gmail.com" },
9
+ ]
10
+ description = "Tkinter Canvas but PIL"
11
+ dependencies = ["Pillow"]
12
+ readme = "README.md"
13
+ requires-python = ">=3.10"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+ license = "MIT"
19
+ license-files = ["LICEN[CS]E*"]
20
+ dynamic = ["version"]
21
+
22
+ [tool.setuptools_scm]
23
+ write_to = "src/recanvas/_version.py"
recanvas-1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '1.0'
22
+ __version_tuple__ = version_tuple = (1, 0)
23
+
24
+ __commit_id__ = commit_id = 'gd3c710ecb'
@@ -0,0 +1,102 @@
1
+ from enum import Enum, auto
2
+ from PIL import Image, ImageDraw, ImageTk
3
+ import tkinter as tk
4
+
5
+ class reObjT(Enum):
6
+ OVAL = auto()
7
+ RECT = auto()
8
+ LINE = auto()
9
+ POLY = auto()
10
+ SKIP = auto()
11
+
12
+ class reObj:
13
+ def __init__(self, t, coords, fill="#000000", outline="#000000", width=1):
14
+ self.type = t
15
+ self.coords = coords
16
+ self.color = fill
17
+ self.outline = outline
18
+ self.width = width
19
+
20
+
21
+ class reCanvas:
22
+ def __init__(self, root, width=100, height=100, bd=1, highlightthickness=1, bg="#000000"):
23
+ self.objs = []
24
+ self.canvas = tk.Canvas(root, width=width, height=height,\
25
+ bd=bd, highlightthickness=highlightthickness)
26
+ self.x = width
27
+ self.y = height
28
+ self.root = root
29
+ self.basebuf = None
30
+ self.buf = Image.new("RGB", (self.x, self.y), "white")
31
+ self.screen = ImageTk.PhotoImage(self.buf, master=self.root)
32
+ self.image_screen = self.canvas.create_image(0, 0, anchor="nw", image=self.screen)
33
+ self.draw = None
34
+ self.bg = bg
35
+
36
+ def pack(self):
37
+ self.canvas.pack()
38
+
39
+ def winfo_height(self): return self.canvas.winfo_height()
40
+
41
+ def winfo_width(self): return self.canvas.winfo_width()
42
+
43
+ def create_rectangle(self, a, b, c, d, fill="#000000", outline="#000000", width=1):
44
+ self.objs.append(reObj(reObjT.RECT, (a,b,c,d), fill=fill, outline=outline, width=width))
45
+ return len(self.objs)-1
46
+
47
+ def create_oval(self, a, b, c, d, fill="#000000", outline="#000000", width=1):
48
+ self.objs.append(reObj(reObjT.OVAL, (a,b,c,d), fill=fill, outline=outline, width=width))
49
+ return len(self.objs)-1
50
+
51
+ def create_line(self, a, b, c, d, fill="#000000", outline="#000000", width=1):
52
+ self.objs.append(reObj(reObjT.LINE, (a,b,c,d), fill=fill, outline=outline, width=width))
53
+ return len(self.objs)-1
54
+
55
+ def create_polygon(self, coords, fill="#000000", outline="#000000", width=1):
56
+ self.objs.append(reObj(reObjT.POLY, coords, fill=fill, outline=outline, width=width))
57
+ return len(self.objs)-1
58
+
59
+ def move(self, objid, x, y):
60
+ obj = self.objs[objid]
61
+ x1, y1, x2, y2 = obj.coords
62
+ obj.coords = (x1 + x, y1 + y, x2 + x, y2 + y)
63
+
64
+ def delete(self, objid):
65
+ self.objs[objid].type = reObjT.SKIP
66
+
67
+ def clear(self):
68
+ self.objs.clear()
69
+
70
+ def coords(self, objid): return self.objs[objid].coords
71
+
72
+ def focus_set(self):
73
+ self.canvas.focus_set()
74
+
75
+ def bind(self, key, func):
76
+ self.canvas.bind(key, func)
77
+
78
+ def get_buf(self):
79
+ return self.buf
80
+
81
+ def open_image_as_buf(self, path):
82
+ self.basebuf = Image.open(path)
83
+ self.draw = None
84
+ return
85
+
86
+ def update(self):
87
+ if self.draw is None: self.draw = ImageDraw.Draw(self.buf)
88
+ if self.basebuf is None: self.draw.rectangle((0,0,self.x,self.y), fill=self.bg)
89
+ else:
90
+ self.buf.paste(self.basebuf)
91
+ for obj in self.objs:
92
+ match obj.type:
93
+ case reObjT.OVAL:
94
+ self.draw.ellipse(obj.coords, fill=obj.color, outline=obj.outline, width=obj.width)
95
+ case reObjT.RECT:
96
+ self.draw.rectangle(obj.coords, fill=obj.color, outline=obj.outline, width=obj.width)
97
+ case reObjT.LINE:
98
+ self.draw.line(obj.coords, fill=obj.color, width=obj.width)
99
+ case reObjT.POLY:
100
+ self.draw.polygon(obj.coords, fill=obj.color, outline=obj.outline, width=obj.width)
101
+ self.screen.paste(self.buf)
102
+ self.canvas.itemconfig(self.image_screen, image=self.screen)
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: recanvas
3
+ Version: 1.0
4
+ Summary: Tkinter Canvas but PIL
5
+ Author-email: Semenii Maksym <maks20sem@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: Pillow
13
+ Dynamic: license-file
14
+
15
+ # Recanvas
16
+ Recanvas is a Python library made to simplify using canvas for things it isn't good at. Just read code, there isn't a lot.
@@ -0,0 +1,13 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.md
4
+ pyproject.toml
5
+ .github/workflows/python-publish.yml
6
+ src/recanvas/__init__.py
7
+ src/recanvas/_version.py
8
+ src/recanvas/recanvas.py
9
+ src/recanvas.egg-info/PKG-INFO
10
+ src/recanvas.egg-info/SOURCES.txt
11
+ src/recanvas.egg-info/dependency_links.txt
12
+ src/recanvas.egg-info/requires.txt
13
+ src/recanvas.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ Pillow
@@ -0,0 +1 @@
1
+ recanvas