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


Python IconView.add_items方法代码示例

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


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

示例1: DeviceIconView

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import add_items [as 别名]
class DeviceIconView(ScrolledWindow):
    def __init__(self, items=None):
        ScrolledWindow.__init__(self, 0, 0)

        self.device_iconview = IconView()
        self.device_iconview.connect("right-click-item", self.__on_right_click_item)
        self.device_iconview.draw_mask = self.draw_mask

        if items:
            self.device_iconview.add_items(items)

        self.device_scrolledwindow = ScrolledWindow()
        self.device_scrolledwindow.add_child(self.device_iconview)

        self.add_child(self.device_scrolledwindow)

        event_manager.add_callback("text", self.__on_text)
        event_manager.add_callback("hide-text", self.__on_hide_text)
        
    def __on_text(self, name, obj, argv):
        disable(self, False)
        text(self, argv)

    def __on_hide_text(self, name, obj, argv):
        disable(self, True)

    def __do_remove_item(self, item):
        item.do_remove()
        self.device_iconview.delete_items([item])

    def __on_right_click_item(self, widget, item, x, y):
        menu_items = [(None, _("Pair"), lambda : item.do_pair())]
        if item.is_paired:
            menu_items = []
            menu_items.extend(item.menu_items)
            menu_items.append(None)
            menu_items.append((None, _("Remove Device"), lambda : self.__do_remove_item(item)))

        Menu(menu_items, True).show((int(x), int(y)))
        
    def clear(self):
        self.device_iconview.clear()

    def draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(x, y, w, h)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo("#AEAEAE"))
        cr.rectangle(x, y, w, h)
        cr.stroke()

    def add_items(self, items, clear=False):
        if clear:
            self.device_iconview.clear()

        self.device_iconview.add_items(items)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:59,代码来源:bluetooth_view.py

示例2: AlbumSummaryView

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import add_items [as 别名]
class AlbumSummaryView(gtk.VBox):
    '''
    class docs
    '''

    def __init__(self):
        '''
        init docs
        '''
        gtk.VBox.__init__(self)
        self.scrolled_window = ScrolledWindow()

        self.iconview = IconView()
        self.iconview.draw_mask = self.draw_mask

        self.scrolled_window.add_child(self.iconview)
        self.pack_start(self.scrolled_window, True, True)

        global_event.register_event('download-album-infos-finish', self.update_item)

    def try_fetch_data(self):
        FetchAlbumData(LANGUAGE).start()

    @post_gui
    def update_item(self, data):
        items = []
        if data:
            for album_info in data:
                items.append(AlbumSummaryItem(album_info))

            items.sort(key=attrgetter('album_order'), reverse=True)
            self.iconview.add_items(items)
            global_event.emit('switch-to-album-summary-view')
        else:
            global_event.emit('switch-to-network-problem-view')

    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)),]
                     )
开发者ID:kissthink,项目名称:deepin-store,代码行数:52,代码来源:album_page.py

示例3: RecommendItem

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import add_items [as 别名]

#.........这里部分代码省略.........
    
    def get_column_widths(self):
        return [CATEGORY_ITEM_NAME_WIDTH]
        
    def get_column_renders(self):    
        return [self.render_name]
        
    def hover(self, column, offset_x, offset_y):
        self.is_hover = True
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
        
    def unhover(self, column, offset_x, offset_y):
        self.is_hover = False
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
    
    def select(self):
        self.is_select = True
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
        
    def unselect(self):
        self.is_select = False
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
            
    def button_press(self, column, offset_x, offset_y):
        self.show_page()

    def get_pkg_icon_view_page(self):
        items = []
        for info in self.recommend_infos:
            items.append(RecommendIconItem(info))
        
        self.pkg_icon_view = IconView() 
        self.pkg_icon_view.add_items(items)
        self.pkg_icon_scrolled_window = ScrolledWindow()
        self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
        self.pkg_icon_view.draw_mask = self.draw_mask
        
        self.pkg_icon_view_align = gtk.Alignment()
        self.pkg_icon_view_align.set(0.5, 0.5, 1, 1)
        self.pkg_icon_view_align.set_padding(6, 0, 1, 11)
        self.pkg_icon_view_align.add(self.pkg_icon_scrolled_window)
        return self.pkg_icon_view_align

    def get_download_rank_page(self):
        self.download_rank_page = DownloadRankPage(self.data_manager)
        return self.download_rank_page
    
    def get_album_page(self):
        self.album_page = AlbumPage(self.data_manager)
        return self.album_page
        
    # from deepin_utils.date_time import print_exec_time
    # @print_exec_time
    def show_page(self):
        if self.recommend_scrolled_window_initial:        
            global_event.emit("show-pkg-view", self.recommend_scrolled_window)
        else:
            self.check_network_connection()
        
    def draw_blank_mask(self, cr, x, y, w, h):
        pass
        
    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 click_page(self):
        if isinstance(self.active_page, AlbumPage) and self.active_page.in_detail_view:
            self.active_page.switch_to_album_summary_view()
        
    def switch_page(self, page_index):
        container_remove_all(self.page_box)
        page_name = self.page_name[page_index]

        if not self.page_cache.has_key(self.page_name[page_index]):
            self.page_cache[page_name] = getattr(self, self.tab_switcher_pages_callback[page_index])()

        self.active_page = self.page_cache[page_name]
        self.page_box.pack_start(self.active_page, True, True)
        
        if isinstance(self.active_page, AlbumPage):
            if self.active_page.in_detail_view:
                self.active_page.switch_to_album_summary_view()

        self.recommend_scrolled_window.show_all()
