當前位置: 首頁>>代碼示例>>Python>>正文


Python ImageBase.get_pixbuf方法代碼示例

本文整理匯總了Python中foobnix.helpers.image.ImageBase.get_pixbuf方法的典型用法代碼示例。如果您正苦於以下問題:Python ImageBase.get_pixbuf方法的具體用法?Python ImageBase.get_pixbuf怎麽用?Python ImageBase.get_pixbuf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在foobnix.helpers.image.ImageBase的用法示例。


在下文中一共展示了ImageBase.get_pixbuf方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: append_image

# 需要導入模塊: from foobnix.helpers.image import ImageBase [as 別名]
# 或者: from foobnix.helpers.image.ImageBase import get_pixbuf [as 別名]
 def append_image(self, url):
     if not url:
         return None
     enditer = self.buffer.get_end_iter()
     image = ImageBase(None)
     image.set_image_from_url(url)
     self.buffer.insert_pixbuf(enditer, image.get_pixbuf())
開發者ID:simokhov,項目名稱:foobnix,代碼行數:9,代碼來源:textarea.py

示例2: InfoPanelWidget

# 需要導入模塊: from foobnix.helpers.image import ImageBase [as 別名]
# 或者: from foobnix.helpers.image.ImageBase import get_pixbuf [as 別名]

#.........這裏部分代碼省略.........
            if not os.path.isdir(COVERS_DIR):
                os.mkdir(COVERS_DIR)
            list_images = os.listdir(COVERS_DIR)
            '''remove extra keys'''
            for key in dict.keys():
                if (key+'.jpg') not in list_images:
                    del dict[key]
            '''remove extra files'''
            for file in list_images:
                if os.path.splitext(file)[0] not in dict.keys():
                    os.remove(os.path.join(COVERS_DIR, file))
            
            for list, key in zip(dict.values(), dict.keys()):
                if bean.text in list:
                    bean.image = os.path.join(COVERS_DIR, key + ".jpg")
                    break
            
            if not bean.image:
                '''get image url'''
                bean.image = self.controls.lastfm_service.get_album_image_url(bean.artist, bean.title)
                              
        self.image.update_info_from(bean)
        
        if not bean.image:
            logging.warning("""""Can't get cover image. Check the correctness of the artist's name and track title""""")
            
        '''make .jpg image and store it in cache'''        
        if bean.image and bean.image.startswith("http://"):
            url_basename = os.path.splitext(os.path.basename(bean.image))[0]
            if dict.has_key(url_basename):
                dict[url_basename].append(bean.text)
            else:
                dict[url_basename] = [bean.text]
                self.image.get_pixbuf().save(os.path.join(COVERS_DIR, url_basename + '.jpg'), "jpeg", {"quality":"90"})
        
        self.controls.trayicon.update_info_from(bean)
        self.controls.coverlyrics.set_cover()
        
        
    def show_similar_lyrics(self):
        if self.info_cache.lyric_bean == self.bean:
            return None
        self.info_cache.lyric_bean = self.bean
        
        """lyrics"""
        if not os.path.isdir(LYRICS_DIR):
            os.mkdir(LYRICS_DIR)
        lyrics_list = os.listdir(LYRICS_DIR)
        lyrics_title = "*** %s - %s *** \n" % (self.bean.artist, self.bean.title)
        if lyrics_title in lyrics_list:
            text = "".join(open(os.path.join(LYRICS_DIR, lyrics_title), 'r').readlines())
        else:
            text = get_lyrics(self.bean.artist, self.bean.title)
            if text:
                open(os.path.join(LYRICS_DIR, lyrics_title), 'w').write(text)
            else:
                text = "The text not found"
        
        self.lyrics.set_text(text, lyrics_title)
        self.controls.coverlyrics.lyrics.set_text(text, lyrics_title)
        
    def show_wiki_info(self):
        if not self.bean:
            return
        if self.info_cache.wiki_artist == self.bean.artist:
            return None
開發者ID:matttbe,項目名稱:foobnix,代碼行數:70,代碼來源:infopanel.py


注:本文中的foobnix.helpers.image.ImageBase.get_pixbuf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。