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


Python TreeView.delete_items方法代码示例

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


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

示例1: InstallPage

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import delete_items [as 别名]
class InstallPage(gtk.VBox):
    '''
    class docs
    '''

    def __init__(self, bus_interface, data_manager):
        '''
        init docs
        '''
        # Init.
        gtk.VBox.__init__(self)
        self.bus_interface = bus_interface
        self.data_manager = data_manager

        self.message_bar = MessageBar(32)
        self.message_box = gtk.HBox()

        self.treeview = TreeView(enable_drag_drop=False)
        self.treeview.set_expand_column(0)
        self.cute_message_image = gtk.VBox()
        self.content_box = gtk.VBox()

        self.pack_start(self.message_box, False, False)
        self.pack_start(self.content_box, True, True)

        self.cute_message_pixbuf = utils.get_common_locale_image_pixbuf("info", "no_download.png")
        self.content_box.pack_start(self.cute_message_image, True, True)

        self.treeview.draw_mask = self.draw_mask

        self.cute_message_image.connect("expose-event", self.expose_cute_message_image)
        self.treeview.connect("items-change", self.update_message_bar)
        self.treeview.connect("items-change", lambda treeview: global_event.emit("update-install-notify-number", self.get_installing_pkgs_number()))

        #self.get_action_item("deepin-webapps-baidu-map")
        #self.download_failed("deepin-webapps-baidu-map")

    def expose_cute_message_image(self, widget, event):
        if self.cute_message_pixbuf:
            cr = widget.window.cairo_create()
            rect = widget.allocation

            cr.set_source_rgb(1, 1, 1)
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

            draw_pixbuf(
                cr,
                self.cute_message_pixbuf,
                rect.x + (rect.width - self.cute_message_pixbuf.get_width()) / 2,
                rect.y + (rect.height - self.cute_message_pixbuf.get_height()) / 2,
                )

    def update_install_status(self):
        global_event.emit("update-install-notify-number", self.get_installing_pkgs_number())
        self.update_message_bar(self.treeview)

    def get_installing_pkgs_number(self):
        items = []
        for item in self.treeview.visible_items:
            if not (item.status == item.STATUS_INSTALL_FINISH or \
                    item.status == item.STATUS_DOWNLOAD_FAILED):
                items.append(item)
        return len(items)

    def get_installed_pkgs_number(self):
        items = []
        for item in self.treeview.visible_items:
            if item.status == item.STATUS_INSTALL_FINISH:
                items.append(item)
        return len(items)

    def delete_item_match_pkgname(self, pkg_name):
        for install_item in self.treeview.visible_items:
            if install_item.pkg_name == pkg_name:
                self.treeview.delete_items([install_item])
                break

    def update_message_bar(self, treeview):
        if self.get_installing_pkgs_number() == 0:
            if self.get_installed_pkgs_number() == 0:
                container_remove_all(self.message_box)

                children = self.content_box.get_children()
                if len(children) == 0 or children[0] == self.treeview:
                    if self.cute_message_pixbuf == None:
                        self.cute_message_pixbuf = utils.get_common_locale_image_pixbuf("info", "no_download.png")

                    container_remove_all(self.content_box)
                    self.content_box.pack_start(self.cute_message_image, True, True)

                    self.show_all()
            else:
                self.message_bar.set_message("")
        else:
            container_remove_all(self.message_box)
            self.message_box.pack_start(self.message_bar, True, True)
            self.message_bar.set_message(_("%s applications are being installed") % self.get_installing_pkgs_number())

            children = self.content_box.get_children()
#.........这里部分代码省略.........
开发者ID:kissthink,项目名称:deepin-store,代码行数:103,代码来源:install_page.py

示例2: UninstallPage

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import delete_items [as 别名]

