XMWAI 0.4.12__tar.gz → 0.4.23__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.

Potentially problematic release.


This version of XMWAI might be problematic. Click here for more details.

Files changed (120) hide show
  1. {xmwai-0.4.12/XMWAI.egg-info → xmwai-0.4.23}/PKG-INFO +1 -1
  2. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/__init__.py +2 -2
  3. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/trial_class.py +53 -49
  4. {xmwai-0.4.12 → xmwai-0.4.23/XMWAI.egg-info}/PKG-INFO +1 -1
  5. {xmwai-0.4.12 → xmwai-0.4.23}/setup.py +1 -1
  6. {xmwai-0.4.12 → xmwai-0.4.23}/LICENSE.txt +0 -0
  7. {xmwai-0.4.12 → xmwai-0.4.23}/MANIFEST.in +0 -0
  8. {xmwai-0.4.12 → xmwai-0.4.23}/README.md +0 -0
  9. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/bomb_core.py +0 -0
  10. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/core.py +0 -0
  11. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/file/__init__.py +0 -0
  12. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/file/idiom.json +0 -0
  13. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/0.gif +0 -0
  14. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/1.gif +0 -0
  15. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/10.gif +0 -0
  16. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/11.gif +0 -0
  17. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/12.gif +0 -0
  18. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/13.gif +0 -0
  19. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/14.gif +0 -0
  20. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/15.gif +0 -0
  21. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/16.gif +0 -0
  22. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/17.gif +0 -0
  23. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/18.gif +0 -0
  24. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/19.gif +0 -0
  25. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/2.gif +0 -0
  26. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/20.gif +0 -0
  27. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/21.gif +0 -0
  28. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/22.gif +0 -0
  29. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/23.gif +0 -0
  30. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/24.gif +0 -0
  31. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/25.gif +0 -0
  32. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/26.gif +0 -0
  33. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/27.gif +0 -0
  34. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/28.gif +0 -0
  35. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/29.gif +0 -0
  36. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/3.gif +0 -0
  37. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/30.gif +0 -0
  38. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/31.gif +0 -0
  39. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/32.gif +0 -0
  40. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/33.gif +0 -0
  41. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/34.gif +0 -0
  42. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/35.gif +0 -0
  43. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/36.gif +0 -0
  44. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/37.gif +0 -0
  45. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/38.gif +0 -0
  46. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/39.gif +0 -0
  47. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/4.gif +0 -0
  48. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/40.gif +0 -0
  49. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/41.gif +0 -0
  50. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/42.gif +0 -0
  51. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/43.gif +0 -0
  52. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/44.gif +0 -0
  53. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/45.gif +0 -0
  54. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/46.gif +0 -0
  55. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/47.gif +0 -0
  56. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/48.gif +0 -0
  57. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/49.gif +0 -0
  58. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/5.gif +0 -0
  59. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/50.gif +0 -0
  60. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/51.gif +0 -0
  61. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/52.gif +0 -0
  62. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/53.gif +0 -0
  63. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/54.gif +0 -0
  64. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/55.gif +0 -0
  65. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/56.gif +0 -0
  66. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/57.gif +0 -0
  67. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/58.gif +0 -0
  68. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/59.gif +0 -0
  69. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/6.gif +0 -0
  70. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/60.gif +0 -0
  71. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/61.gif +0 -0
  72. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/62.gif +0 -0
  73. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/63.gif +0 -0
  74. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/64.gif +0 -0
  75. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/65.gif +0 -0
  76. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/66.gif +0 -0
  77. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/67.gif +0 -0
  78. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/68.gif +0 -0
  79. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/69.gif +0 -0
  80. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/7.gif +0 -0
  81. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/70.gif +0 -0
  82. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/71.gif +0 -0
  83. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/72.gif +0 -0
  84. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/73.gif +0 -0
  85. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/74.gif +0 -0
  86. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/75.gif +0 -0
  87. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/76.gif +0 -0
  88. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/77.gif +0 -0
  89. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/78.gif +0 -0
  90. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/79.gif +0 -0
  91. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/8.gif +0 -0
  92. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/80.gif +0 -0
  93. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/81.gif +0 -0
  94. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/82.gif +0 -0
  95. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/83.gif +0 -0
  96. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/84.gif +0 -0
  97. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/85.gif +0 -0
  98. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/9.gif +0 -0
  99. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/gif/__init__.py +0 -0
  100. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/idiom_core.py +0 -0
  101. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/magic_core.py +0 -0
  102. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/burger.js +0 -0
  103. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/BottomBun.png +0 -0
  104. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/TopBun.png +0 -0
  105. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/beef.png +0 -0
  106. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/bg.jpeg +0 -0
  107. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/bg.png +0 -0
  108. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/cheese.png +0 -0
  109. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/lettuce.png +0 -0
  110. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/sauce.png +0 -0
  111. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/static/images/tomato.png +0 -0
  112. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/templates/burger.html +0 -0
  113. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/templates/nutrition_pie.html +0 -0
  114. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/templates//345/210/233/346/204/217/350/217/234/350/260/261.html" +0 -0
  115. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI/web_core.py +0 -0
  116. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI.egg-info/SOURCES.txt +0 -0
  117. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI.egg-info/dependency_links.txt +0 -0
  118. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI.egg-info/requires.txt +0 -0
  119. {xmwai-0.4.12 → xmwai-0.4.23}/XMWAI.egg-info/top_level.txt +0 -0
  120. {xmwai-0.4.12 → xmwai-0.4.23}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.4.12
