pygui_simple 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.
- pygui_simple-0.1.0/LICENSE +21 -0
- pygui_simple-0.1.0/PKG-INFO +17 -0
- pygui_simple-0.1.0/README.md +0 -0
- pygui_simple-0.1.0/pyproject.toml +33 -0
- pygui_simple-0.1.0/src/pygui_simple/__init__.py +0 -0
- pygui_simple-0.1.0/src/pygui_simple/cv2_utilities.py +162 -0
- pygui_simple-0.1.0/src/pygui_simple/py.typed +0 -0
- pygui_simple-0.1.0/src/pygui_simple/tkcalendar.py +616 -0
- pygui_simple-0.1.0/src/pygui_simple/tkcontrol.py +112 -0
- pygui_simple-0.1.0/src/pygui_simple/tkmatplot.py +294 -0
- pygui_simple-0.1.0/src/pygui_simple/tkscrollpicker.py +617 -0
- pygui_simple-0.1.0/src/pygui_simple/tkslideswitch.py +448 -0
- pygui_simple-0.1.0/src/pygui_simple/tkwin.py +1344 -0
- pygui_simple-0.1.0/src/pygui_simple/winbasic.py +327 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 YoucheeXu
|
|
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,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pygui_simple
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple gui library
|
|
5
|
+
Author: Youchee
|
|
6
|
+
Author-email: Youchee <youchi.xu@live.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Dist: matplotlib>=3.10.8
|
|
12
|
+
Requires-Dist: opencv-python-headless>=4.13.0.92
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Project-URL: Homepage, https://github.com/YoucheeXu/pygui
|
|
15
|
+
Project-URL: Issues, https://github.com/YoucheeXu/pygui/issues
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pygui_simple"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A simple gui library"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Youchee", email = "youchi.xu@live.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.13"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"matplotlib>=3.10.8",
|
|
12
|
+
"opencv-python-headless>=4.13.0.92",
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
license = "MIT"
|
|
19
|
+
license-files = ["LICEN[CS]E*"]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/YoucheeXu/pygui"
|
|
23
|
+
Issues = "https://github.com/YoucheeXu/pygui/issues"
|
|
24
|
+
|
|
25
|
+
[build-system]
|
|
26
|
+
requires = ["uv_build>=0.9.18,<0.10.0"]
|
|
27
|
+
build-backend = "uv_build"
|
|
28
|
+
|
|
29
|
+
[dependency-groups]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest>=9.0.2",
|
|
32
|
+
"pytest-cov>=7.1.0",
|
|
33
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# -*- coding: UTF-8 -*-
|
|
3
|
+
import inspect
|
|
4
|
+
import re
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import cv2
|
|
9
|
+
# import PIL
|
|
10
|
+
from PIL import Image, ImageTk
|
|
11
|
+
|
|
12
|
+
def show_image(image: cv2.typing.MatLike):
|
|
13
|
+
for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
|
|
14
|
+
# print(line)
|
|
15
|
+
m = re.search(r'\bimgShow\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*\)', line)
|
|
16
|
+
if m:
|
|
17
|
+
title = m.group(1)
|
|
18
|
+
|
|
19
|
+
cv2.imshow(title, image)
|
|
20
|
+
_ = cv2.waitKey(0)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def read_image(impath: str, flags: int = cv2.IMREAD_UNCHANGED):
|
|
24
|
+
# load the image from disk
|
|
25
|
+
# impath_gbk = impath.encode('gbk') # unicode转gbk,字符串变为字节数组
|
|
26
|
+
# return cv2.imread(impath_gbk.decode(), cv2.IMREAD_UNCHANGED) # 字节数组直接转字符串,不解码
|
|
27
|
+
return cv2.imdecode(np.fromfile(impath, dtype=np.uint8), flags)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def scale_image(image: cv2.typing.MatLike, w: int, h: int, interp: int = cv2.INTER_AREA):
|
|
31
|
+
"""
|
|
32
|
+
Args:
|
|
33
|
+
interp: cv.INTER_NEAREST 最近邻插值 cv.INTER_LINEAR 双线性插值
|
|
34
|
+
cv.INTER_CUBIC 三次样条插值 cv.INTER_AREA 使用像素区域关系重新采样。
|
|
35
|
+
"""
|
|
36
|
+
return cv2.resize(image, (w, h), interpolation=interp)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def rotate_image(image: cv2.typing.MatLike, degree: float):
|
|
40
|
+
# Shape of image in terms of pixels.
|
|
41
|
+
h, w = cast(tuple[int, int], image.shape[:2])
|
|
42
|
+
|
|
43
|
+
ll = max(w, h)
|
|
44
|
+
cx, cy = (ll // 2, ll // 2)
|
|
45
|
+
padding_w = (ll - w) // 2 # 指定零填充的宽度
|
|
46
|
+
padding_h = (ll - h) // 2 # 指定零填充的高度
|
|
47
|
+
|
|
48
|
+
# 在原图像做对称的零填充,使得图片由矩形变为方形
|
|
49
|
+
image_padded: cv2.typing.MatLike = np.zeros(shape=(ll, ll, 3), dtype=np.uint8)
|
|
50
|
+
image_padded[padding_h : padding_h + h, padding_w : padding_w + w, :] = image
|
|
51
|
+
|
|
52
|
+
# getRotationMatrix2D creates a matrix needed for transformation.
|
|
53
|
+
# - (cX, cY): 旋转的中心点坐标
|
|
54
|
+
# - degree: 旋转的度数,正度数表示逆时针旋转,而负度数表示顺时针旋转。
|
|
55
|
+
# - 1.0:旋转后图像的大小,1.0原图,2.0变成原来的2倍,0.5变成原来的0.5倍
|
|
56
|
+
rm = cv2.getRotationMatrix2D((cx, cy), degree, 1)
|
|
57
|
+
rotated_padded = cv2.warpAffine(image_padded, rm, (ll, ll))
|
|
58
|
+
|
|
59
|
+
image = rotated_padded[
|
|
60
|
+
padding_w : padding_w + w, padding_h : padding_h + h, :
|
|
61
|
+
]
|
|
62
|
+
return image
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def image2photo(image: cv2.typing.MatLike):
|
|
66
|
+
""" OpenCV represents images in BGR order however PIL represents
|
|
67
|
+
images in RGB order, so we need to swap the channels
|
|
68
|
+
"""
|
|
69
|
+
image1 = cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA)
|
|
70
|
+
|
|
71
|
+
# convert the images to PIL format...
|
|
72
|
+
image2 = Image.fromarray(image1)
|
|
73
|
+
# ...and then to ImageTk format
|
|
74
|
+
image3 = ImageTk.PhotoImage(image2)
|
|
75
|
+
return image3
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def read_exif(fname: str): #定义获取图片exif的方法
|
|
79
|
+
""" Get embedded EXIF data from image file."""
|
|
80
|
+
ret = {} #创建一个字典对象存储exif的条目如相机品牌:相应品牌这样的数据
|
|
81
|
+
try:
|
|
82
|
+
# image = PIL.Image.open(fname) # 创建图像对象
|
|
83
|
+
image = Image.open(fname) # 创建图像对象
|
|
84
|
+
if hasattr(image, '_getexif'): # 检查图像对象有无_getexif属性,发现也有getexif属性,内容好像差不多
|
|
85
|
+
exif_info = image._getexif() # 取出img的_getexif属性,这是一个字典对象
|
|
86
|
+
if exif_info is not None:
|
|
87
|
+
for tag, value in exif_info.items():
|
|
88
|
+
decoded = PIL.ExifTags.TAGS.get(tag, tag)
|
|
89
|
+
ret[decoded] = value
|
|
90
|
+
except IOError:
|
|
91
|
+
print('IOERROR: ' + fname)
|
|
92
|
+
return ret
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def decode_gpsinfo(gps_info):
|
|
96
|
+
"""
|
|
97
|
+
00 VersionID int8u[4]
|
|
98
|
+
(tags 0x0001-0x0006 used for camera location according to MWG 2.0.)
|
|
99
|
+
01 LatitudeRef string[2] 'N' = North 'S' = South
|
|
100
|
+
02 Latitude float64u[3]
|
|
101
|
+
03 LongitudeRef string[2] 'E' = East 'W' = West
|
|
102
|
+
04 Longitude float64u[3]
|
|
103
|
+
05 AltitudeRef int8u 0 = Above Sea Level 1 = Below Sea Level
|
|
104
|
+
2 = Positive Sea Level (sea-level ref) 3 = Negative Sea Level (sea-level ref)
|
|
105
|
+
06 Altitude float64u
|
|
106
|
+
07 TimeStamp float64u[3] (UTC time of GPS fix. When writing,
|
|
107
|
+
date is stripped off if present, and time is adjusted to UTC if it includes a timezone)
|
|
108
|
+
08 Satellites string
|
|
109
|
+
09 Status string[2] 'A' = Measurement Active 'V' = Measurement Void
|
|
110
|
+
10 MeasureMode string[2] 2 = 2-Dimensional Measurement 3 = 3-Dimensional Measurement
|
|
111
|
+
11 DOP float64u
|
|
112
|
+
12 SpeedRef string[2] 'K' = km/h 'M' = mph 'N' = knots
|
|
113
|
+
13 Speed float64u
|
|
114
|
+
14 TrackRef string[2] 'M' = Magnetic North 'T' = True North
|
|
115
|
+
15 Track float64u
|
|
116
|
+
16 ImgDirectionRef string[2] 'M' = Magnetic North 'T' = True North
|
|
117
|
+
17 ImgDirection float64u
|
|
118
|
+
18 MapDatum string
|
|
119
|
+
(tags 0x0013-0x001a used for subject location according to MWG 2.0)
|
|
120
|
+
19 DestLatitudeRef string[2] 'N' = North 'S' = South
|
|
121
|
+
20 DestLatitude float64u[3]
|
|
122
|
+
21 DestLongitudeRef string[2] 'E' = East 'W' = West
|
|
123
|
+
22 DestLongitude float64u[3]
|
|
124
|
+
23 DestBearingRef string[2] 'M' = Magnetic North 'T' = True North
|
|
125
|
+
24 DestBearing float64u
|
|
126
|
+
25 DestDistanceRef string[2] 'K' = Kilometers 'M' = Miles 'N' = Nautical Miles
|
|
127
|
+
26 DestDistance float64u
|
|
128
|
+
27 ProcessingMethod undef (values of "GPS", "CELLID", "WLAN" or "MANUAL" by the EXIF spec.)
|
|
129
|
+
28 AreaInformation undef
|
|
130
|
+
29 DateStamp string[11] (when writing, time is stripped off if present,
|
|
131
|
+
after adjusting date/time to UTC if time includes a timezone. Format is YYYY:mm:dd)
|
|
132
|
+
30 Differential int16u 0 = No Correction 1 = Differential Corrected
|
|
133
|
+
31 HPositioningError float64u
|
|
134
|
+
"""
|
|
135
|
+
gpsitem_dict = {1: "LatitudeRef", 2: "Latitude", 3: "LongitudeRef", 4: "Longitude",
|
|
136
|
+
5: "AltitudeRef", 6: "Altitude", 7: "TimeStamp", 8: "Satellites", 9: "Status",
|
|
137
|
+
10: "MeasureMode", 11: "DOP", 12: "SpeedRef", 13: "Speed", 14: "TrackRef",
|
|
138
|
+
15: "Track", 16: "ImgDirectionRef", 17: "ImgDirection", 18: "MapDatum",
|
|
139
|
+
19: "DestLatitudeRef", 20: "DestLatitude", 21: "DestLongitudeRef",
|
|
140
|
+
22: "DestLongitude", 23: "DestBearingRef", 24: "DestBearing",
|
|
141
|
+
25: "DestDistanceRef", 26: "DestDistance", 27: "ProcessingMethod",
|
|
142
|
+
28: "AreaInformation", 29: "DateStamp", 30: "Differential", 31: "HPositioningError"}
|
|
143
|
+
gpsinfo_decoded = {}
|
|
144
|
+
for tag, val in gps_info.items():
|
|
145
|
+
key = gpsitem_dict[tag]
|
|
146
|
+
val_decoded = val
|
|
147
|
+
match key:
|
|
148
|
+
case "LatitudeRef":
|
|
149
|
+
val_decoded = "North" if val == "N" else "South"
|
|
150
|
+
case "LongitudeRef":
|
|
151
|
+
val_decoded = "East" if val == "E" else "West"
|
|
152
|
+
case "SpeedRef":
|
|
153
|
+
val_decoded = {"K": "km/h", "M": "mph", "N": "knots"}.get(val, "Unknown")
|
|
154
|
+
case "ImgDirectionRef":
|
|
155
|
+
val_decoded = {"M": "Magnetic North", "T": "True North"}.get(val, "Unknown")
|
|
156
|
+
case "DestBearingRef":
|
|
157
|
+
val_decoded = {"M": "Magnetic North", "T": "True North"}.get(val, "Unknown")
|
|
158
|
+
case _:
|
|
159
|
+
pass
|
|
160
|
+
gpsinfo_decoded[key] = val_decoded
|
|
161
|
+
return gpsinfo_decoded
|
|
162
|
+
|
|
File without changes
|