本文整理汇总了Python中dtk.ui.treeview.TreeView.add_item方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.add_item方法的具体用法?Python TreeView.add_item怎么用?Python TreeView.add_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.add_item方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PreferenceDialog
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import add_item [as 别名]
class PreferenceDialog(DialogBox):
def __init__(self):
super(PreferenceDialog, self).__init__(_("Preference"), 575, 495,
mask_type=DIALOG_MASK_MULTIPLE_PAGE,
close_callback=self.hide_all)
self.set_position(gtk.WIN_POS_CENTER)
self.main_box = gtk.VBox()
close_button = Button(_("Close"))
close_button.connect("clicked", lambda w: self.hide_all())
# Init widget.
self.general_setting = GeneralSetting()
self.hotkey_setting = HotKeySetting()
self.desktop_lyrics_setting = DesktopLyricsSetting()
self.scroll_lyrics_setting = ScrollLyricsSetting()
# Category bar
self.category_bar = TreeView(font_x_padding=20)
self.category_bar.draw_mask = self.draw_treeview_mask
self.general_category_item = CategoryItem(_("General"), self.general_setting)
self.category_bar.add_item(None, self.general_category_item)
self.category_bar.add_item(None, CategoryItem(_("Hotkeys"), self.hotkey_setting))
lyrics_node = self.category_bar.add_item(None, CategoryItem(_("Lyrics")))
self.category_bar.add_item(lyrics_node, CategoryItem(_("Desktop"), self.desktop_lyrics_setting))
self.category_bar.add_item(lyrics_node, CategoryItem(_("Window"), self.scroll_lyrics_setting))
self.category_bar.add_item(None, CategoryItem(_("About us"), AboutBox()))
self.category_bar.connect("single-click-item", self.category_single_click_cb)
self.category_bar.set_highlight_index(0)
category_box = gtk.VBox()
background_box = BackgroundBox()
background_box.set_size_request(132, 11)
background_box.draw_mask = self.draw_treeview_mask
category_box.pack_start(background_box, False, False)
category_scrolled_window = ScrolledWindow()
category_scrolled_window.add_child(self.category_bar)
category_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
category_scrolled_window.set_size_request(132, 516)
category_scrolled_window_align = gtk.Alignment()
category_scrolled_window_align.set(0, 0, 1, 1,)
category_scrolled_window_align.set_padding(0, 1, 0, 0)
category_scrolled_window_align.add(category_scrolled_window)
category_box.pack_start(category_scrolled_window_align, True, True)
# Pack widget.
left_box = gtk.VBox()
self.right_box = gtk.VBox()
left_box.add(category_box)
self.right_box.add(self.general_category_item.get_allocated_widget())
right_align = gtk.Alignment()
right_align.set_padding(0, 0, 10, 0)
right_align.add(self.right_box)
body_box = gtk.HBox()
body_box.pack_start(left_box, False, False)
body_box.pack_start(right_align, False, False)
self.main_box.add(body_box)
# DialogBox code.
self.body_box.pack_start(self.main_box, True, True)
self.right_button_box.set_buttons([close_button])
def switch_lyrics_page(self, index=3):
self.category_bar.tree_list[2].show_child_items_bool = True
self.category_bar.sort()
self.category_bar.queue_draw()
self.category_bar.set_highlight_index(index)
highlight_item = self.category_bar.get_highlight_item()
self.category_single_click_cb(None, highlight_item)
def show_scroll_lyrics_page(self):
self.switch_lyrics_page(4)
self.show_all()
def show_desktop_lyrics_page(self):
self.switch_lyrics_page(3)
self.show_all()
def draw_treeview_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, ("#FFFFFF", 0.9))
def category_single_click_cb(self, widget, item):
if item.get_allocated_widget():
switch_tab(self.right_box, item.get_allocated_widget())
示例2: tree_view_single_click_cb
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import add_item [as 别名]
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):
pass
tree_view = TreeView()
tree_view_scrolled_window = ScrolledWindow()
tree_view_scrolled_window.add_child(tree_view)
tree_view.connect("single-click-item", tree_view_single_click_cb)
tab_5_box.pack_start(tree_view_scrolled_window)
wuhan_node = tree_view.add_item(None, TreeViewItem("Linux Deepin"))
wuhan_dev_node = tree_view.add_item(wuhan_node, TreeViewItem("test1"))
wuhan_des_node = tree_view.add_item(wuhan_node, TreeViewItem("test2"))
wuhan_sys_node = tree_view.add_item(wuhan_node, TreeViewItem("test3"))
tree_view.add_item(wuhan_dev_node, TreeViewItem("Deepin Music Player"))
tree_view.add_item(wuhan_dev_node, TreeViewItem("Deepin Media Player"))
tree_view.add_item(wuhan_dev_node, TreeViewItem("Deepin Software Center"))
tree_view.add_item(wuhan_sys_node, TreeViewItem("Deepin Talk"))
tree_view.add_item(wuhan_sys_node, TreeViewItem("Deepin IM"))
tree_view.add_item(wuhan_sys_node, TreeViewItem("Deepin Reader"))
tree_view.add_item(wuhan_des_node, TreeViewItem("ZHL"))
tree_view.add_item(wuhan_des_node, TreeViewItem("ZHL"))