当前位置: 首页>>代码示例>>Python>>正文


Python ViewContainer.remove方法代码示例

本文整理汇总了Python中lollypop.view_container.ViewContainer.remove方法的典型用法代码示例。如果您正苦于以下问题:Python ViewContainer.remove方法的具体用法?Python ViewContainer.remove怎么用?Python ViewContainer.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.view_container.ViewContainer的用法示例。


在下文中一共展示了ViewContainer.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RadioPopover

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import remove [as 别名]

#.........这里部分代码省略.........

    def _add_pixbuf(self, stream):
        """
            Add stream to the view
        """
        try:
            pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
                stream, ArtSize.MONSTER,
                ArtSize.MONSTER,
                True,
                None)
            image = Gtk.Image()
            self._orig_pixbufs[image] = pixbuf
            # Scale preserving aspect ratio
            width = pixbuf.get_width()
            height = pixbuf.get_height()
            if width > height:
                height = height*ArtSize.BIG*self.get_scale_factor()/width
                width = ArtSize.BIG*self.get_scale_factor()
            else:
                width = width*ArtSize.BIG*self.get_scale_factor()/height
                height = ArtSize.BIG*self.get_scale_factor()
            scaled_pixbuf = pixbuf.scale_simple(width,
                                                height,
                                                GdkPixbuf.InterpType.BILINEAR)
            del pixbuf
            surface = Gdk.cairo_surface_create_from_pixbuf(scaled_pixbuf,
                                                           0,
                                                           None)
            del scaled_pixbuf
            image.set_from_surface(surface)
            del surface
            image.show()
            self._view.add(image)
        except Exception as e:
            print(e)
            pass
        # Remove spinner if exist
        if self._spinner is not None:
            self._stack.set_visible_child(self._logo)
            self._stack.clean_old_views(self._logo)
            self._spinner = None

    def _on_btn_add_modify_clicked(self, widget):
        """
            Add/Modify a radio
            @param widget as Gtk.Widget
        """
        uri = self._uri_entry.get_text()
        new_name = self._name_entry.get_text()
        rename = self._name != '' and self._name != new_name

        if uri != '' and new_name != '':
            if rename:
                self._radios_manager.rename(new_name, self._name)
            else:
                self._radios_manager.add(new_name)
            self._radios_manager.add_track(new_name,
                                           uri.lstrip().rstrip())
            self._stack.remove(self._widget)
            self._stack.set_visible_child(self._spinner)
            self._name = new_name
            self._populate_threaded()
            self.set_size_request(700, 400)

    def _on_btn_delete_clicked(self, widget):
        """
            Delete a radio
            @param widget as Gtk.Widget
        """
        if self._name != '':
            cache = Art._RADIOS_PATH
            self._radios_manager.delete(self._name)
            Lp.art.clean_radio_cache(self._name)
            if os.path.exists(cache+"/%s.png" % self._name):
                os.remove(cache+"/%s.png" % self._name)

    def _on_activate(self, flowbox, child):
        """
            Use pixbuf as cover
            Reset cache and use player object to announce cover change
        """
        pixbuf = self._orig_pixbufs[child.get_child()]
        Lp.art.save_radio_logo(pixbuf, self._name)
        Lp.art.clean_radio_cache(self._name)
        Lp.art.announce_logo_update(self._name)
        self.hide()
        self._streams = {}

    def _on_entry_changed(self, entry):
        """
            Update modify/add button
            @param entry as Gtk.Entry
        """
        uri = self._uri_entry.get_text()
        name = self._name_entry.get_text()
        if name != '' and uri.find('://') != -1:
            self._btn_add_modify.set_sensitive(True)
        else:
            self._btn_add_modify.set_sensitive(False)
开发者ID:sebfag,项目名称:lollypop,代码行数:104,代码来源:pop_radio.py


注:本文中的lollypop.view_container.ViewContainer.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。