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


Python TreeView.set_column_titles方法代码示例

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


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

示例1: PluginsManager

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_column_titles [as 别名]
class PluginsManager(gtk.VBox):
    
    def __init__(self):
        gtk.VBox.__init__(self)
        
        self.set_spacing(5)
        self.plugins = utils.get_main_window().plugins
        self.plugins_view = TreeView()
        self.plugins_view.set_expand_column(0)
        self.plugins_view.draw_mask = self.plugins_view_draw_mask
        self.plugins_view.set_size_request(420, 330)        
        self.plugins_view.connect("single-click-item", self.on_plugins_view_single_click)
                
        self.plugins_view.set_column_titles([_("Add-on"), _("Version"), _("Enable"), ""],
                                            (self.sort_by_title, self.sort_by_title,
                                             self.sort_by_title, self.sort_by_title))
        plugins_view_align = set_widget_gravity(self.plugins_view, gravity=(1, 1, 1, 1),
                                                paddings=(10, 0, 0, 0))
        
        self.plugin_infos = PluginInfos()
        self.plugin_infos.set_size_request(420, 90)
        
        # plugin info
        self.pack_start(plugins_view_align, False, True)
        self.pack_start(self.plugin_infos, False, True)
        
    def sort_by_title(self, items, reverse):    
        return sorted(items, key=lambda item: item.plugin, reverse=reverse)
    
    def plugins_view_draw_mask(self, cr, x, y, width, height):
        draw_alpha_mask(cr, x, y, width, height, "layoutLeft")
        
    def flush_plugins(self):
        self.__load_plugin_list()
        
    def __load_plugin_list(self):    
        
        # clear plugins_view items.
        self.plugins_view.clear()
        
        plugins = self.plugins.list_installed_plugins()
        plugins_list = []
        failed_list = []
        
        for plugin in plugins:
            try:
                info = self.plugins.get_plugin_info(plugin)
            except Exception:    
                failed_list.append(plugin)
                continue
            
            enabled  = plugin in self.plugins.enabled_plugins
            plugins_list.append((plugin, info, enabled))
            
        plugins_list.sort(key=lambda x: locale.strxfrm(x[1]["Name"]))
        plugins_items = [PluginItem(*args) for args in plugins_list]
        self.plugins_view.add_items(plugins_items)
        
    def on_plugins_view_single_click(self, widget, item, column, x, y):
        if column == 2:
            plugin = item.plugin
            will_enable = not item.enabled
            if will_enable:
                try:
                    self.plugins.enable_plugin(plugin)
                except Exception, e:    
                    print e
                    return
            else:    
                try:
                    self.plugins.disable_plugin(plugin)
                except Exception, e:    
                    print e
                    return
            item.toggle_enabled()    
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:77,代码来源:plugins_view.py

示例2: ListviewFactory

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_column_titles [as 别名]
class ListviewFactory(object):
    '''
    class docs
    '''
	
    def __init__(self, items, owner):
        '''
        init docs
        '''
        self.items = [ListViewItem(x, owner) for x in items]
        self.owner = owner
        self.count_per_page = 10 if self.owner == "brief" else 20
        self.listview = None
        
        self.page_count = 0
        self.page_index = 0
        self.paged_items = self.get_paged_items()
        
        self.init_listview()
        
    def prepend_item(self, item):
        if self.listview:
            self.listview.add_items([ListViewItem(item, self.owner)], insert_pos=0)
     
    def append_item(self, item):
        if self.listview:
            self.listview.add_items([ListViewItem(item, self.owner)])
        
    def on_listview_button_pressed(self, widget, event, listview):
        x = event.x
        y = event.y
        
        if event.button == 1:
            for item in listview.get_items():
                for index, rect in enumerate(item.pointer_hand_rectangles):
                    if is_in_rect((x, y), rect):
                        action = item.message["hints"]["x-deepin-hyperlinks"][index]
                        
                        if action.has_key("href"):
                            webbrowser.open_new_tab(action.get("href"))
                            
                            return
                        
            
    
    def on_listview_motion_notify(self, widget, event, listview):
        x = event.x
        y = event.y
        flag = False
        for item in listview.get_items():
            if flag:
                break
            for rect in item.pointer_hand_rectangles:
                if is_in_rect((x, y), rect):
                    flag = True
                    break
        if flag:
            widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
        else:
            widget.window.set_cursor(None)
         
        
    def init_listview(self):
        '''
        docs
        '''
        items = self.paged_items[self.page_index]

        self.listview = TreeView(items)
        self.listview.draw_mask = self.on_listview_draw_mask
        self.listview.set_expand_column(0)
        
        if self.owner == "detail":
            self.listview.set_column_titles([_("Content of messages"), _("Time")],
                                            [self.sort_by_content, self.sort_by_time])
        
        self.listview.draw_area.connect_after("button-press-event", self.on_listview_button_pressed, self.listview)
        self.listview.draw_area.connect_after("motion-notify-event", self.on_listview_motion_notify, self.listview)
        self.listview.connect("right-press-items", self.on_listview_right_press_items)
        self.listview.scrolled_window.connect("vscrollbar-state-changed", self.update_listview)
        
        event_manager.emit("listview-items-added", items)
        
    def update_listview(self, widget, state):
        if state == "bottom":
            if self.page_index < self.page_count - 1:
                self.page_index = self.page_index + 1
                
                items = self.paged_items[self.page_index]
                self.listview.add_items(items)
                
                event_manager.emit("listview-items-added", items)
                
    def on_listview_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_listview_right_press_items(self, widget, root_x, root_y, current_item, select_items):
        if self.owner == "detail":        
#.........这里部分代码省略.........
开发者ID:electricface,项目名称:deepin-notifications,代码行数:103,代码来源:listview_factory.py