开发者ID:electricface,项目名称:deepin-software-center,代码行数:104,代码来源:home_page.py

示例4: Browser

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import add_items [as 别名]

#.........这里部分代码省略.........
    
    def create_separator_box(self, padding_x=0, padding_y=0):
        separator_box = HSeparator(
            app_theme.get_shadow_color("hSeparator").get_color_info(),
            padding_x, padding_y)
        return separator_box
    
    def __switch_to_filter_view(self, widget):
        self.back_button.set_no_show_all(True)
        self.back_button.hide()
        self.switch_box(self.right_box, self.filter_scrolled_window)
        self.view_mode = ICON_VIEW_MODE
        
    def reload_filter_view(self, tag="artist", switch=False, use_path=False):    
        self.entry_box.entry.set_text("")
        self.back_button.set_no_show_all(True)
        self.back_button.hide()
        self.categorybar_status = tag
        self.filter_view.clear()
            
        if not use_path:    
            self.path_categorybar.set_index(-1)    
        
        _dict = self.get_infos_from_db(tag)
        keys = _dict.keys()
        keys.sort()
        items = []
        all_nb = len(self.__db_query.get_all_songs())
        items.append(IconItem(("deepin-all-songs", "deepin-all-songs", all_nb, tag)))

        for key in keys:
            value, nb = _dict[key] 
            items.append(IconItem((key, value, nb, tag)))
        self.filter_view.add_items(items)    
        
        if switch:
            self.switch_box(self.right_box, self.filter_scrolled_window)
            self.view_mode = ICON_VIEW_MODE
            if not use_path:
                self.change_combo_box_status(True)
            
    def get_infos_from_db(self, tag, values=None):
        genres = []
        artists = []
        extened = False
        return self.__db_query.get_info(tag, genres, artists, values, extened)
    
    def get_attr_infos_from_db(self, info_type="###ALL###", song_dir=None):
        return self.__db_query.get_attr_infos(info_type, song_dir)
    
    def change_combo_box_status(self, hide=False):    
        if not hide:
            self.path_combo_box.set_no_show_all(False)
            self.path_combo_box.show_all()
        else:    
            self.path_combo_box.hide_all()
            self.path_combo_box.set_no_show_all(True)
    
    def update_path_songs(self, key):
        self.back_button.set_no_show_all(True)
        self.back_button.hide()
        self.filter_categorybar.set_index(-1)        
        self.__current_path = key        
        self.change_combo_box_status()        
        
        if self.path_combo_box.get_combo_active():
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:70,代码来源:browser.py

示例5: HorizontalFrame

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import add_items [as 别名]
 
 icon_view_hframe = HorizontalFrame()
 icon_view_vframe = gtk.Alignment()
 icon_view_vframe.set(0, 0, 1, 1)
 icon_view_vframe.set_padding(0, 1, 0, 0)
 
 icon_view_scrolled_window = ScrolledWindow()
 icon_view = IconView(10, 10)
 icon_view_scrolled_window.add_child(icon_view)
 icon_view_hframe.add(icon_view_scrolled_window)
 
 icon_view_vframe.add(icon_view_hframe)
 
 icon_files = map(lambda index: os.path.join(os.path.dirname(__file__), "cover/%s.jpg" % (index)), range(1, 33))
 icon_items = map(lambda icon_file_path: IconItem(icon_file_path, 96, 96), icon_files * 100)
 icon_view.add_items(icon_items)
 
 tab_4_box.pack_start(icon_view_vframe, True, True)
 
 # Tab 5.
 button_box = gtk.VBox()
 check_button = CheckButton("Check Button")
 radio_button_1 = RadioButton("Radio Button1")
 radio_button_2 = RadioButton("Radio Button2")
 button_box.pack_start(check_button, False, False, 4)
 button_box.pack_start(radio_button_1, False, False, 4)
 button_box.pack_start(radio_button_2, False, False, 4)
 tab_5_box.pack_start(button_box, False, False)
 
 # Tree view.
 def tree_view_single_click_cb(widget, item):
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:33,代码来源:demo.py


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