#.........这里部分代码省略.........
            # for delete items
            if self.uninstall_change_items["delete"] != []:
                for item in self.uninstall_change_items["delete"]:
                    if item in self.cache_items:
                        self.cache_items.remove(item)
                self.uninstall_change_items["delete"] = []

            self.treeview.add_items(self.cache_items)

    def normal_search_cb(self, keywords):
        pass
        
    def update_message_bar(self, treeview):    
        self.message_bar.set_message(_("%s applications can be uninstalled") % len(treeview.visible_items))
        
    def draw_mask(self, cr, x, y, w, h):
        '''
        Draw mask interface.
        
        @param cr: Cairo context.
        @param x: X coordiante of draw area.
        @param y: Y coordiante of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        draw_vlinear(cr, x, y, w, h,
                     [(0, ("#FFFFFF", 0.9)),
                      (1, ("#FFFFFF", 0.9)),]
                     )
        
    def update_action_status(self, pkg_infos):
        pkg_items = []
        for (pkg_name, action_status) in pkg_infos:
            pkg_item = None
            for item in self.treeview.visible_items:
                if item.pkg_name == pkg_name:
                    pkg_item = item
                    break

            if pkg_item == None:
                pkg_item = UninstallItem(pkg_name, self.bus_interface.request_pkgs_uninstall_version([pkg_name])[0], self.data_manager)
                
            if action_status == "wait":
                pkg_item.action_wait()
            elif action_status == "start":
                pkg_item.action_start()
            elif action_status == "update":
                pkg_item.action_update(0)
            pkg_items.append(pkg_item)
                
        pkg_items = filter(lambda item: item not in self.treeview.visible_items, pkg_items)
        self.treeview.add_items(pkg_items)        
        
    def fetch_uninstall_info(self):
        self.bus_interface.request_uninstall_pkgs(
                        reply_handler=self.render_uninstall_info,
                        error_handler=lambda e:handle_dbus_error("request_uninstall_pkgs", e))
    
    def render_uninstall_info(self, pkg_infos):
        self.add_uninstall_items(pkg_infos)
        
    def add_uninstall_items(self, pkg_infos):
        items = []
        for pkg_info in pkg_infos:
            (pkg_name, pkg_version) = eval(pkg_info)
            if self.data_manager.is_pkg_have_desktop_file(pkg_name) != None \
                and self.data_manager.is_pkg_display_in_uninstall_page(pkg_name)[0] == '1':
                items.append(UninstallItem(pkg_name, pkg_version, self.data_manager))
            
        if self.search_flag:
            self.uninstall_change_items["add"] += items
        else:
            self.treeview.add_items(items)

    def delete_uninstall_items(self, items):
        if self.search_flag:
            self.uninstall_change_items["delete"] += items
            for item in items:
                if item in self.treeview.visible_items:
                    self.treeview.delete_items([item])
        else:
            self.treeview.delete_items(items)
        
    def action_start(self, pkg_name):
        for item in self.treeview.visible_items:
            if item.pkg_name == pkg_name:
                item.action_start()
                break
    
    def action_update(self, pkg_name, percent):
        for item in self.treeview.visible_items:
            if item.pkg_name == pkg_name:
                item.action_update(percent)
                break
    
    def action_finish(self, pkg_name, pkg_info_list):
        for item in self.treeview.visible_items:
            if item.pkg_name == pkg_name:
                item.action_finish()
                break
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:104,代码来源:uninstall_page.py

示例3: PlaylistUI

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import delete_items [as 别名]

#.........这里部分代码省略.........
        rect = widget.allocation
        cr.set_source_rgba(1, 1, 1, 0.95)
        cr.rectangle(rect.x, rect.y, rect.width, rect.height)
        cr.fill()
        
        draw_line(cr, (rect.x, rect.y + 1), 
                  (rect.x + rect.width, rect.y + 1), "#b0b0b0")
        return False
    
    def expose_entry_mask(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        draw_alpha_mask(cr, rect.x , rect.y, rect.width, rect.height, "toolbarEntry")
        
    def draw_category_list_mask(self, cr, x, y, width, height):
        draw_alpha_mask(cr, x, y, width, height, "layoutLeft")
        
    def draw_item_mask(self, cr, x, y, width, height):    
        draw_vlinear(cr, x, y, width, height,
                     app_theme.get_shadow_color("editlistItemPress").get_color_info())        
        
    def __on_db_loaded(self, db):        
        if not MediaDB.get_playlists():
            MediaDB.create_playlist("local", _("Default List"))            
            
        # From MediaDB loaded playlists.    
        init_items = [ListTreeItem(pl) for pl in MediaDB.get_playlists()]    
        self.category_list.add_items(init_items)
        
        # Init Category_list.
        self.category_list.set_highlight_item(self.get_categroy_item_by_index(self.get_save_item_index()))
        self.current_item = self.category_list.get_highlight_item()
        
        self.delete_source_id = self.current_item.song_view.connect("delete-select-items", self.parser_delete_items)
        self.drag_source_id = self.current_item.song_view.connect("drag-data-received", self.parser_drag_event)
        self.menu_source_id = self.current_item.song_view.connect("right-press-items", self.popup_detail_menu)

        Player.set_source(self.current_item.song_view)
        self.right_box.add(self.current_item.get_list_widget())
        self.list_paned.show_all()
        
    def __on_player_loaded(self, player):   
        if self.current_item:
            self.current_item.song_view.reset_error_items()
            self.current_item.song_view.set_highlight_song(Player.song)
        
    def __play_and_add(self, widget, song):    
        self.current_item.song_view.add_songs(song, play=True)
        
    def __add_songs_to_list(self, widget, songs):
        if songs and self.current_item.song_view:
            self.current_item.song_view.add_songs(songs)
        
    def get_selected_song_view(self):    
        if self.current_item:
            return self.current_item.song_view
            
    def search_cb(self, widget, text):        
        if not self.search_flag:
            self.cache_items = self.current_item.song_view.get_items()
        
        # Clear song_view select status    
        self.current_item.song_view.clear_highlight()
        self.current_item.song_view.select_rows = []
        
        if text != "":
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:70,代码来源:playlist.py


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