I am building a GUI that is a heads-up display and in the background an animation is played.
The tool is supposed to read data from a text file that contains the information that will be displayed. Also, the animation is a library of images. Thus, each second the code looks at a line in the table and displays the information for that row as well as the image associated with that row.
I have implemented a possible solution to this particular need using Matplotlib. My issue is that once the code is ran, if I click anywhere on the screen, or try to open a new window while the loop is running, I get a "(Not Responding") status on the program toolbar
How can I prevent this issue from happening? Or are there better ways to implement this functionality? I has to be able to read a txt/csv file as well as render the images one after the other.
Here is a sample of the code:
import matplotlib.pyplot as plt
import numpy as np
import time
from scipy.misc import imread
import matplotlib.cbook as cbook
import pandas as pd
from pylab import *
#Open file with information for HUD
filename = "data.txt"
rndz_data = pd.read_table(filename, sep="\s+")
frames = np.arange(5)
plt.ion()
fig = plt.figure()
#Create array of image files
datafile = [cbook.get_sample_data('rndz0000.png'),
cbook.get_sample_data('rndz0001.png'),
cbook.get_sample_data('rndz0002.png'),
cbook.get_sample_data('rndz0003.png'),
cbook.get_sample_data('rndz0004.png')]
#Create plot and animate
for i in frames:
img = imread(datafile[i])
plt.clf()
plt.imshow(img, zorder=0, extent=[0.5, 8.0, 1.0, 7.0])
plt.plot
plt.draw()
time.sleep(1)