本文整理汇总了Python中dtk.ui.treeview.TreeView.get_highlight_item方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.get_highlight_item方法的具体用法?Python TreeView.get_highlight_item怎么用?Python TreeView.get_highlight_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.get_highlight_item方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PreferenceDialog
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import get_highlight_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: DetailWindow
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import get_highlight_item [as 别名]
class DetailWindow(Window):
'''
class docs
'''
def __init__(self):
'''
init docs
'''
Window.__init__(self, enable_resize=True)
self.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)
self.set_position(gtk.WIN_POS_CENTER)
self.set_skip_taskbar_hint(True)
self.set_skip_pager_hint(True)
self.resizable = True
self.classified_items = None
self.__init_pixbuf()
self.main_box = gtk.VBox()
self.titlebar_box = gtk.HBox()
self.toolbar_box = gtk.HBox()
self.toolbar_box.set_size_request(-1, TOOLBAR_HEIGHT)
self.main_view_box = gtk.HBox()
self.main_view_box.set_size_request(WINDOW_WIDTH,
WINDOW_HEIGHT - TITLEBAR_HEIGHT - TOOLBAR_HEIGHT - 23)
self.add_titlebar()
self.treeview_box = gtk.VBox()
self.main_view_box.pack_start(self.treeview_box, False, False)
self.listview_box = gtk.VBox()
self.main_view_box.pack_start(self.listview_box, True, True)
self.refresh_view() #add treeview and listview
self.main_box.pack_start(self.toolbar_box, False, False)
# self.main_box.pack_start(self.main_view_box, False, False)
self.main_box.pack_start(self.main_view_box, True, True)
# self.main_box.connect("expose-event", self.on_main_box_expose_event)
main_box_align = gtk.Alignment(0.5, 0.5, 1, 1)
main_box_align.set_padding(2, 2, 2, 2)
main_box_align.add(self.main_box)
self.window_frame.pack_start(self.titlebar_box, False, False)
self.window_frame.pack_start(main_box_align)
@property
def is_empty(self):
return not bool(len(self.classified_items))
def __init_pixbuf(self):
self.import_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_import.png"))
self.export_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_export.png"))
self.delete_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_delete.png"))
self.refresh_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_refresh.png"))
self.skin_preview_pixbuf = app_theme.get_pixbuf("frame.png")
def _init_data(self):
self.__init_data()
def __init_data(self):
self.classified_items = {}
rows = db.get_all()
for row in rows:
app_name = row[MESSAGE].app_name
self.classified_items.setdefault(app_name, []).append(row)
def add_to_view(self):
row = db.get_last()
# add to data
app_name = row[MESSAGE].app_name
if app_name in self.classified_items.keys():
self.classified_items[app_name].insert(0, row)
else:
self.classified_items.setdefault(app_name, []).insert(0, row)
self.treeview_add_item(app_name)
# add to view
if app_name == self.treeview.get_highlight_item().get_title():
self.factory.prepend_item(row)
def refresh_view(self):
self.__init_data()
if len(self.classified_items):
self.add_treeview()
self.current_showed_items = self.get_items_from_treeview_highlight()
self.add_listview(self.current_showed_items)
else:
align = gtk.Alignment(0.5, 0.5, 0, 0)
align.add(Label(_("(Empty)")))
container_remove_all(self.treeview_box)
container_remove_all(self.listview_box)
self.listview_box.pack_start(align, True, True)
self.main_view_box.show_all()
container_remove_all(self.toolbar_box)
#.........这里部分代码省略.........
示例3: PlaylistUI
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import get_highlight_item [as 别名]
#.........这里部分代码省略.........
def expose_toolbar_mask(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
cr.set_source_rgba(1, 1, 1, 0.95)
cr.rectangle(rect.x, rect.y, rect.width, rect.height)
cr.fill()
draw_line(cr, (rect.x, rect.y + 1),
(rect.x + rect.width, rect.y + 1), "#b0b0b0")
return False
def expose_entry_mask(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
draw_alpha_mask(cr, rect.x , rect.y, rect.width, rect.height, "toolbarEntry")
def draw_category_list_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, "layoutLeft")
def draw_item_mask(self, cr, x, y, width, height):
draw_vlinear(cr, x, y, width, height,
app_theme.get_shadow_color("editlistItemPress").get_color_info())
def __on_db_loaded(self, db):
if not MediaDB.get_playlists():
MediaDB.create_playlist("local", _("Default List"))
# From MediaDB loaded playlists.
init_items = [ListTreeItem(pl) for pl in MediaDB.get_playlists()]
self.category_list.add_items(init_items)
# Init Category_list.
self.category_list.set_highlight_item(self.get_categroy_item_by_index(self.get_save_item_index()))
self.current_item = self.category_list.get_highlight_item()
self.delete_source_id = self.current_item.song_view.connect("delete-select-items", self.parser_delete_items)
self.drag_source_id = self.current_item.song_view.connect("drag-data-received", self.parser_drag_event)
self.menu_source_id = self.current_item.song_view.connect("right-press-items", self.popup_detail_menu)
Player.set_source(self.current_item.song_view)
self.right_box.add(self.current_item.get_list_widget())
self.list_paned.show_all()
def __on_player_loaded(self, player):
if self.current_item:
self.current_item.song_view.reset_error_items()
self.current_item.song_view.set_highlight_song(Player.song)
def __play_and_add(self, widget, song):
self.current_item.song_view.add_songs(song, play=True)
def __add_songs_to_list(self, widget, songs):
if songs and self.current_item.song_view:
self.current_item.song_view.add_songs(songs)
def get_selected_song_view(self):
if self.current_item:
return self.current_item.song_view
def search_cb(self, widget, text):
if not self.search_flag:
self.cache_items = self.current_item.song_view.get_items()
# Clear song_view select status
self.current_item.song_view.clear_highlight()
self.current_item.song_view.select_rows = []