-
-
Notifications
You must be signed in to change notification settings - Fork 1
Shortcut MacOS
Tip: As of
moleditpy-installerv3.0, runningmoleditpy-installerbuilds and signs aMoleditPy.applauncher for you (in~/Applications, or/Applicationswith--system), including the.pmeprjdocument type/icon and Launch Services registration. It also correctly pairs the launcher with the Python interpreter of its own environment, which the manual Automator method below cannot do automatically. See Installation for macOS. Use the manual steps below only if you want to build the.appby hand.
This guide explains how to make a Python app installed with pip install moleditpy runnable as a .app application on macOS and how to set a custom icon.
The executable file (binary) is typically located at a path like this:
/Users/<username>/Library/Python/<python_version>/bin/moleditpy
- Open Automator
- Select "New Document" → "Application"
- From the list on the left, add "Utilities" → "Run Shell Script"
Enter the following into the script area:
#!/bin/bash
/Users/<username>/Library/Python/<python_version>/bin/moleditpy "$@"Note:
"$@"is used to pass arguments, such as files that are dragged and dropped onto the app icon.
- From the menu, select "File" → "Save"
- Name it
moleditpy.app - You can temporarily save it to your Desktop or any other location.
After saving, copy the created app to the system's main Applications folder.
- Select
moleditpy.appin Finder - Press
⌘ + Cto copy - From the Finder menu, click "Go" → "Applications"
- Press
⌘ + Vto paste
sudo cp -R ~/Desktop/moleditpy.app /Applications/You may be prompted to enter your password when running
sudo.
Location of the icon image:
/Users/<username>/Library/Python/<python_version>/lib/python<python_version>/site-packages/moleditpy/assets/icon.png
- Open the
icon.pngfile from the path above in Finder. - With the image open in the "Preview" app:
- Press
⌘ + Ato select all. - Press
⌘ + Cto copy.
- Press
- In Finder, select
moleditpy.appin the/Applicationsfolder and press⌘ + I(Get Info). - Click the small icon in the top-left corner (a border will appear) and press
⌘ + Vto paste.
This will change the app's icon.
# Convert PNG to ICNS
iconutil -c icns /path/to/icon.iconset
# Apply to the app
cp /path/to/icon.icns /Applications/MyTool.app/Contents/Resources/app.icnsNote: iconutil is a standard command on macOS. You can create an icon.iconset directory as follows:
mkdir icon.iconset
cp icon.png icon.iconset/icon_512x512.png
iconutil -c icns icon.iconsetIf the application fails to launch, run the following command:
chmod +x /Users/<username>/Library/Python/<python_version>/bin/moleditpyYou can now run the Python app simply by double-clicking moleditpy.app located in your /Applications folder.
-
Installation for macOS — the
moleditpy-installerroute that automates all of this - Shortcut for Windows / Linux
- Keyboard Shortcuts