Skip to main content

EasyPlotGUI

Python library that makes it easy to have a Qt GUI with a matplotlib widget made in QtDesigner implemented on a script.

Installation

pip install EasyPlotGUI

Easy implementation process

  1. Create GUI on QtDesigner based on mpl_gui.ui
  2. Compile your ui to Python with pyuic5 ./your_file.ui -o ./your_ui.py
  3. Import EasyPlotGUI as parent class (see example of usage)
  4. Overwrite update_graph() with graph to be generated; and update_interactivity() with GUI elements interaction

Check out the example on ./example.py.

QtDesigner

Installation with pip

QtDesigner is a Graphical tool for creating Guided User Interfaces that can either be downloaded with Qt Creator or with the library pyqt5-tools.

Lightest and fastest way to get QtDesigner is to install pyqt5-tools. For this, execute:

pip install pyqt5-tools

After the installation, the designer.exe executable should be found in:

Python3X\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe

I suggest creating a shortcut for it, for easier execution or adding the folder to the path, so that it can be called as just designer from the terminal/shell.

UI with Matplotlib Creation

Use the mpl_gui.ui file on QtDesigner as a starting point for the GUI with Matplotlib integrated. Just keep in mind that the names of every object added to the User Interface are those you will have to call on the Python script.

The only important thing in this .ui file is the MplWidget object. The MplWidget is the widget created to link matplotlib to Qt. Do not delete it.

Example output

Step by step - Creating a User Interface

1. Create a new file (MainWindow) on Qt Designer

alt

2. Add a QWidget to it

alt

3. Promote the widget to MplWidget

Right click on the widget that was just added and click on Promote to... . The class name has to be MplWidget and the header file EasyPlotGUI so that the Python script can link it. Click on Add to add the new promoted class, then select it and click on Promote.

alt

4. Add your UI elements

Add the desired element. The name of the elemen (mySlider in the example) is what you'll call in your class (self.ui.mySlider.value() gives the value of the slider).

alt

Now save the file. It should have a .ui extension.

5. Compile the .ui into a .py

pyuic5 ./your_file.ui -o ./your_ui.py

6. Import it in your class

from EasyPlotGUI import EasyPlotGUI
import your_ui

import numpy as np

class MyClass(EasyPlotGUI):
    def __init__(self):
        super().__init__(your_ui)
        self.window_title = "My GUI Name"
        self.icon_path = "logo.png"

        # initialize Graph variables for first plot
        self.f = 1

    def update_interactivity(self):
        self.ui.mySlider.valueChanged.connect(self.change_frequency)

    def change_frequency(self):
        self.f = self.ui.mySlider.value()
        self.update_graph()

    def update_graph(self):
        x = np.linspace(0, 1)
        y = np.sin(2*np.pi*self.f*x)

        self.ax.clear()
        self.ax.plot(x, y, label="Sine")
        self.ax.legend()
        self.ax.set_title('Sine Wave')
        self.draw()

    # calling it
if __name__ == "__main__":
    my_gui=MyClass()
    my_gui.show_gui()

Metadata

Release files for EasyPlotGUI 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for EasyPlotGUI 0.1.3
File Size Uploaded
EasyPlotGUI-0.1.3.tar.gz 4.2 kB Details

Release files / EasyPlotGUI-0.1.3.tar.gz

Download URL EasyPlotGUI-0.1.3.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1bfeb3aa5106502cd8a86725c087a690dac195ee1783062d66dc7a9695f8d843
BLAKE2b-256 checksum
How to use checksums
9cc2e2d66d85bfac239389aa2153ccfeda89b01b5224e6c76c2707b2b78f6370
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page