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


Python TreeView.delete_all_items方法代码示例

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


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

示例1: plugin_widget

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import delete_all_items [as 别名]
    def plugin_widget(self):
        self.__get_devices()
        plugin_box = gtk.VBox()
        adapter_box = gtk.HBox(spacing = 5)
        adapter_image = ImageBox(app_theme.get_pixbuf("bluetooth/enable_open.png"))
        adapter_label = self.__setup_label(_("Adapter"))
        adapter_toggle = self.__setup_toggle()
        if self.my_bluetooth.adapter:
            adapter_toggle.set_active(self.my_bluetooth.adapter.get_powered())
            if self.my_bluetooth.adapter.get_powered():
                self.tray_icon.set_icon_theme("enable")
            else:
                self.tray_icon.set_icon_theme("enable_disconnect")
        adapter_toggle.connect("toggled", self.__adapter_toggled)
        separator_align = self.__setup_align(padding_bottom = 0)
        separator = self.__setup_separator()
        separator_align.add(separator)
        '''
        devices treeview
        '''
        device_treeview = TreeView()
        device_separator_align = self.__setup_align()
        device_separator = self.__setup_separator()
        device_separator_align.add(device_separator)
        device_count = len(self.device_items)
        if device_count:
            device_treeview.delete_all_items()
            device_treeview.add_items(self.device_items)
            device_treeview.set_size_request(self.width, device_count * DeviceItem.ITEM_HEIGHT)
        else:
            device_treeview.set_child_visible(False)
            device_separator_align.set_size_request(-1, 0)
            device_separator_align.set_child_visible(False)
        '''
        select button
        '''
        select_button_align = self.__setup_align()
        select_button = SelectButton(_("Advanced options..."),
                                     font_size = 10,
                                     ali_padding = 5)
        select_button.set_size_request(self.width, 25)
        select_button.connect("clicked", self.__bluetooth_selected) # I don't know why, but replacing "button-press-event" with 
        select_button_align.add(select_button)                      # clicked really works...

        adapter_box.pack_start(adapter_image, False, False)
        adapter_box.pack_start(adapter_label, False, False)
        adapter_box.pack_start(adapter_toggle, False, False)

        plugin_box.pack_start(adapter_box, False, False)
        plugin_box.pack_start(separator_align, False, False)
        plugin_box.pack_start(device_treeview, False, False)
        plugin_box.pack_start(device_separator_align, False, False)
        plugin_box.pack_start(select_button_align, False, False)

        return plugin_box
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:57,代码来源:tray_bluetooth_plugin.py

