Beispiel #1
0
    def fetchCurrentPicture(self, arg=None, menuw=None):
        url = 'http://antwrp.gsfc.nasa.gov/apod/%s'
        apodpichref = ''
        try:
            myfile = urllib.urlopen(url % 'index.html')
            apodpage = myfile.read()
            result = re.search("a href=\"(image.*)\"", apodpage)
            apodpichref = result.group(1)
        except:
            #unreachable or url error
            realurl = url % 'index.html'
            print 'APOD ERROR: could not open %s' % realurl
            dialog.show_alert(_('Unable to open URL'))
            return

        apodfile = os.path.join(self.apoddir, os.path.basename(apodpichref))

        try:
            urllib.urlretrieve(url % apodpichref, apodfile)
            imgitem = ImageItem(apodfile, self)
            imgitem.view(menuw=menuw)
        except:
            #unreachable or url error
            realurl = url % apodpichref
            print 'APOD ERROR: could not open %s' % realurl
            dialog.show_alert(_('Unable to open URL'))
            return
Beispiel #2
0
 def showimage(self, arg=None, menuw=None):
     """Save in file and watch it"""
     logger.log( 9, 'showimage(arg=%r, menuw=%r)', arg, menuw)
     file = config.FLICKR_DIR + "/" + arg[2].replace("-","_") + ".jpg"
     if not os.path.exists(file):
         box = PopupBox(_("Downloading picture \"") + arg[0] + '"', width=600)
         box.show()
         urllib.urlretrieve(arg[1],file)
         box.destroy()
     imgitem = ImageItem(file, self, arg[0])
     imgitem.menuw=menuw
     imgitem.view(menuw=menuw)
Beispiel #3
0
 def browsePictureDir(self, arg=None, menuw=None):
     apodpic_items = []
     apodpics = os.listdir(self.apoddir)
     apodpics.sort(lambda l, o: cmp(l.upper(), o.upper()))
     for apodpic in apodpics:
         img_item = ImageItem(os.path.join(self.apoddir, apodpic), self)
         apodpic_items += [img_item]
     if (len(apodpic_items) == 0):
         apodpic_items += [
             menu.MenuItem(_('No Images found'), menuw.back_one_menu, 0)
         ]
     apodpic_menu = menu.Menu(_('Apod Pictures'),
                              apodpic_items,
                              reload_func=menuw.back_one_menu)
     menuw.pushmenu(apodpic_menu)
     menuw.refresh()
Beispiel #4
0
    def doChoice1(self, arg=None, menuw=None):
        mylistofitems = []
        mylistofobjects = some_func_that_returns_you_list()

        for myobject in mylistofobjects:
            img_item = ImageItem(myobject, self)
            mylistofitems += [img_item]

        if (len(mylistofitems) == 0):
            mylistofitems += [
                menu.MenuItem(_('No Objects found'), menuw.back_one_menu, 0)
            ]

        myobjectmenu = menu.Menu(_('My Image Objects'),
                                 mylistofitems,
                                 reload_func=menuw.back_one_menu)

        rc.app(None)
        menuw.pushmenu(myobjectmenu)
        menuw.refresh()
Beispiel #5
0
 def doChoice2(self, arg=None, menuw=None):
     imgitem = ImageItem(self.importantData, self)
     imgitem.view(menuw=menuw)