A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/tacaswell/mpl-qtthread below:

tacaswell/mpl-qtthread: An experimental backend to create Qt figures from background threads.

A Matplotlib backend for working with (Q)Threads and Qt

A minimal example:

import threading
import time
import matplotlib
import matplotlib.backends.backend_qt
import matplotlib.pyplot as plt

import mpl_qtthread

matplotlib.use("module://mpl_qtthread.backend_agg")

matplotlib.backends.backend_qt._create_qApp()

mpl_qtthread.monkeypatch_pyplot()

plt.ion()


def background():
    # time.sleep(1)
    fig, ax = plt.subplots()
    (ln,) = ax.plot(range(5))
    for j in range(5):
        print(f"starting to block {j}")
        ln.set_color(f"C{j}")
        ax.set_title(f'cycle {j}')
        fig.canvas.draw_idle()
        time.sleep(5)
    print("Done! please close the window")

threading.Thread(target=background).start()
matplotlib.backends.backend_qt.qApp.exec()

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4