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


Python TreeView.set_highlight_item方法代码示例

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


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

示例1: DetailWindow

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

#.........这里部分代码省略.........
            container_remove_all(self.treeview_box)
            container_remove_all(self.listview_box)
            self.listview_box.pack_start(align, True, True)
        self.main_view_box.show_all()

        container_remove_all(self.toolbar_box)
        self.add_toolbar()
        self.toolbar_box.show_all()

    def on_main_box_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        cr.rectangle(*rect)
        cr.set_source_rgb(*STROKE_LINE_COLOR)
        cr.stroke_preserve()
        cr.set_source_rgb(1, 1, 1)
        cr.fill()


    def on_treeview_draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(x, y, w, h)
        cr.fill()

        cr.move_to(x, y)
        cr.line_to(x + w, y)
        cr.set_source_rgb(*STROKE_LINE_COLOR)
        cr.stroke()
        draw_line(cr, (x+w-1, y), (x+w-1, y+h), "#b2b2b2")

    def on_treeview_click_item(self, widget, item, column, x, y):
        if not item.is_parent:
            widget.set_highlight_item(item)

            self.current_showed_items = self.get_items_from_treeview_highlight()
            self.add_listview(self.current_showed_items)

            for comb_item in self.category_comb.items:
                if comb_item.title == item.title:
                    self.category_comb.set_select_index(comb_item_value_to_index(comb_item.item_value))

    def on_treeview_double_click_item(self, widget, item, column, x, y):
        if item.is_parent:
            if item.is_expand:
                item.unexpand()
            else:
                item.expand()

    def on_treeview_right_press_items(self, widget, root_x, root_y, current_item, select_items):
        '''
        docs
        '''
        self.treeview.set_highlight_item(current_item)
        if not current_item.is_parent:
            def on_add_to_bl():
                blacklist.add(current_item.title)
                current_item.is_in_blacklist = True
                current_item.emit_redraw_request()
            def on_remove_from_bl():
                blacklist.remove(current_item.title)
                current_item.is_in_blacklist = False
                current_item.emit_redraw_request()

            menu_items = []
            if current_item.title in blacklist.bl:
开发者ID:electricface,项目名称:deepin-notifications,代码行数:70,代码来源:window_view.py

