pyGUI & wake a sleeping Mac example.

A more modern way running on Python 3.x. The original post is old!

Note: Create a virtual environment so all your libraries stay separated from the Python included in OS X.

There are a couple ways to do this. One way is to install Brew, then install Python and required libs, including Python Virtual Environment. You can also use the installer from Python.org and point to your installed version and install Virtual Environments with python3 -m venv .venv in the terminal. It has been years since I have run a Mac, but I liked iTerm2.

Stick with 3.x and avoid Python 2.x. It’s mentioned occasionally, but it is old and no longer supported as of Jan. 2020.

Brew route

https://brew.sh

https://docs.brew.sh/Homebrew-and-Python

GUI’s

Here is a GUI that is simple and cross platform. It is installed via pip.

https://beeware.org/project/toga

I do believe this used to be the GUI I used. It is now DearPyGUI. The code may or may not be the same.

You could use Tkinter, but that might be more involved on Mac. Kivvy is great, but also more complex. Flet is really easy and solid, but I have not used it on Mac. Flet is installed via pip. I see no reason for Flet not to work.

This library will do he actual wake on LAN so you don’t need to write a lot of code yourself. Installed via pip.

https://pypi.org/project/wakeonlan

This library will package your program as a Mac App. Installed via pip.

https://pypi.org/project/py2app

A little reading and you should be on your way.

Original post below…

I started playing around with pyGUI a year or two ago, which allows fast gui development on OS X, Windows, and Linux from Python. I wrote a little app to wake up Macs awhile back and packaged it as a standard Mac bundle. In theory the raw Python should run on Windows, but be aware that it utilizes arp.

This pyGUI app will wake a sleeping Macintosh with either an IP or MAC address. This is a very simple example of a basic window, textbox, and button in pyGUI.

Download WakeUp . Includes source and is public domain. Special thanks to Ocal who created the coffee cup icon I used.

Packaging a pyGUI Script On Mac.

If you’re unsure of how to package a Python App Bundle I’ll walk you through it now.

Install XCode. Create your Python program.

Right click your script and select Open With, Build Applet.App. Python version 2.6 would not work with pyGUI so I selected 2.5.

Now you need to right click your new app bundle and select Show Package Contents. Drill down into Resources folder. Copy the GUI folder in the pyGUI (I keep the pyGUI download handy on my desktop) lib and paste it into Resources.

Your app should run with a GUI now since it has the pyGUI libraries available.

To change the icon, just get an icon you like and use Icon Composer, which is in Utilities in the Development folder. Drag the image into the box and save as the same name as the icns in Resources in the app bundle. Copy over it and you’re set.

I have not tested bundling on Lion, but the bundled apps run fine.