Embedding Matplotlib in a GUI made with Qt Designer
For simple examples, designing the GUI in the Python code can be good enough, but for more complex applications, this solution does not scale.
There are some tools to help you design the GUI for Qt, and one of the most commonly used is Qt Designer.
Similar to Glade, we can design the user interface part of the application using on-screen form and drag-and-drop interface. Then we can connect the widgets with the backend code, where we develop the logic of the application.
The core of our example application will be plotting the frequencies of occurrences of letters in a text file: we will count the number of times each letter of the English alphabet appears in a given file and then plot this information in a bar graph.
First, we will show how to design our GUI with Qt Designer, in particular, how to create a custom Matplotlib widget managed by an external Python source file. Then, we will convert that GUI into a Python code that we can use...