示例2: SearchPage

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import delete_all_items [as 别名]
class SearchPage(gtk.VBox):
    '''
    class docs
    '''
	
    def __init__(self, data_manager):
        '''
        init docs
        '''
        # Init.
        gtk.VBox.__init__(self)
        self.data_manager = data_manager
        
        self.keywords = []
        self.all_pkg_names = []
        self.message_bar = MessageBar(18)
        
        self.content_box = gtk.VBox()

        self.treeview = TreeView(enable_drag_drop=False, expand_column=0)

        self.cute_message_image = gtk.VBox()
        self.cute_message_pixbuf = utils.get_common_locale_image_pixbuf("info", "noresult.png")
        self.cute_message_image.connect("expose-event", self.expose_cute_message_image)

        self.content_box.pack_start(self.message_bar, False, False)
        self.content_box.pack_start(self.treeview)

        self.loading_box = LoadingBox()

        self.pack_start(self.loading_box, True, True)
        
        self.treeview.connect("items-change", self.update_message_bar)
        self.treeview.draw_mask = self.draw_mask

    def expose_cute_message_image(self, widget, event):
        if self.cute_message_pixbuf:
            cr = widget.window.cairo_create()
            rect = widget.allocation
            
            cr.set_source_rgba(1, 1, 1, 0)
            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_message_bar(self, treeview):
        if len(treeview.visible_items) > 0:
            self.message_bar.set_message(_("%s: %s matched applications") % (' '.join(self.keywords), len(self.all_pkg_names)))
            container_remove_all(self)
            self.pack_start(self.content_box)
            global_event.emit("update-current-status-pkg-page", treeview)
        else:
            container_remove_all(self)
            self.pack_start(self.cute_message_image)
        
    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(self, keywords):
        self.keywords = keywords
        self.treeview.delete_all_items()
        self.all_pkg_names = self.data_manager.search_query(keywords)

        if self.all_pkg_names:
            if len(self.all_pkg_names) > LOAD_ITEMS_NUMBER:
                self.load_new_items(self.all_pkg_names[:LOAD_ITEMS_NUMBER])
            else:
                self.load_new_items(self.all_pkg_names)
        else:
            self.update_message_bar(self.treeview)

        self.treeview.scrolled_window.connect('vscrollbar-state-changed', self.scrolled_window_vscrollbar_handler)

    def scrolled_window_vscrollbar_handler(self, widget, state):
        if state == "bottom":
            current_item_number = len(self.treeview.visible_items)
            all_pkgs_number = len(self.all_pkg_names)
            start = current_item_number
            if current_item_number < all_pkgs_number and (current_item_number+LOAD_ITEMS_NUMBER) < all_pkgs_number:
                end = current_item_number+LOAD_ITEMS_NUMBER
            elif current_item_number < all_pkgs_number and (current_item_number+LOAD_ITEMS_NUMBER) >= all_pkgs_number:
                end = all_pkgs_number
#.........这里部分代码省略.........
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:103,代码来源:search_page.py

示例3: Region

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

#.........这里部分代码省略.........
            print "provider has not selected"
            return
        try:
            self.plan_select
        except:
            self.plan_select = None
        
        def add_keys(settings):
            self.prop_dict = settings
            
        username = self.__sp.get_provider_username(self.code, self.provider_select)
        password = self.__sp.get_provider_password(self.code, self.provider_select)
        add_keys({"cdma": {
                 "number": "#777",
                 "username": username,
                 "password": password}})
        provider_type = "cdma"
        if self.plan_select:
            self.prop_dict.pop("cdma")
            apn = self.plan_select
            index = self.__sp.get_provider_apns_name(self.code, self.provider_select).index(apn)
            (network_id, network_type) = self.__sp.get_provider_networks(self.code, self.provider_select)[index]
            add_keys({"gsm":{
                     "number": "*99#",
                     "username": username,
                     "password": password,
                     "apn": apn,
                     #"network_id": network_id,
                     "network_type": network_type}})
            provider_type = "gsm"

        #setting_page = nm_module.slider.get_page_by_name("setting")
        #broadband = setting_page.setting_group.get_broadband()
        if self.connection_type == None:
            new_connection = getattr(nm_module.nm_remote_settings, "new_%s_connection"%provider_type)()
            Dispatcher.emit("region-back", new_connection, self.prop_dict, provider_type)

            #setting_page.sidebar.new_connection_list[provider_type].append(new_connection)
            #setting_page.init(setting_page.sidebar.new_connection_list)
            #setting_page.sidebar.set_active(new_connection)
            #broadband.set_new_values(self.prop_dict, provider_type)
        else:
            Dispatcher.emit("region-back", self.connection, self.prop_dict, provider_type)

            #broadband.set_new_values(self.prop_dict, provider_type)

        nm_module.slider._slide_to_page("setting", "none")

    def init(self, connection):
        if connection == None:
            self.connection_type = None
        else:
            self.connection = connection
            mobile_type = connection.get_setting("connection").type
            self.connection_type = mobile_type
        Dispatcher.send_submodule_crumb(_("Region"), 2)

        from mm.provider import ServiceProviders
        self.__sp = ServiceProviders()
        self.country_list = self.__sp.get_country_name_list()
        self.country_tree.delete_all_items()
        self.country_tree.add_items([CountryItem(_(country)) for country in self.country_list])
        # add a bottom line for last item

        code = self.__sp.get_country_from_timezone()

        self.country_codes = self.__sp.get_country_list()
        try:
            selected_country = self.country_tree.visible_items[self.country_codes.index(code)]
            self.country_tree.select_items([selected_country])
            self.auto_scroll_to()
            self.country_tree.emit("button-press-item", selected_country, 0, 1, 1)
        except:
            pass

    def country_selected(self, widget, w, a, b, c):
        self.provider_tree.delete_all_items()
        self.code = self.country_codes[widget.select_rows[0]]
        if self.connection_type:
            self.provider_names = getattr(self.__sp, "get_country_%s_providers_name"%self.connection_type)(self.code)
        else:
            self.provider_names = self.__sp.get_country_providers_name(self.code)
        
        self.provider_select = None
        self.provider_tree.add_items([Item(p, self.__sp, self.code) for p in self.provider_names])
        self.provider_tree.show_all()

    def provider_selected(self, widget, item, column, offset_x, offset_y):
        if type(item) is Item:
            self.provider_select = item.content
            self.plan_select = None
        else:
            self.plan_select = item.content

    def auto_scroll_to(self):
        vadjust = self.country_tree.scrolled_window.get_vadjustment()
        upper = vadjust.upper
        page_size = vadjust.page_size

        vadjust.set_value(min(upper - page_size, (self.country_tree.select_rows[0]- 4)*30))
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:104,代码来源:regions.py

