gtkui.py 文件源码

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

项目:yt-browser 作者: juanfgs 项目源码 文件源码
def on_video_search1_activated(self,searchbox):
        """ Start searching when the user presses enter """

        # Show a spinner to the user while the results are being retrieved
        spinner = Gtk.Spinner()
        searching = Gtk.Label("Buscando...")

        # iterate through the list items and remove child items
        self.video_list.foreach(lambda child: self.video_list.remove(child))

        # Show the spinner and searching label
        self.video_list.add(spinner)
        self.video_list.add(searching)
        spinner.start()

        # Update the changes
        self.video_list.show_all()

        #we spawn a new thread to consume the api asynchronously
        def start_search():
            #for now we use a single backend

            self.search_response = self.backend.search(searchbox.get_text())
            for search_result in self.search_response.get("items",[]):
                if search_result["id"]["kind"] == "youtube#video":
                    GLib.idle_add(spinner.destroy)
                    GLib.idle_add(searching.destroy)
                    GLib.idle_add(self.update_list,search_result)
                    GLib.idle_add(self.video_list.show)


        self.download_thread = threading.Thread(target=start_search)
        self.download_thread.daemon = True
        self.download_thread.start()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号