Opening PyQtGraph, then closing immediately

I have the base code from the documentation

import pyqtgraph as pg
import numpy as np
x = np.arange(1000)
y = np.random.normal(size=(3, 1000))
plotWidget = pg.plot(title="Three plot curves")
for i in range(3):
    plotWidget.plot(x, y[i], pen=(i,3))

But for some reason, the window opens and then closes right away, I just see a flicker. Is there any function in which I can leave the window open?

thank

+4
source share
2 answers

The problem is that the Python process ends after the last iteration of the loop, forand therefore also terminates with widgets. You can use the switch -ito enter an interactive Python interpreter after executing a script that saves all the objects that were created during the execution of the script:

python -i /path/to/script.py

, , pyqtgraph, , "" (, show matplotlib.pyplot ), pyqtgraph.

+2

a_guest - Pycharm goto: Run → Edit Configurations → Interpreter Options. -i .

0

Source: https://habr.com/ru/post/1679640/


All Articles