3
+ Version: 0.4.23
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -2,10 +2,10 @@ from .core import story, photo, reply, poem, crack, show # 从子模块导入
2
2
  from .magic_core import birthday # 从子模块导入函数到顶层
3
3
  from .bomb_core import bomb # 从子模块导入函数到顶层
4
4
  from .idiom_core import idiom, searchIdiom, get_json_path # 从子模块导入函数到顶层
5
- from .trial_class import make, get_file_content_as_base64, save_pic, detect_windows_scale, get_file_content_as_base64_2, cartoon # 从子模块导入函数到顶层
5
+ from .trial_class import make, get_file_content_as_base64, save_pic, detect_scale, open_image, get_file_content_as_base64_2, cartoon # 从子模块导入函数到顶层
6
6
  from .web_core import burger, cookbook # 从子模块导入函数到顶层
7
7
 
8
8
  __all__ = ["story", "photo", "reply", "poem", 'birthday', 'bomb',
9
9
  "idiom", "searchIdiom", "get_json_path", "crack", "show",
10
- "make", "get_file_content_as_base64", "save_pic", "detect_windows_scale",
10
+ "make", "get_file_content_as_base64", "save_pic", "detect_scale", "open_image",
11
11
  "get_file_content_as_base64_2", "cartoon", "burger", "cookbook"] # 可选:明确导出的内容
@@ -13,6 +13,9 @@ import cv2
13
13
  import numpy as np
14
14
 
15
15
  '''-----------体验课1-----------'''
16
+ import urllib.parse
17
+ import platform
18
+ from io import BytesIO
16
19
 
17
20
 
18
21
  def make(screen):
@@ -57,9 +60,8 @@ def make(screen):
57
60
  # 发送创建任务请求
58
61
  response = requests.post(create_url, headers=headers,
59
62
  data=create_payload.encode("utf-8"))
60
- response.raise_for_status() # 检查请求是否成功
63
+ response.raise_for_status()
61
64
  task_id = response.json()["data"]["task_id"]
62
- # print(f"任务已创建,ID: {task_id}")
63
65
 
64
66
  # 轮询检查任务状态
65
67
  query_payload = json.dumps({"task_id": task_id}, ensure_ascii=False)
@@ -71,16 +73,15 @@ def make(screen):
71
73
  query_url, headers=headers, data=query_payload.encode("utf-8"))
72
74
  response.raise_for_status()
73
75
  task_status = response.json()["data"]["task_status"]
74
- # print(f"任务状态: {task_status}")
75
76
 
76
77
  # 处理任务结果
77
78
  if task_status == "SUCCESS":
78
79
  picture = requests.get(response.json()[
79
- "data"]["sub_task_result_list"][0]["final_image_list"][0]["img_url"])
80
+ "data"]["sub_task_result_list"][0]["final_image_list"][0]["img_url"])
80
81
  image_data = BytesIO(picture.content)
81
82
  image = Image.open(image_data)
82
83
  image.save('image.gif')
83
- os.system("image.gif")
84
+ open_image("image.gif")
84
85
  else:
85
86
  print(f"任务失败,状态: {task_status}")
86
87
 
@@ -99,14 +100,31 @@ def get_file_content_as_base64(path, urlencoded=False):
99
100
  return content
100
101
 
101
102
 
103
+ def detect_scale():
104
+ """
105
+ 跨平台缩放比例检测
106
+ - Windows: 检测实际 DPI
107
+ - macOS/Linux: 默认返回 1.0
108
+ """
109
+ if platform.system() == "Windows":
110
+ try:
111
+ user32 = ctypes.windll.user32
112
+ user32.SetProcessDPIAware()
113
+ if hasattr(user32, 'GetDpiForSystem'):
114
+ dpi = user32.GetDpiForSystem()
115
+ return dpi / 96.0
116
+ screen_width = user32.GetSystemMetrics(0)
117
+ return screen_width / 1920.0
118
+ except Exception:
119
+ return 1.0
120
+ else:
121
+ return 1.0
122
+
123
+
102
124
  def save_pic(screen, output_file="pic.png"):
