Any recommendation for the GUI toolkit du jour? What plays nicely with Matplotlib, can be easily installed using miniconda, and has Python user community 'momentum' behind it?
Matplotlib has
backends for most windowing toolkits, including both
agg and
cairo subtypes for Qt, Gtk+, wxWidgets/wxPython, and tkinter (tk).
All four have lots of Python users, but in my opinion, right now (as of 2021) Python 3 + Qt 5 gives the best tools for this stuff. However, I've never been one to consider 'popularity' or 'momentum', and my opinion is weighed by my own personal preferences, and may have zero value for you because your preferences and needs likely differ.
(Python3+Qt5 does suffer from the fact that there are two separate sets of bindings, python3-pyqt5 (PyQt5) and python3-pyside2 (PySide2), and making a Python program compatible at run time with either one takes a few lines of extra Python code (a bit more if you use .ui files), and a bit of consideration how one uses the Qt5 namespaces –– Qt, QtCore, QtGui, QtWidgets, and QtSvg.)
The tkinter (tk) backend has the fewest dependencies, and is the easiest to get working.
For a fellow scientist who isn't interested in programming per se, but needs to to make better tools for themselves, I'd recommend starting with Python3 and matplotlib, and use the tk/tkinter UI built in to Python (and supported by matplotlib). Then, if and only if the UI widgets just don't cut it anymore, look into the other toolkits.
Doing a web search for
"matplotlib" "tkinter" shows lots of examples and tutorials; and the matplotlib site itself lists a few
tutorials. One needs to trawl through to find the ones best suited for oneself. Note that matplotlib itself provides simple toolkit-agnostic
widgets you can use if you want matplotlib to automatically use the best/first toolkit that is available!
(The
textbox example does not mention, unfortunately, that one can provide a dictionary of variables and functions the textbox can utilize to the
Python eval() function. If that dictionary contains
'__builtins__':None, then built-ins like "open()" and import facilities cannot be used, only the objects in the global and local dictionaries supplied. In other words, it's rather easy to include all
math functions (without any prefix), some named constants, and
'__builtins__':None in the global dictionary, the current values of the variables in the local dictionary, and repeatedly evaluate the (possibly compiled, for speed!) expression safely in Python. A crafty person can even create their own local dictionary class object, overriding
__getattr__ method, to auto-detect what variables the expression uses. Lots of options and power for not much effort!)
In all toolkits, there is a common theme: event-based programming.
Essentially, when you construct your window or windows, you pass control to the toolkit. The toolkit manages everything, and calls back to your code whenever something interesting happens. To construct a widget showing an interactive plot, you usually initially tell matplotlib which backend you want to use, and then either pass the widget matplotlib should draw into, or create a "canvas" or figure in matplotlib, and display that in some interactive widget. Understanding this model, and accepting "loss of full control" by passing the control to the widget toolkit, seems to be the biggest issue among those new to this kind of programming, in my experience!