ezicon 1.0.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.
- ezicon-1.0.0/PKG-INFO +23 -0
- ezicon-1.0.0/README.md +7 -0
- ezicon-1.0.0/ezicon.egg-info/PKG-INFO +23 -0
- ezicon-1.0.0/ezicon.egg-info/SOURCES.txt +9 -0
- ezicon-1.0.0/ezicon.egg-info/dependency_links.txt +1 -0
- ezicon-1.0.0/ezicon.egg-info/entry_points.txt +2 -0
- ezicon-1.0.0/ezicon.egg-info/requires.txt +1 -0
- ezicon-1.0.0/ezicon.egg-info/top_level.txt +1 -0
- ezicon-1.0.0/ezicon.py +166 -0
- ezicon-1.0.0/setup.cfg +4 -0
- ezicon-1.0.0/setup.py +24 -0
ezicon-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ezicon
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Create Windows Start Menu shortcuts for Python scripts instantly.
|
|
5
|
+
Author: gusta01010
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: pywin32
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: classifier
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: description-content-type
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: summary
|
|
16
|
+
|
|
17
|
+
# pylnk
|
|
18
|
+
|
|
19
|
+
A simple tool to create Windows Start Menu shortcuts for Python scripts.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
```bash
|
|
23
|
+
pip install pylnk-tool
|
ezicon-1.0.0/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ezicon
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Create Windows Start Menu shortcuts for Python scripts instantly.
|
|
5
|
+
Author: gusta01010
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: pywin32
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: classifier
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: description-content-type
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: summary
|
|
16
|
+
|
|
17
|
+
# pylnk
|
|
18
|
+
|
|
19
|
+
A simple tool to create Windows Start Menu shortcuts for Python scripts.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
```bash
|
|
23
|
+
pip install pylnk-tool
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pywin32
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ezicon
|
ezicon-1.0.0/ezicon.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import argparse
|
|
4
|
+
import win32com.client
|
|
5
|
+
import glob
|
|
6
|
+
|
|
7
|
+
# This tag identifies shortcuts created by this tool
|
|
8
|
+
EZICON_TAG = "Created by ezicon"
|
|
9
|
+
|
|
10
|
+
def is_gui_application(file_path):
|
|
11
|
+
if file_path.lower().endswith('.pyw'):
|
|
12
|
+
return True
|
|
13
|
+
try:
|
|
14
|
+
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
|
|
15
|
+
content = f.read().lower()
|
|
16
|
+
if 'tkinter' in content or 'from tkinter' in content:
|
|
17
|
+
return True
|
|
18
|
+
except Exception:
|
|
19
|
+
pass
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
def get_start_menu_path():
|
|
23
|
+
return os.path.join(os.environ['APPDATA'], r"Microsoft\Windows\Start Menu\Programs")
|
|
24
|
+
|
|
25
|
+
def create_link(target_script_path, custom_name=None, icon_path=None):
|
|
26
|
+
target_script = os.path.abspath(target_script_path)
|
|
27
|
+
|
|
28
|
+
if not os.path.exists(target_script):
|
|
29
|
+
print(f"Error: File '{target_script}' not found.")
|
|
30
|
+
return
|
|
31
|
+
|
|
32
|
+
# Validate icon file if provided
|
|
33
|
+
if icon_path:
|
|
34
|
+
icon_path = os.path.abspath(icon_path)
|
|
35
|
+
if not os.path.exists(icon_path):
|
|
36
|
+
print(f"Error: Icon file '{icon_path}' not found.")
|
|
37
|
+
return
|
|
38
|
+
if not icon_path.lower().endswith('.ico'):
|
|
39
|
+
print(f"Error: Icon file must be a .ico file, got '{os.path.splitext(icon_path)[1]}'")
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
if custom_name:
|
|
43
|
+
script_name = custom_name
|
|
44
|
+
else:
|
|
45
|
+
script_name = os.path.splitext(os.path.basename(target_script))[0]
|
|
46
|
+
|
|
47
|
+
start_menu = get_start_menu_path()
|
|
48
|
+
shortcut_path = os.path.join(start_menu, f"{script_name}.lnk")
|
|
49
|
+
|
|
50
|
+
# Check if shortcut already exists
|
|
51
|
+
if os.path.exists(shortcut_path):
|
|
52
|
+
while True:
|
|
53
|
+
choice = input(f"Shortcut '{script_name}.lnk' already exists. Overwrite? (y/n): ").lower()
|
|
54
|
+
if choice in ['n', 'no']:
|
|
55
|
+
print("Operation cancelled.")
|
|
56
|
+
return
|
|
57
|
+
if choice in ['y', 'yes']:
|
|
58
|
+
break
|
|
59
|
+
|
|
60
|
+
python_dir = os.path.dirname(sys.executable)
|
|
61
|
+
|
|
62
|
+
# GUI Detection
|
|
63
|
+
if is_gui_application(target_script):
|
|
64
|
+
print(f"Detected GUI/Tkinter in '{script_name}': Hiding console window...")
|
|
65
|
+
python_exe = os.path.join(python_dir, "pythonw.exe")
|
|
66
|
+
else:
|
|
67
|
+
print(f"Detected Console App in '{script_name}': Keeping console window...")
|
|
68
|
+
python_exe = sys.executable
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
shell = win32com.client.Dispatch("WScript.Shell")
|
|
72
|
+
shortcut = shell.CreateShortCut(shortcut_path)
|
|
73
|
+
|
|
74
|
+
shortcut.Targetpath = python_exe
|
|
75
|
+
shortcut.Arguments = f'"{target_script}"'
|
|
76
|
+
shortcut.WorkingDirectory = os.path.dirname(target_script)
|
|
77
|
+
shortcut.IconLocation = icon_path if icon_path else sys.executable
|
|
78
|
+
|
|
79
|
+
# --- IMPORTANT: Tag the shortcut so we can clean it later ---
|
|
80
|
+
shortcut.Description = EZICON_TAG
|
|
81
|
+
# -----------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
shortcut.save()
|
|
84
|
+
print(f"Success! Shortcut created: '{script_name}'")
|
|
85
|
+
print(f"Location: {shortcut_path}")
|
|
86
|
+
|
|
87
|
+
except Exception as e:
|
|
88
|
+
print(f"Error creating shortcut: {e}")
|
|
89
|
+
|
|
90
|
+
def clean_shortcuts():
|
|
91
|
+
"""Scans start menu for shortcuts with the PyIcon tag and asks to delete them."""
|
|
92
|
+
start_menu = get_start_menu_path()
|
|
93
|
+
shell = win32com.client.Dispatch("WScript.Shell")
|
|
94
|
+
|
|
95
|
+
found_shortcuts = []
|
|
96
|
+
|
|
97
|
+
print(f"Scanning {start_menu} for ezicon shortcuts...")
|
|
98
|
+
|
|
99
|
+
# Iterate over all .lnk files in the directory
|
|
100
|
+
for file_path in glob.glob(os.path.join(start_menu, "*.lnk")):
|
|
101
|
+
try:
|
|
102
|
+
shortcut = shell.CreateShortCut(file_path)
|
|
103
|
+
# Check the metadata tag
|
|
104
|
+
if shortcut.Description == EZICON_TAG:
|
|
105
|
+
found_shortcuts.append(file_path)
|
|
106
|
+
except Exception:
|
|
107
|
+
continue
|
|
108
|
+
|
|
109
|
+
if not found_shortcuts:
|
|
110
|
+
print("No ezicon shortcuts found to clean.")
|
|
111
|
+
return
|
|
112
|
+
|
|
113
|
+
print(f"\nFound {len(found_shortcuts)} shortcut(s) created by ezicon:")
|
|
114
|
+
for sc in found_shortcuts:
|
|
115
|
+
print(f" - {os.path.basename(sc)}")
|
|
116
|
+
|
|
117
|
+
# Confirmation Prompt
|
|
118
|
+
while True:
|
|
119
|
+
choice = input("\nAre you sure you want to delete these icons? (y/n): ").lower()
|
|
120
|
+
if choice in ['y', 'yes']:
|
|
121
|
+
count = 0
|
|
122
|
+
for sc in found_shortcuts:
|
|
123
|
+
try:
|
|
124
|
+
os.remove(sc)
|
|
125
|
+
count += 1
|
|
126
|
+
except Exception as e:
|
|
127
|
+
print(f"Failed to delete {os.path.basename(sc)}: {e}")
|
|
128
|
+
print(f"\nClean up complete. Deleted {count} icons.")
|
|
129
|
+
break
|
|
130
|
+
elif choice in ['n', 'no']:
|
|
131
|
+
print("Operation cancelled.")
|
|
132
|
+
break
|
|
133
|
+
|
|
134
|
+
def main():
|
|
135
|
+
parser = argparse.ArgumentParser(description="Create or clean Windows Start Menu shortcuts for Python scripts.")
|
|
136
|
+
|
|
137
|
+
# Flags
|
|
138
|
+
parser.add_argument("--clean", action="store_true", help="Remove all icons created by this tool")
|
|
139
|
+
parser.add_argument("-f", "--file", help="Path to the python file")
|
|
140
|
+
parser.add_argument("-n", "--name", help="Custom name for the shortcut icon")
|
|
141
|
+
parser.add_argument("-i", "--icon", help="Path to a .ico file for the shortcut icon")
|
|
142
|
+
|
|
143
|
+
# Positionals
|
|
144
|
+
parser.add_argument("pos_file", nargs='?', help="Path to the python file (positional)")
|
|
145
|
+
parser.add_argument("pos_name", nargs='?', help="Custom name for the shortcut icon (positional)")
|
|
146
|
+
|
|
147
|
+
args = parser.parse_args()
|
|
148
|
+
|
|
149
|
+
# Priority 1: Cleaning
|
|
150
|
+
if args.clean:
|
|
151
|
+
clean_shortcuts()
|
|
152
|
+
return
|
|
153
|
+
|
|
154
|
+
# Priority 2: Creating
|
|
155
|
+
target_file = args.file if args.file else args.pos_file
|
|
156
|
+
target_name = args.name if args.name else args.pos_name
|
|
157
|
+
icon_file = args.icon
|
|
158
|
+
|
|
159
|
+
if not target_file:
|
|
160
|
+
parser.print_help()
|
|
161
|
+
return
|
|
162
|
+
|
|
163
|
+
create_link(target_file, target_name, icon_file)
|
|
164
|
+
|
|
165
|
+
if __name__ == "__main__":
|
|
166
|
+
main()
|
ezicon-1.0.0/setup.cfg
ADDED
ezicon-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="ezicon", # <--- The Install Name
|
|
8
|
+
version="1.0.0",
|
|
9
|
+
author="gusta01010",
|
|
10
|
+
description="Create Windows Start Menu shortcuts for Python scripts instantly.",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type="text/markdown",
|
|
13
|
+
py_modules=["ezicon"], # Matches the filename 'pylnk.py'
|
|
14
|
+
install_requires=["pywin32"], # Auto-installs dependency
|
|
15
|
+
classifiers=[
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Operating System :: Microsoft :: Windows",
|
|
18
|
+
],
|
|
19
|
+
entry_points={
|
|
20
|
+
"console_scripts": [
|
|
21
|
+
"ezicon=ezicon:main", # <--- The Command (Type 'pylnk' to run)
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
)
|