5 from enthought
.traits
.api
import HasTraits
,Str
,Float
,Button
6 from enthought
.traits
.ui
.api
import View
,Item
,ButtonEditor
7 from yahoo
.search
.image
import ImageSearch
11 def yahoosearch(query
):
12 ''' Yahoo searches for an image and returns a URL, or an empty string if something goes wrong '''
14 search
= ImageSearch(app_id
="junk",query
=query
)
16 for res
in search
.parse_results():
24 ''' Fetch file from link and return path to local file '''
25 return urllib
.urlretrieve(url
)[0]
27 class ImgSearch(HasTraits
):
28 query
= Str("Enter search")
32 def _run_query_fired(self
):
33 self
.url
= yahoosearch(self
.query
)
34 self
.localfile
= fetchlink(self
.url
)
36 pl
.open(self
.localfile
)
38 view
= View('query','url','localfile',Item('run_query',show_label
=False))