![](/img/trans.png)
[英]XIO: fatal IO error 11 (Resource temporarily unavailable) on X server “:0” after 235 requests (235 known processed) with 0 events remaining
[英]python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0
我正在嘗試閱讀一些圖像(后來打算對它們執行某些任務),同時將圖像讀入內存。 我想顯示一個動畫的'.gif'圖片。 為此我不得不使用Threads。 現在它給出錯誤:
python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
有時它會給出錯誤:
python: Fatal IO error 0 (Success) on X server :0.0.
(是錯誤消息幾乎交替更改)我不知道為什么會發生此錯誤以及如何刪除它。
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()
如果我更換這條線
dirim[infile]=wx.Bitmap(path+infile)
用虛線:
dirim[infile]=infile
它工作正常,沒有錯誤。
如果我更換這條線
thread.start_new_thread(grabImages, ( ))
用這樣的東西:
grabImages()
它工作正常,沒有錯誤。 唯一的問題我無法顯示動畫gif然后..
我試圖刪除〜/ .gconf中/桌面/ GNOME /外圍設備如提到的鏈接通過給華金 。 它不起作用..我也試過'xhost +'。 我從網上的某個地方找到了。 仍然沒有成功。
請告訴我們這段代碼中發生了什么..並建議我使用ubuntu 10.04操作系統的解決方案。 目錄權限是:
drwxr-xr-x images
drwxr-xr-x soccer
Python verion的細節是:關於linux2的Python 2.6.5(r265:79063,2010年4月16日,13:09:56)[GCC 4.4.3]
你的代碼在win7中非常適合我,wxpython 2.8.12.1和python 2.6.7運行在Spe版本0.8.4.i上,當圖像位於腳本目錄中時(我使用了我自己的動畫gif和png)。
除了wx和use之外,我需要的唯一更改是導入animate( from wx import animate
)
showclock = animate.GIFAnimationCtrl(self, -1, clock)
代替
showclock = wx.animate.GIFAnimationCtrl(self, -1, clock)
編輯:有幾個人在這里和這里和這里有同樣的錯誤消息。 最后一個讓我覺得它可能與在linux中使用帶有gui框架的線程有關 ( 另見相關內容 )。 你應該谷歌錯誤字符串,以查看是否可以獲得更多信息或在錯誤字符串作為主題的SO上詢問特定問題。 UF! 已經有一個了 !
不知道它是否與您的問題有關,但您應該在創建wxApp之后實例化對話框並調用其ShowModal:
class App(wx.App):
def OnInit(self):
dia = AniGif(None, -1, "Ani Gif")
try:
dia.ShowModal()
finally:
dia.Destroy()
return True
App(0).MainLoop()
==編輯==
我沒有看到你從另一個線程實例化了一個wx.Bitmap。 這不好。 試試這個:
def grabImages():
global dirim
dirim = {}
def addToDict(key, path):
dirim[key] = wx.Bitmap(path)
path = './images/soccer/'
listing = os.listdir(path)
for infile in listing:
if len(infile)>4 and infile[-4:]=='.jpg' :
print path+infile
wx.CallAfter(addToDict, infile, path+infile)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.