示例3: TreeView

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_column_titles [as 别名]
    
    # Add TreeView.
    print os.path.expanduser("~")
    treeview = TreeView(get_dir_items(os.path.expanduser("~")))
    
    # expand column.
    treeview.set_expand_column(3)
    
    # hide column
    treeview.set_hide_columns([1, 2])
    
    #treeview.set_highlight_item(treeview.get_items()[35])
    treeview.connect("delete-select-items", m_delete_select_items)
    treeview.connect("button-press-item", m_button_press_item)
    treeview.connect("double-click-item", m_double_click_item)
    treeview.connect("right-press-items", m_right_press_items)
    treeview.connect("single-click-item", m_single_click_item)
    # treeview = TreeView(get_dir_items("/"))
    treeview_align = gtk.Alignment()
    treeview_align.set(0.5, 0.5, 1, 1)
    treeview_align.set_padding(0, 2, 2, 2)
    
    treeview.set_column_titles(["文件名", "大小", "类型", "修改时间"],
                               [sort_by_name, sort_by_size, sort_by_type, sort_by_mtime])
    
    treeview_align.add(treeview)
    application.main_box.pack_start(treeview_align)
    application.window.connect("show", lambda w: treeview.visible_highlight())

    application.run()
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:32,代码来源:treeview_demo.py

示例4: SearchUI

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_column_titles [as 别名]
class SearchUI(DialogBox):
    def __init__(self):
        DialogBox.__init__(
            self, _("Lyrics search"), 460, 300, DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all, 
            modal=False, window_hint=None, skip_taskbar_hint=False, window_pos=gtk.WIN_POS_CENTER)
        
        self.artist_entry = InputEntry()
        self.artist_entry.set_size(130, 23)
        self.title_entry = InputEntry()
        self.title_entry.set_size(130, 23)
        artist_label = Label(_("Artist:"))
        title_label = Label(_("Title:"))
        right_align = gtk.Alignment()
        right_align.set(0, 0, 0, 1)
        
        self.search_button = Button(_("Search"))
        self.search_button.connect("clicked", self.search_lyric_cb)
        self.process_id = 0
        
        info_box = gtk.HBox(spacing=25)
        
        control_box = gtk.HBox(spacing=5)
        title_box = gtk.HBox(spacing=5)        
        title_box.pack_start(title_label, False, False)
        title_box.pack_start(self.title_entry)
        artist_box = gtk.HBox(spacing=5)
        artist_box.pack_start(artist_label, False, False)
        artist_box.pack_start(self.artist_entry)
        control_box.pack_start(title_box, False, False)
        control_box.pack_start(artist_box, False, False)
        
        info_box.pack_start(control_box, False, False)
        info_box.pack_start(self.search_button, False, False)
        
        sort_items = [ lambda items, reverse : self.sort_by_key(items, reverse, "title"),
                       lambda items, reverse : self.sort_by_key(items, reverse, "artist")]
        self.result_view = TreeView()
        self.result_view.set_expand_column(0)
        self.result_view.connect("double-click-item", self.double_click_cb)
        self.result_view.set_column_titles([_("Title"), _("Artist")], sort_items)
        self.result_view.draw_mask = self.draw_view_mask
        
        self.prompt_label = Label("")
        download_button = Button(_("Download"))
        download_button.connect("clicked", self.download_lyric_cb)
        cancel_button = Button(_("Close"))
        cancel_button.connect("clicked", lambda w: self.hide_all())
        
        info_box_align = gtk.Alignment()
        info_box_align.set_padding(5, 0, 5, 0)
        info_box_align.add(info_box)
        
        self.body_box.set_spacing(5)
        self.body_box.pack_start(info_box_align, False, False)
        self.body_box.pack_start(self.result_view, True, True)
        self.left_button_box.set_buttons([self.prompt_label])
        self.right_button_box.set_buttons([download_button, cancel_button])
        self.lrc_manager = LrcManager()
        
    def show_window(self):    
        DialogBox.show_window(self)
        self.present()
                
    def draw_view_mask(self, cr, x, y, width, height):            
        draw_alpha_mask(cr, x, y, width, height, "layoutMiddle")
        
    def sort_by_key(self, items, sort_reverse, sort_key):    
        return sorted(items, reverse=sort_reverse, key=lambda item: getattr(item, sort_key))
        
    def double_click_cb(self, widget, item, colume, x, y):   
        self.download_lyric_cb(widget)
        
    def search_engine(self, artist, title, pid):    
        
        ting_result = poster.query_lrc_info(artist, title)
        self.render_lyrics(ting_result, pid=pid)
        
        ttplayer_result = TTPlayer().request(artist, title)
        self.render_lyrics(ttplayer_result, pid=pid)
        
        ttpod_result = TTPod().request(artist, title)        
        self.render_lyrics(ttpod_result, pid=pid)
        
        duomi_result = DUOMI().request(artist, title)
        self.render_lyrics(duomi_result, pid=pid, last=True)
        
        
    def search_lyric_cb(self, widget):
        self.result_view.clear()
        artist = self.artist_entry.entry.get_text()
        title = self.title_entry.entry.get_text()
        # widget.set_sensitive(False)
        self.prompt_label.set_text(_("Now searching..."))
        if artist == "" and title == "":
            self.prompt_label.set_text(_("Not found!"))
            return
        self.process_id += 1
        utils.ThreadLoad(self.search_engine, artist, title, self.process_id).start()
        
    @post_gui
#.........这里部分代码省略.........
开发者ID:electricface,项目名称:deepin-music-player,代码行数:103,代码来源:lyrics_search.py

示例5: SessionView

# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_column_titles [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.set_column_titles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。