gtkui.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:yt-browser 作者: juanfgs 项目源码 文件源码
def update_list(self,search_result):
        """ Dynamically create widgets and place them on the video list """
        builder = Gtk.Builder()
        builder.add_from_string( self.video_item_string )
        url = search_result["snippet"]["thumbnails"]["default"]["url"]
        download_button = builder.get_object("download-button")
        convert_button = builder.get_object("convert-button")
        video_item_box = builder.get_object("video-item-box")
        video_thumbnail = builder.get_object("video-image")
        video_info = builder.get_object("video-info")
        download_button.connect("clicked",self.on_download_clicked, { "video_id": search_result["id"]["videoId"], "title": search_result["snippet"]["title"], "action": "download" })
        convert_button.connect("clicked",self.on_download_clicked, { "video_id": search_result["id"]["videoId"], "title": search_result["snippet"]["title"], "action": "convert" })

        response = urllib.request.urlopen(url)
        fname = "/tmp/yt-browser-thumb" + url.split("/")[-1]

        f = open(fname, "wb")
        f.write(response.read())
        f.close()
        response.close()
        video_thumbnail.set_from_pixbuf(Pixbuf.new_from_file(fname))

        video_info.set_markup(search_result["snippet"]["title"] )
        self.video_list.add(video_item_box)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号