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


Python TreeView.show方法代码示例

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


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

示例1: SessionView

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

    def __init__(self):
        gtk.VBox.__init__(self)
        self.open_dialog = False
        self.tmp_editing_session = None
        
        # UI style
        style.draw_background_color(self)
        self.tree = TreeView([],enable_drag_drop=False,
                             enable_hover=True,
                             enable_multiple_select=False,
                             )
        self.tree.set_expand_column(3)
        self.tree.set_column_titles((_("Active"), _("Application"), _("Description"), _("Exec")),)

        self.tree.set_size_request(800, -1)
        self.tree.connect("right-press-items", self.right_press_item)

        self.tree.draw_mask = self.draw_mask
        self.tree.add_items(self.get_list())
        align = gtk.Alignment(0, 0, 0, 1)
        align.set_padding(15, 0, 20, 20)
        align.add(self.tree)
        align.connect("expose-event", self.expose_line)


        add_button = Button(_("New"))
        self.delete_button = Button(_("Delete"))
        add_button.connect("clicked", self.add_autostart)
        self.delete_button.connect("clicked", self.delete_autostart)
        self.delete_button.set_sensitive(False)
        
        foot_box = FootBox(adjustment=15)
        foot_box.set_buttons([add_button, self.delete_button])
        self.pack_start(align, True, True)
        
        self.pack_end(foot_box, False, False)
        #self.pack_end(self.new_box, False, False)

        self.show_all()

        self._init_monitor()

    def disable_delete_button(self, value):
        self.delete_button.set_sensitive(not value)
    def _init_monitor(self):
        self.library_monitor = LibraryMonitor(get_user_config_dir())
        self.library_monitor.set_property("monitored", True)
        self.library_monitor.connect("file-added", self.refresh_list)
        self.library_monitor.connect("location-removed", self.refresh_list)

    def right_press_item(self, widget,  x_root, y_root, current_item, select_items):
        self.tmp_editing_session = current_item.item
        for item in select_items:
            item.unselect()
        if current_item != None:
            current_item.select()
            if self.open_dialog == False:
                dialog = NewSessionDialog(confirm_callback = self.edit_done, cancel_callback = self.cancel_callback)
                dialog.name_entry.set_text(current_item.item.name)
                dialog.exec_entry.set_text(current_item.item.exec_)
                dialog.desc_entry.set_text(current_item.item.comment)
                dialog.place_center()
                dialog.show_all()
                self.open_dialog = True

    def create_session_item(self, dialog):
        name = dialog.name_entry.get_text()
        exec_ = dialog.exec_entry.get_text()
        comment = dialog.desc_entry.get_text()
        session_manager.add(name, exec_, comment)
        self.open_dialog = False

    def expose_line(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        style.draw_out_line(cr, rect, exclude=["left", "right", "top"])
    
    def sort_method(self):
        pass

    def add_autostart(self, widget):
        if self.open_dialog == False:
            dialog = NewSessionDialog(confirm_callback= self.create_session_item, cancel_callback = self.cancel_callback)
            dialog.show_all()
            self.open_dialog = True

    def delete_autostart(self, widget):
        items = map(lambda row: self.tree.visible_items[row], self.tree.select_rows)
        item = items[0].item
        item.delete()
        self.tree.delete_select_items()
        if self.tree.visible_items == []:
            self.tree.add_items([NothingItem()])

    def edit_done(self, dialog):
        self.tmp_editing_session.set_name(dialog.name_entry.get_text())
        self.tmp_editing_session.set_exec(dialog.exec_entry.get_text())
        self.tmp_editing_session.set_comment(dialog.desc_entry.get_text())
#.........这里部分代码省略.........
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:103,代码来源:session_view.py


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