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


Python TreeView.visible_item方法代码示例

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


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

示例1: HomePage

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import visible_item [as 别名]
class HomePage(gtk.HBox):
    '''
    class docs
    '''
	
    def __init__(self, data_manager, recommend_status):
        '''
        init docs
        '''
        # Init.
        gtk.HBox.__init__(self)
        self.data_manager = data_manager
        self.recommend_status = recommend_status
        
        self.background_box = BackgroundBox()
        self.background_box.draw_mask = self.draw_mask
        self.sidebar_box = gtk.VBox()
        self.page_box = gtk.VBox()
        self.sidebar_box.set_size_request(CATEGORY_VIEW_WIDTH, -1)
        
        self.canopy = gtk.VBox()
        self.canopy.set_size_request(-1, 19)
        
        self.search_align = gtk.Alignment()
        self.search_align.set(0.5, 0.5, 0, 0)
        self.search_align.set_padding(15, 5, 13, 13)
        self.search_align.add(search_entry)
        
        self.in_press = False
        self.press_return = False
        self.press_id = 0
        self.show_timeout_id = None
        self.entry_changed = False
        
        search_entry.entry.connect("changed", self.search_entry_changed)
        search_entry.entry.connect("key-press-event", self.search_entry_key_press)
        search_entry.entry.connect("key-release-event", self.search_entry_key_release)
        search_entry.connect("action-active", lambda entry, search_string: self.show_search_page(search_string))
        search_entry.entry.connect("press-return", lambda entry: self.show_search_page(entry.get_text(), True))
        
        self.recommend_item = RecommendItem(data_manager, self.recommend_status)
       
        category_items = []
        for (index, first_category_name) in enumerate(data_manager.get_first_category()):
            category_items.append(CategoryItem(index+1, first_category_name, data_manager))
        
        self.category_view = TreeView(
            [self.recommend_item] + category_items,
            enable_drag_drop=False,
            enable_multiple_select=False,
            expand_column=0,
            )
        self.category_view.draw_mask = self.draw_mask
        self.category_view.set_size_request(-1, 470)

        self.category_view_align = gtk.Alignment()
        self.category_view_align.set(0.5, 0.5, 1, 1)
        self.category_view_align.set_padding(10, 10, 0, 0)
        self.category_view_align.add(self.category_view)
        
        self.background_box.pack_start(self.canopy, False, False)
        self.background_box.pack_start(self.search_align, True, True)
        self.background_box.pack_end(self.category_view_align, False, False)
        self.sidebar_box.pack_start(self.background_box, False, False)
        
        self.split_line = gtk.VBox()
        self.split_line.set_size_request(1, -1)
        
        self.pack_start(self.sidebar_box, False, False)
        self.pack_start(self.split_line, False, False)
        self.pack_start(self.page_box, True, True)
        
        self.canopy.connect("expose-event", self.expose_canopy)
        self.split_line.connect("expose-event", self.expose_split_line)
        
        global_event.register_event("show-pkg-view", self.show_pkg_view)
        global_event.register_event("category-expand", self.category_expand_handler)

    def category_expand_handler(self, item):
        self.category_view.visible_item(item.child_items[-1])
        
    def jump_to_category(self, first_category_name, second_category_name):
        
        for item in self.category_view.visible_items:
            if isinstance(item, CategoryItem) and item.is_expand:
                item.unexpand()
        
        for item in self.category_view.visible_items:
            if isinstance(item, CategoryItem) and item.first_category_name == first_category_name:
                item.expand()
                break

        for item in self.category_view.visible_items:
            if isinstance(item, SecondCategoryItem) and item.second_category_name == second_category_name:
                self.category_view.select_items([item])
                self.category_view.visible_item(item)
                item.button_press(0, 0, 0)
                break
        
    def draw_mask(self, cr, x, y, w, h):
#.........这里部分代码省略.........
开发者ID:electricface,项目名称:deepin-software-center,代码行数:103,代码来源:home_page.py

示例2: MirrorsBox

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

        self.current_mirror_item = None

        self.select_best_mirror_button_texts = {
                "normal": _("Select the best mirror"),
                "wait": _("Waiting"),
                "success": _("Successfully")
                }

        self.main_box.pack_start(self.create_mirror_select_table(), True, True)
        self.main_box.pack_start(self.create_source_update_frequency_table(), False, True)
        self.mirror_test_obj = None

        global_event.register_event("mirror-test-finished", self.finish_mirror_test)
        global_event.register_event("cancel-mirror-test", self.cancel_mirror_test)
        global_event.register_event("mirror-backend-changed", self.mirror_changed_handler)

    def create_source_update_frequency_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        dir_title_label = Label(_("Refresh package lists"))

        # auto update check button
        self.is_auto_update_button = CheckButton(label_text=_('Upgrade automatically'))
        self.is_auto_update_button.connect('released', self.change_auto_update)
        self.is_auto_update_button.set_active(utils.is_auto_update())

        self.update_label = Label(_("Time interval: "))
        self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1)
        self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
        self.hour_lablel = Label(_(" hour"))
        self.hour_lablel.set_size_request(50, 12)
        spin_hbox = gtk.HBox(spacing=3)
        spin_hbox.pack_start(self.update_label, False, False)
        spin_hbox.pack_start(self.update_spin, False, False)
        spin_hbox.pack_start(self.hour_lablel, False, False)

        main_table.attach(dir_title_label, 0, 2, 0, 1, yoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xoptions=gtk.FILL)
        main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
        return main_table

    def change_auto_update(self, widget, data=None):
        widget_active = widget.get_active()
        self.update_spin.set_sensitive(widget_active)
        self.update_label.set_sensitive(widget_active)
        self.hour_lablel.set_sensitive(widget_active)

        utils.set_auto_update(widget_active)

        daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
        if widget_active and not daemon_running:
            dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
        elif not widget_active and daemon_running:
            session = dbus.SessionBus()
            dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
            iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
            iface.quit()

    def select_best_mirror(self, widget):
        widget.set_label(self.select_best_mirror_button_texts["wait"])
        widget.set_sensitive(False)
        global_event.emit("toggle-waiting-dialog", True)
        utils.ThreadMethod(self.change_to_nearest_mirror_thread, (widget, )).start()

    def cancel_mirror_test(self):
        if self.mirror_test_obj:
            self.mirror_test_obj.cancel()
            self.mirror_test_obj = None
            self.finish_mirror_test("")

    def change_to_nearest_mirror_thread(self, widget):
        from mirror_speed.ip_detect import get_nearest_mirrors
        hostnames = get_nearest_mirrors()
        self.mirror_test_obj = MirrorTest(hostnames)
        hostname = self.mirror_test_obj.run()
        for mirror in self.mirrors_list:
            if mirror.hostname == hostname:
                global_event.emit("mirror-test-finished", mirror)
                break

    def finish_mirror_test(self, mirror):
        for item in self.mirror_view.visible_items:
            if item.mirror == mirror:
                self.mirror_view.visible_item(item)
        self.select_best_mirror_button.set_sensitive(True)
        self.select_best_mirror_button.set_label(self.select_best_mirror_button_texts["normal"])

    def create_mirror_select_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        mirror_select_title = Label(_("Select mirror"))
        self.select_best_mirror_button = Button(self.select_best_mirror_button_texts["normal"])
#.........这里部分代码省略.........
开发者ID:kissthink,项目名称:deepin-store,代码行数:103,代码来源:preference.py


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