示例2: AddPage

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_highlight_item [as 别名]
class AddPage(gtk.HBox):
    
    def __init__(self):
        gtk.HBox.__init__(self)

        self.aibizhi_cache_page = CachePage(Aibizhi())
        self.bizhi360_cache_page = CachePage(Bizhi360())
        
        self.aibizhi_cache_page.cache_view.try_to_fetch()
        self.bizhi360_cache_page.cache_view.try_to_fetch()
        self.system_wallpapers_page = SystemPage(get_system_wallpaper_dirs()[0])
        self.picture_wallpapers_page = PicturePage(get_images_dir())
        self.download_wallpapaers_page = UserPage(get_download_wallpaper_dir())

        self.task_page = TaskPage()
        
        self.__init_navigatebar()
        
        self.switch_page = gtk.VBox()
        self.pack_start(self.navigatebar, False, True)
        self.pack_start(self.switch_page, True, True)
        
        self.switch_page.add(self.system_wallpapers_page)
        event_manager.add_callback("downloading-tasks-number", self.on_download_item_changed)
        self.connect("expose-event", self.on_addpage_expose_event)
        
    def set_theme(self, theme):
        self.system_wallpapers_page.set_theme(theme)
        self.picture_wallpapers_page.set_theme(theme)
        self.download_wallpapaers_page.set_theme(theme)
        self.aibizhi_cache_page.set_theme(theme)
        self.bizhi360_cache_page.set_theme(theme)

    def on_download_item_changed(self, name, obj, data):    
        pass

    def __init_navigatebar(self):    
        self.navigatebar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
        self.navigatebar.connect("single-click-item", self.on_navigatebar_single_click)
        self.navigatebar.set_size_request(132, -1)
        self.navigatebar.draw_mask = self.on_navigatebar_draw_mask
        
        local_expand_item = ExpandItem(_("Library"))
        network_expand_item = ExpandItem(_("Internet"))
        self.navigatebar.add_items([local_expand_item, 
                                    network_expand_item, 
                                   ])
        local_expand_item.add_childs([(_("System"), self.system_wallpapers_page),
                                      (_("Pictures"), self.picture_wallpapers_page), 
                                      (_("Favorites"), self.download_wallpapaers_page)], expand=True)
        network_expand_item.add_childs([(_("360 Wallpaper"), self.bizhi360_cache_page), 
                                        (_("LoveWallpaper"), self.aibizhi_cache_page),
                                       ], expand=True)        
        
        self.navigatebar.set_highlight_item(self.navigatebar.get_items()[1])
        
    def on_addpage_expose_event(self, widget, event):    
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        self.draw_mask(cr, *rect)
        
    def on_navigatebar_draw_mask(self, cr, x, y, w, h):    
        self.draw_mask(cr, x, y, w, h)
        draw_line(cr, (x + w, y), (0, h), "#d6d6d6")        
        
    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.
        '''
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(x, y, w, h)
        cr.fill()
        

    def on_navigatebar_single_click(self, widget, item, column, x, y):
        if item.widget:
            widget.set_highlight_item(item)
            switch_box(self.switch_page, item.widget)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:87,代码来源:add_page.py

示例3: MainBox

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_highlight_item [as 别名]
class MainBox(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        self.connect("expose-event", self.on_page_expose_event)

        self.aibizhi_cache_page = CachePage(Aibizhi())
        self.bizhi360_cache_page = CachePage(Bizhi360())
        self.aibizhi_cache_page.cache_view.try_to_fetch()
        self.bizhi360_cache_page.cache_view.try_to_fetch()

        self.favorites_page = FavoritePage(get_favorite_dir())
        self.pictures_page = LocalPicturePage(get_download_wallpaper_dir())

        self.add_item = AddItem()
        self.pictures_page.select_view.add_items([self.add_item])

        self.task_page = TaskPage()
        
        self.switch_page = gtk.VBox()
        self.__init_navigatebar()

        self.pack_start(self.navigatebar, False, True)
        self.pack_start(self.switch_page, True, True)

        event_manager.add_callback("switch-to-local-pictures", self.switch_to_local_pictures)

    def switch_to_local_pictures(self, name, obj, data=None):
        item = self.navigatebar.get_items()[2]
        self.on_navigatebar_single_click(self.navigatebar, item, 0, 0, 0)

    def __init_navigatebar(self):
        self.navigatebar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
        self.navigatebar.connect("single-click-item", self.on_navigatebar_single_click)
        self.navigatebar.set_size_request(132, -1)
        self.navigatebar.draw_mask = self.on_navigatebar_draw_mask
        
        local_expand_item = ExpandItem(_("Library"))
        network_expand_item = ExpandItem(_("Internet"))
        self.navigatebar.add_items([local_expand_item, 
                                    network_expand_item, 
                                   ])
        local_expand_item.add_childs([
            (FavoritesTitle, self.favorites_page),
            (LocalWallpapersTitle, self.pictures_page),
            ],
            expand=True)
        network_expand_item.add_childs([(_("360 Wallpaper"), self.bizhi360_cache_page), 
                                        (_("LoveWallpaper"), self.aibizhi_cache_page),
                                       ], expand=True)        
        
        if get_favorite_number() == 0:
            self.navigatebar.set_highlight_item(self.navigatebar.get_items()[2])
            self.switch_page.add(self.pictures_page)
        else:
            self.navigatebar.set_highlight_item(self.navigatebar.get_items()[1])
            self.switch_page.add(self.favorites_page)

    def draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(x, y, w, h)
        cr.fill()

    def on_page_expose_event(self, widget, event):    
        cr = widget.window.cairo_create()
        width, height= widget.size_request()
        self.draw_mask(cr, 0, 0, width, height)

    def on_navigatebar_draw_mask(self, cr, x, y, w, h):    
        self.draw_mask(cr, x, y, w, h)
        draw_line(cr, (x + w, y), (0, h), "#d6d6d6")        

    def on_navigatebar_single_click(self, widget, item, column, x, y):
        if item.widget:
            widget.set_highlight_item(item)
            switch_box(self.switch_page, item.widget)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:77,代码来源:local_page.py

示例4: PlaylistUI

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

#.........这里部分代码省略.........
        
    def expose_toolbar_mask(self, widget, event):    
        cr = widget.window.cairo_create()
        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()
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:70,代码来源:playlist.py


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