示例4: CompletionWindow

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import delete_all_items [as 别名]
class CompletionWindow(Window):
    '''
    class docs
    '''
	
    def __init__(self, window_width, window_height):
        '''
        init docs
        '''
        # Init.
        Window.__init__(
            self,
            shadow_visible=False,
            shadow_radius = 0,
            shape_frame_function=self.shape_completion_window_frame,
            expose_frame_function=self.expose_completion_window_frame,
            # window_type=gtk.WINDOW_POPUP,
            )
        
        self.window_width = window_width
        self.window_height = window_height
        self.window_offset_x = 0
        self.window_offset_y = 0
        self.align_size = 2
        
        self.treeview = TreeView(
            enable_highlight=False,
            enable_multiple_select=False,
            enable_drag_drop=False,)
        
        self.treeview.draw_mask = self.treeview_draw_mask
        self.treeview.scrolled_window.tag_by_popup_grab_window = True
        self.treeview_align = gtk.Alignment()
        self.treeview_align.set(0.5, 0.5, 1, 1)
        self.treeview_align.set_padding(self.align_size, self.align_size, self.align_size, self.align_size)
        self.treeview_align.add(self.treeview)
        
        self.window_frame.pack_start(self.treeview_align, True, True)
        
        self.connect("realize", self.realize_completion_window)
        
        self.get_scrolledwindow = self.get_scrolledwindow
        
        wrap_grab_window(completion_grab_window, self)
        
    def get_scrolledwindow(self):
        return self.treeview.scrolled_window
        
    def shape_completion_window_frame(self, widget, event):
        pass
    
    def treeview_draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgba(1, 1, 1, 0.95)
        cr.rectangle(x, y, w, h)
        cr.fill()
        
    def expose_completion_window_frame(self, widget, event):
        cr = widget.window.cairo_create()        
        rect = widget.allocation

        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()
        
        cr.set_line_width(1)
        cr.set_source_rgb(*color_hex_to_cairo("#c7c7c7"))
        cr.rectangle(*rect)
        cr.stroke()
            
    def show(self, keyword):
        self.treeview.delete_all_items()
        self.treeview.add_items([TextItem(key) for key in ["linux", "deepin", "word", keyword]])
        self.treeview.select_first_item()        
        # self.treeview.grab_focus()
        
        (x, y) = get_widget_root_coordinate(search_entry, WIDGET_POS_BOTTOM_LEFT, True)
        self.move(x + self.window_offset_x, y + self.window_offset_y)
        self.show_all()
        
    def realize_completion_window(self, widget):
        self.set_default_size(self.window_width, self.window_height)
        self.set_geometry_hints(
            None,
            self.window_width,       # minimum width
            self.window_height,       # minimum height
            self.window_width,
            self.window_height,
            -1, -1, -1, -1, -1, -1
            )
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:93,代码来源:completion_window.py