103
125
  """
104
126
  精准截取turtle绘图区域,不包含窗口边框和标题栏
105
- 专为Windows系统优化,支持高DPI缩放
106
-
107
- 参数:
108
- screen: turtle的Screen对象
109
- output_file: 输出文件名
127
+ 跨平台支持 (Windows/macOS/Linux)
110
128
  """
111
129
  canvas = screen.getcanvas()
112
130
  screen.update()
@@ -118,62 +136,48 @@ def save_pic(screen, output_file="pic.png"):
118
136
  width = canvas.winfo_width()
119
137
  height = canvas.winfo_height()
120
138
 
121
- # 检测Windows屏幕缩放比例
122
- scale_factor = detect_windows_scale()
123
- # print(f"检测到屏幕缩放比例: {scale_factor}x")
139
+ # 检测屏幕缩放比例
140
+ scale_factor = detect_scale()
124
141
 
125
- # 调整截图区域,排除窗口边框
126
- # 典型Windows窗口边框宽度约为8像素,标题栏约为30像素
127
- border_width = int(8 * scale_factor)
128
- title_height = int(30 * scale_factor)
142
+ # Windows 上要扣除边框和标题栏
143
+ border_width = int(
144
+ 8 * scale_factor) if platform.system() == "Windows" else 0
145
+ title_height = int(
146
+ 30 * scale_factor) if platform.system() == "Windows" else 0
129
147
 
130
148
  # 计算实际绘图区域
131
149
  img = ImageGrab.grab(
132
150
  bbox=(
133
- x + border_width, # 左边界,排除左侧边框
134
- y + title_height, # 上边界,排除标题栏和上边框
135
- x + width - border_width, # 右边界,排除右侧边框
136
- y + height - border_width # 下边界,排除底部边框
151
+ x + border_width,
152
+ y + title_height,
153
+ x + width - border_width,
154
+ y + height - border_width
137
155
  )
138
156
  )
139
157
 
140
- # 保存为PNG
141
158
  img.save(output_file)
142
- # print(f"已保存图形到 {output_file} (尺寸: {img.size})")
143
159
  except Exception as e:
144
160
  print(f"截图时出错: {e}")
145
- print("提示: 尝试使用save_turtle_canvas_fallback函数或手动截图")
161
+ print("提示: 可以尝试手动截图或使用其他方法")
146
162
 
147
163
 
148
- def detect_windows_scale():
164
+ def open_image(file_path):
149
165
  """
150
- 检测Windows系统的屏幕缩放比例
151
- 优先使用高精度方法,失败则降级使用兼容性方法
166
+ 跨平台打开图片
167
+ - Windows: os.startfile
168
+ - macOS: open
169
+ - Linux: xdg-open
152
170
  """
171
+ system = platform.system()
153
172
  try:
154
- # 高精度方法:获取系统DPI
155
- user32 = ctypes.windll.user32
156
- user32.SetProcessDPIAware()
157
-
158
- # 尝试获取系统DPI (Windows 8.1及以上)
159
- if hasattr(user32, 'GetDpiForSystem'):
160
- dpi = user32.GetDpiForSystem()
161
- return dpi / 96.0 # Windows标准DPI是96
162
-
163
- # 尝试获取显示器DPI (Windows 10及以上)
164
- if hasattr(user32, 'GetDpiForWindow'):
165
- root = tk.Tk()
166
- dpi = user32.GetDpiForWindow(root.winfo_id())
167
- root.destroy()
168
- return dpi / 96.0
169
-
170
- # 兼容方法:获取屏幕尺寸并与标准尺寸比较
171
- screen_width = user32.GetSystemMetrics(0)
172
- return screen_width / 1920.0 # 假设标准分辨率为1920x1080
173
+ if system == "Windows":
174
+ os.startfile(file_path)
175
+ elif system == "Darwin": # macOS
176
+ os.system(f"open {file_path}")
177
+ else: # Linux / 其他
178
+ os.system(f"xdg-open {file_path}")
173
179
  except Exception as e:
174
- print(f"检测缩放比例时出错: {e}")
175
- print("使用默认缩放比例1.0")
176
- return 1.0
180
+ print(f"打开图片失败: {e}")
177
181
 
178
182
 
179
183
  '''-----------体验课2-----------'''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.4.12
3
+ Version: 0.4.23
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
3
3
 
4
4
  setup(
5
5
  name="XMWAI", # 包名(pip install XMWAI)
6
- version="0.4.12", # 每次上传记得升级版本号
6
+ version="0.4.23", # 每次上传记得升级版本号
7
7
  author="pydevelopment", # 作者
8
8
  author_email="hekai@xiaoma.cn", # 邮箱
9
9
  description="Small code King AI related library", # 简短描述
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes