카테고리 없음

Github Screnshot Apps Macos

vilucbalramoehis 2021. 2. 28. 15:22
make-chrome-app.sh
#!/bin/sh
# wget https://gist.githubusercontent.com/stefansundin/c89fd15bae5a58831790/raw/make-chrome-app.sh
# chmod +x make-chrome-app.sh
# ./make-chrome-app.sh
echo'Note that the app will run with a separate data dir and thus not have your regular extensions and settings.'
echo
echo'What should the app be called?'
read name
echo
if [ -d'$HOME/Applications/$name.app' ];then
echo'That app already exists.'
exit 1
fi
echo'What is the url?'
read url
echo
echo'What is the full path to the icon? (optional)'
read icon
chrome='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
app='$HOME/Applications/$name.app/Contents'
mkdir -p '$app/Resources''$app/MacOS''$app/Profile'
# convert the icon
if [ -f$icon ];then
sips -s format tiff $icon --out '$app/Resources/icon.tiff' --resampleWidth 128 &> /dev/null
tiff2icns -noLarge '$app/Resources/icon.tiff'&> /dev/null
fi
# create the executable
cat >'$app/MacOS/$name'<<EOF
#!/bin/sh
exec '$chrome' --app='$url' --user-data-dir='$app/Profile' --disable-save-password-bubble '$@'
EOF
chmod +x '$app/MacOS/$name'
# create Info.plist
cat >'$app/Info.plist'<<EOF
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>CFBundleExecutable</key>
<string>$name</string>
<key>CFBundleIconFile</key>
<string>icon</string>
</dict>
</plist>
EOF
# disable Chrome's first-run dialog
touch '$app/Profile/First Run'
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

We will explore the use of PyInstaller to create a cross-platform standalone application using python. For this tutorial I will be using Tkinter to visually demonstrate.

Built in screenshot editor. ScreenCloud uses the CMake build system, start off by downloading the appropriate version for your OS from the CMake website or your distro's repositories. After installing CMake, choose the OS you're compiling on from the the list below: Compiling on Ubuntu; Compiling on Mac OS X; Compiling on Windows. Description of Change Screenshot for macOS I thought it would be easy. Hours later after testing with CGWindowListCreateImage and much more (CGImage.ScreenImage), this is the only way I can find out. Documentation By default only the app windows are visible. But macOS is asking to set the permission in the settings. The security setting have to be enabled to get all apps on screen. As of January 2020, all apps running on macOs 10.15 Catalina are required to be notarized. For Unity games distributed outside the Mac App Store, such as with Steam, the notarization process is done post build using a series of Xcode command line tools. A Mac that is compatible with macOs 10.15 Catalina: MacBook (2015 or newer).

PyInstaller can be used in Python3 and Python2, similarly it creates applications for MacOS, Windows, and Linux.

Mac Github Desktop

I will be using:

  • Python 3
  • MacOS 10.12.6
  • PyInstaller 3.5

N.B. - Currently Python 3 has issues with importing a compatible version of tcl on MacOS, however the below describes a method that works around this.

Setup

PyInstaller runs from within the terminal, from here we will install PyInstaller, create a working directory, and cd to it.

Write your python script

This will vary depending on your task, below I will demonstrate visually by creating a tkinter app.

If needed: pip install tkinter.

Save the below tkinter app as DogsGo.py.

Run the above $ python DogsGo.py or from within python.

You should have generated an app that shows:

N.B. Python 2 uses import Tkinter and Python 3 import tkinter.

Build the application

Before we build the application you should first understand flags, these are settings which you apply at the time of building. In many cases these can be applied after, however many are easiest to add at the point of build. For this example I will describe two, however more can be found here.

-w, –windowed, –noconsole - Prevents terminal from appearing when app is opened.

Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS X this also triggers building an OS X .app bundle. On Windows this option will be set if the first script is a ‘.pyw’ file. This option is ignored in *NIX systems.

-F, –onefile - App is bundled into a single file.

Create a one-file bundled executable.

If you are a MacOS user don’t use –onefile, I’ll elaborate below.

Windows and Linux

Once the build is complete, navigate to dist and run the DogsGo application. Or:

*change extension and path depending on OS.

MacOS

Currently the pyinstaller build on MacOS uses an incompatible version of tcl, resulting in the app immediately crashing when it opens (i.e. if you follow the above). Below is a method which allows the application to be opened by editing the init.tcl file. I have written a python script which makes these changes.

The build will be created however the Contents of the application will remain as separate files. Clone the TCLChanger.py from my git repository and run in the same working directory as your original python script.

Or download the file if you don’t use git :’(

You should now be able to open the application.

Exploring .spec and adding an icon

Adding an application icon can be done using the flag --icon=icon-name.icns during the build, however we will use this as an oppertunity to delve into the .spec file that has been generated.

Apps

Opening DogsGo.spec will show a number of settings we can update, for the application icon we want to update exe = EXE(...) and app = BUNDLE(...).

Let us update the icon to dog.icns, don’t forget to rename it dog.icns and copy it to your current directory.

exe = EXE(…)

Add icon='dog.icns'.

app = BUNDLE()

Change icon=None to icon='dog.icns'.

Now that DogsGo.spec has been updated, run the pyinstaller for the DogsGo.spec.

MacOS users, remember to run$ python TCLChanger.pyagain

Final Note

Download Github App

That’s it! You will now be able to transfer the standalone application and use it.

woof.

Install Github Mac

Apps

Helpful links

Github Ios App

  • Pyinstaller Manual: https://pyinstaller.readthedocs.io/en/stable/index.html
  • TKDocsL: https://tkdocs.com/index.html
  • PyInstaller repository: https://github.com/pyinstaller/pyinstaller
  • TCLChanger Repository: https://github.com/jacob-brown/TCLChanger