I needed to quickly build a simple GUI for administering systems, and I wanted to try out PySimpleGUI. It sits on top of other packages such as Tkinter and PyQt — which needs to be compiled into Python to use it.
For development, I tend to use pyenv and Docker, where as the latter is also what I use for deployment. On Linux you can tie Docker to X11 fairly easily, but there’s no clear way for tying Docker to OS X’s Aqua, and the closest would be using socat to bridge Docker to X11 under OS X.
Prerequisites
- Homebrew
- pyenv
- Installer
- Install with Homebrew:
brew install pyenv
Implementation
Install TCL/TK Headers:
brew install tcl-tk
Compile TCL/TK Headers with the latest version of Python under pyenv:
latestTclTk='8.6'
latestPython=`pyenv install --list | sed -e 's/^[[:space:]]*//' | grep --regexp '^[0-9]\.[0-9][\.0-9]*$' | (gsort --version-sort 2>/dev/null || sort --version-sort) | tail -n 1`
PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl${latestTclTk} -ltk${latestTclTk}'" pyenv install ${latestPython}
Create a virtual environment and install PySimpleGUI into it:
pyenv ${latestPython} myGUIenv
mkdir --parents --verbose ~/myGUIproject
cd $_
pyenv local myGUIenv
pip install PySimpleGUI
External links
- pyenv issues : How do I pass custom configure when using pyenv install?
- pyenv issues : pyenv install doesn’t work with homebrew installed tcl-tk : Graham.Annett solution
Did this article save you time or money? I'd love a coffee!
Did you find this useful?
Please share with those who you believe would find this useful too!