I try to read some images (and later intend to do some kind of task for them), and so far the images are read in memory. I want to display an animated .gif image. For this I had to use Threads. Now it gives an error:
python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
And several times this gives an error:
python: Fatal IO error 0 (Success) on X server :0.0.
(Yes. The error message changes almost in turn) I do not know why this error occurred and how to remove it.
import wx from wx import animate import thread import os class AniGif(wx.Dialog): def __init__(self, parent, id, title): wx.Dialog.__init__(self, parent, id, title, size=(300, 300)) buttonOk = wx.Button(self, id=3, label="Ok", pos=(75, 50), size=(50, 50)) self.Bind(wx.EVT_BUTTON, self.OnClick, id=3) def OnClick(self, event) : clock = "loading.gif" showclock = wx.animate.GIFAnimationCtrl(self, -1, clock) showclock.Play() thread.start_new_thread(grabImages, ( )) def grabImages(): global dirim dirim = {} path = './images/soccer/' listing = os.listdir(path) for infile in listing: if len(infile)>4 and infile[-4:]=='.jpg' : print path+infile dirim[infile]=wx.Bitmap(path+infile) app = wx.App() dia = AniGif(None, -1, "Ani Gif") dia.ShowModal() dia.Destroy() app.MainLoop()
if i replace this line
dirim[infile]=wx.Bitmap(path+infile)
with dummy line:
dirim[infile]=infile
It works fine, no error.
And if I replace this line
thread.start_new_thread(grabImages, ( ))
with something like:
grabImages()
It works great, No Error. Only problem: I cannot display an animated gif, then ..
I tried to remove ~ / .gconf / desktop / gnome / peripherals as indicated in the link provided by joaquin . This does not work. and I also tried xhost +. I found it from somewhere on the net. Still no success.
Tell what happens in this code .. and suggest a solution. I am using ubuntu 10.04 OS. And directory rights:
drwxr-xr-x images drwxr-xr-x soccer
Python verion details: Python 2.6.5 (r265: 79063, 04.16.2010, 13:09:56) [GCC 4.4.3] on linux2