示例5: CompletionWindow

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

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

        self.connect("realize", self.realize_completion_window)

        self.get_scrolledwindow = self.get_scrolledwindow

        wrap_grab_window(completion_grab_window, self)

        completion_grab_window.connect("input-method-focus-in", self.input_method_focus_in)
        completion_grab_window.connect("input-method-commit", self.input_method_commit)

        self.keymap = {
            "Home" : self.treeview.select_first_item,
            "End" : self.treeview.select_last_item,
            "Page_Up" : self.treeview.scroll_page_up,
            "Page_Down" : self.treeview.scroll_page_down,
            "Up" : self.treeview.select_prev_item,
            "Down" : self.treeview.select_next_item,
            }

    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 treeview_press_return(self, treeview, select_items):
        if len(select_items) > 0:
            completion_grab_window.popup_grab_window_focus_out()
            global_event.emit("switch-to-detail-page", select_items[0].text)

    def set_input_method_cursor(self):
        entry_buffer = search_entry.entry.entry_buffer
        cursor_pos = entry_buffer.get_cursor_pos(entry_buffer.get_insert_index())[0]
        (entry_x, entry_y) = search_entry.translate_coordinates(search_entry.get_toplevel(), 0, 0)
        (window_x, window_y) = search_entry.get_toplevel().window.get_origin()

        completion_grab_window.im.set_cursor_location(
            gtk.gdk.Rectangle(
                window_x + entry_x + cursor_pos[0],
                window_y + entry_y + cursor_pos[1],
                1,
                cursor_pos[3]))

    def input_method_focus_in(self, grab_window, im):
        self.set_input_method_cursor()

    def input_method_commit(self, grab_window, im, input_text):
        self.set_input_method_cursor()
        search_entry.set_text("%s%s" % (search_entry.get_text(), input_text))

    def get_scrolledwindow(self):
        return self.treeview.scrolled_window

    def shape_completion_window_frame(self, widget, event):
        pass

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

        with cairo_disable_antialias(cr):
            cr.set_line_width(1)
            cr.set_source_rgba(*alpha_color_hex_to_cairo(ui_theme.get_alpha_color("window_frame_outside_3").get_color_info()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

            cr.set_source_rgba(*alpha_color_hex_to_cairo(ui_theme.get_alpha_color("window_frame_inside_2").get_color_info()))
            cr.rectangle(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2)
            cr.fill()

    def show(self, search_string, pkg_names):
        search_entry.entry.entry_buffer.grab_focus_flag = True

        self.treeview.delete_all_items()
        self.treeview.add_items(map(lambda pkg_name: TextItem(pkg_name, search_string), pkg_names))
        self.treeview.draw_area.grab_focus()

        (x, y) = get_widget_root_coordinate(search_entry, WIDGET_POS_BOTTOM_LEFT, False)
        self.move(x + self.window_offset_x, y + self.window_offset_y)
        self.show_all()

    def realize_completion_window(self, widget):
        self.set_default_size(self.window_width, self.window_height)
        self.set_geometry_hints(
            None,
            self.window_width,       # minimum width
            self.window_height,       # minimum height
            self.window_width,
            self.window_height,
            -1, -1, -1, -1, -1, -1
            )
开发者ID:kissthink,项目名称:deepin-store,代码行数:104,代码来源:completion_window.py


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