本文整理汇总了Python中dtk.ui.iconview.IconView类的典型用法代码示例。如果您正苦于以下问题:Python IconView类的具体用法?Python IconView怎么用?Python IconView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IconView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,
tag,
limit=10,
has_add=True,
fetch_add_item=True,
padding_x=0,
padding_y=0):
IconView.__init__(self, padding_x=padding_x, padding_y=padding_y)
targets = [("text/deepin-radios", gtk.TARGET_SAME_APP, 1),
("text/uri-list", 0, 2)]
self.drag_source_set(gtk.gdk.BUTTON1_MASK, targets,
gtk.gdk.ACTION_COPY)
self.connect("drag-data-get", self.__on_drag_data_get)
self.tag = tag
self.__start = 0
self.__limit = limit
self.__fetch_thread_id = 0
self.__render_id = 0
self.__genre_id = "335"
self.__keyword = ""
self.__total = None
# self.more_item = MoreIconItem()
self.fetch_add_item = fetch_add_item
self.connect("single-click-item", self.on_iconview_single_click_item)
self.connect("motion-item", self.on_motion_item)
# if has_add:
# self.add_items([self.more_item])
self.is_finish = False
示例2: __init__
def __init__(self, network_interface, padding_x=8, padding_y=10, download_dir=None):
IconView.__init__(self, padding_x=padding_x, padding_y=padding_y)
self.download_dir = download_dir
self.connect("double-click-item", self.__on_double_click_item)
self.connect("single-click-item", self.__on_single_click_item)
self.__fetch_thread_id = 0
self.network_interface = network_interface
示例3: __init__
def __init__(self, padding_x=0, padding_y=0, status_box=None):
IconView.__init__(self, padding_x=padding_x, padding_y=padding_y)
self.untitled_theme = theme_manager.get_untitled_theme()
self.status_box = status_box
self.__is_double_click = False
self.__single_click_item = None
self.connect("double-click-item", self.__on_double_click_item)
self.connect("single-click-item", self.__on_single_click_item)
self.connect("right-click-item", self.__on_right_click_item)
event_manager.add_callback("clear-systemview-highlight", self.clear_highlight_status)
gobject.timeout_add(500, lambda : self.__init_themes())
示例4: AlbumSummaryView
class AlbumSummaryView(gtk.VBox):
'''
class docs
'''
def __init__(self):
'''
init docs
'''
gtk.VBox.__init__(self)
self.scrolled_window = ScrolledWindow()
self.iconview = IconView()
self.iconview.draw_mask = self.draw_mask
self.scrolled_window.add_child(self.iconview)
self.pack_start(self.scrolled_window, True, True)
global_event.register_event('download-album-infos-finish', self.update_item)
def try_fetch_data(self):
FetchAlbumData(LANGUAGE).start()
@post_gui
def update_item(self, data):
items = []
if data:
for album_info in data:
items.append(AlbumSummaryItem(album_info))
items.sort(key=attrgetter('album_order'), reverse=True)
self.iconview.add_items(items)
global_event.emit('switch-to-album-summary-view')
else:
global_event.emit('switch-to-network-problem-view')
def draw_mask(self, cr, x, y, w, h):
'''
Draw mask interface.
@param cr: Cairo context.
@param x: X coordiante of draw area.
@param y: Y coordiante of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
'''
draw_vlinear(cr, x, y, w, h,
[(0, ("#FFFFFF", 0.9)),
(1, ("#FFFFFF", 0.9)),]
)
示例5: __init__
def __init__(self, monitor_dir, padding_x=8, padding_y=10, filter_dir=None, add_system=False):
IconView.__init__(self, padding_x=padding_x, padding_y=padding_y)
self.system_wallpapper_dir = get_system_wallpaper_dirs()[1]
self.is_file_added = False
self.monitor_dir = monitor_dir
self.filter_dir = filter_dir
self.library_monitor = LibraryMonitor(monitor_dir)
self.library_monitor.set_property("monitored", True)
self.library_monitor.connect("file-added", self.on_library_file_added)
self.library_monitor.connect("folder-added", self.on_library_folder_added)
self.library_monitor.connect("location-removed", self.on_library_location_removed)
self.__image_index = 0
self.__init_monitor_images(add_system)
示例6: get_icon_view
def get_icon_view(self, padding_x=0, padding_y=10):
''' Draggable IconView '''
icon_view = IconView(padding_x, padding_y)
targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2)]
icon_view.drag_source_set(gtk.gdk.BUTTON1_MASK, targets, gtk.gdk.ACTION_COPY)
icon_view.connect("drag-data-get", self.__on_drag_data_get)
icon_view.connect("double-click-item", self.__on_double_click_item)
icon_view.connect("single-click-item", self.__on_single_click_item)
icon_view.connect("right-click-item", self.__on_right_click_item)
icon_view.draw_mask = self.on_iconview_draw_mask
scrolled_window = ScrolledWindow()
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled_window.add_child(icon_view)
return icon_view, scrolled_window
示例7: button_press
def button_press(self, column, offset_x, offset_y):
# init Loading widget
loading_box = LoadingBox()
global_event.emit("show-pkg-view", loading_box)
self.page_box = gtk.VBox()
self.all_pkg_names = self.data_manager.get_second_category_packages(self.second_category_name)
self.message_bar = MessageBar(18)
self.message_bar.set_message(_("%s > %s : %s applications") % (
get_category_name(self.first_category_name),
get_category_name(self.second_category_name),
len(self.all_pkg_names),
))
self.pkg_icon_view = IconView()
self.pkg_icon_view.connect("motion-notify-item", tooltip_aciton)
if len(self.all_pkg_names) > LOAD_ITEMS_NUMBER:
self.load_new_items(self.all_pkg_names[:LOAD_ITEMS_NUMBER])
else:
self.load_new_items(self.all_pkg_names)
self.pkg_icon_scrolled_window = ScrolledWindow()
self.pkg_icon_scrolled_window.connect("vscrollbar-state-changed", self.scrolled_window_vscrollbar_handler)
self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
self.pkg_icon_view.draw_mask = self.draw_mask
self.pkg_icon_view.draw_row_mask = self.draw_row_mask
self.page_box.pack_start(self.message_bar, False, False)
self.page_box.pack_start(self.pkg_icon_scrolled_window, True, True)
global_event.emit("update-current-status-pkg-page", self.pkg_icon_view)
示例8: __init__
def __init__(self, padding_x=8, padding_y=10):
IconView.__init__(self, padding_x=padding_x, padding_y=padding_y)
self.add_item = AddItem()
self.add_items([self.add_item])
self.connect("right-click-item", self.__on_right_click_item)
event_manager.add_callback("add-wallpapers", self.on_add_wallpapers)
event_manager.add_callback("add-download-wallpapers", self.on_add_wallpapers)
event_manager.add_callback("wallpapers-deleted", self.on_wallpapers_deleted)
event_manager.add_callback("select-wallpaper", self.on_wallpaper_select)
event_manager.add_callback("apply-wallpaper", self.on_wallpaper_apply)
event_manager.add_callback("apply-download-wallpaper", self.on_download_wallpaper_apply)
event_manager.add_callback("delete-wallpaper-link", self.__on_delete_wallpaper_link)
self.theme = None
示例9: __init__
def __init__(self):
'''
init docs
'''
gtk.VBox.__init__(self)
self.scrolled_window = ScrolledWindow()
self.iconview = IconView()
self.iconview.draw_mask = self.draw_mask
self.scrolled_window.add_child(self.iconview)
self.pack_start(self.scrolled_window, True, True)
global_event.register_event('download-album-infos-finish', self.update_item)
示例10: get_pkg_icon_view_page
def get_pkg_icon_view_page(self):
items = []
for info in self.recommend_infos:
items.append(RecommendIconItem(info))
self.pkg_icon_view = IconView()
self.pkg_icon_view.add_items(items)
self.pkg_icon_scrolled_window = ScrolledWindow()
self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
self.pkg_icon_view.draw_mask = self.draw_mask
self.pkg_icon_view_align = gtk.Alignment()
self.pkg_icon_view_align.set(0.5, 0.5, 1, 1)
self.pkg_icon_view_align.set_padding(6, 0, 1, 11)
self.pkg_icon_view_align.add(self.pkg_icon_scrolled_window)
return self.pkg_icon_view_align
示例11: __init__
def __init__(self, items=None):
ScrolledWindow.__init__(self, 0, 0)
self.device_iconview = IconView()
self.device_iconview.connect("right-click-item", self.__on_right_click_item)
self.device_iconview.draw_mask = self.draw_mask
if items:
self.device_iconview.add_items(items)
self.device_scrolledwindow = ScrolledWindow()
self.device_scrolledwindow.add_child(self.device_iconview)
self.add_child(self.device_scrolledwindow)
event_manager.add_callback("text", self.__on_text)
event_manager.add_callback("hide-text", self.__on_hide_text)
示例12: single_click
def single_click(self, column, offset_x, offset_y):
# init Loading widget
loading_box = LoadingBox()
global_event.emit("show-pkg-view", loading_box)
self.page_box = gtk.VBox()
self.all_pkg_names = []
self.all_desktop_infos = {}
for (second_category, pkg_dict) in self.second_category_items.items():
for (pkg_name, desktop_info) in pkg_dict.items():
self.all_pkg_names.append(pkg_name)
self.all_desktop_infos[pkg_name] = desktop_info
self.message_bar = MessageBar(18)
self.message_bar.set_message(_("%s: %s applications") % (
get_category_name(self.first_category_name),
len(self.all_pkg_names),
))
self.pkg_icon_view = IconView()
self.pkg_icon_view.connect("motion-notify-item", tooltip_aciton)
if len(self.all_pkg_names) > LOAD_ITEMS_NUMBER:
self.load_new_items(self.all_pkg_names[:LOAD_ITEMS_NUMBER])
else:
self.load_new_items(self.all_pkg_names)
self.pkg_icon_view.draw_mask = self.draw_mask
self.pkg_icon_view.draw_row_mask = self.draw_row_mask
self.pkg_icon_scrolled_window = ScrolledWindow()
self.pkg_icon_scrolled_window.connect("vscrollbar-state-changed", self.scrolled_window_vscrollbar_handler)
self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
self.page_box.pack_start(self.message_bar, False, False)
self.page_box.pack_start(self.pkg_icon_scrolled_window, True, True)
global_event.emit("update-current-status-pkg-page", self.pkg_icon_view)
示例13: Browser
class Browser(gtk.VBox, SignalContainer):
def __init__(self, db_query):
gtk.VBox.__init__(self)
SignalContainer.__init__(self)
self.__db_query = db_query
self._tree = {}
self.__selected_tag = {"album": [], "artist": [], "genre": []}
self.view_mode = ICON_VIEW_MODE
self.__search_flag = False
self.__song_cache_items = []
self.__cover_cache_items = []
# init widget.
self.entry_box = SearchEntry("")
self.entry_box.set_size(155, 22)
self.entry_box.entry.connect("changed", self.__search_cb)
# upper box.
self.back_button = self.__create_simple_button("back", self.__switch_to_filter_view)
self.back_button.set_no_show_all(True)
back_align = gtk.Alignment()
back_align.set(0.5, 0.5, 0, 0)
back_align.set_padding(0, 0, 0, 10)
back_align.add(self.back_button)
# path control
self.path_combo_box = ComboMenuButton()
self.path_combo_box.connect("list-actived", lambda w: self.update_path_list_view())
self.path_combo_box.connect("combo-actived", lambda w, k : self.update_path_filter_view(k))
path_combo_align = gtk.Alignment()
path_combo_align.set_padding(0, 0, 10, 0)
path_combo_align.add(self.path_combo_box)
self.path_combo_box.set_no_show_all(True)
upper_box = gtk.HBox(spacing=5)
upper_box.pack_start(path_combo_align, False, False)
upper_box.pack_start(create_right_align(), True, True)
upper_box.pack_start(back_align, False, False)
entry_box_align = gtk.Alignment()
entry_box_align.set(0.5, 0.5, 0, 0)
entry_box_align.set_padding(1, 0, 0, 0)
entry_box_align.add(self.entry_box)
upper_box.pack_start(entry_box_align, False, False)
upper_box_align = gtk.Alignment()
upper_box_align.set_padding(0, 10, 0, 10)
upper_box_align.set(0.5, 0.5, 1, 1)
upper_box_align.connect("expose-event", self.expose_upper_box_mask)
upper_box_align.add(upper_box)
self.categorybar_status = "artist"
self.filter_categorybar = OptionBar(
[(app_theme.get_pixbuf("filter/artist_normal.png"), app_theme.get_pixbuf("filter/artist_press.png"),
_("By artist"), lambda : self.reload_filter_view("artist", True)),
(app_theme.get_pixbuf("filter/album_normal.png"), app_theme.get_pixbuf("filter/album_press.png"),
_("By album"), lambda : self.reload_filter_view("album", True)),
(app_theme.get_pixbuf("filter/genre_normal.png"), app_theme.get_pixbuf("filter/genre_press.png"),
_("By genre"), lambda : self.reload_filter_view("genre", True)),]
)
# Song path bar.
self.__current_path = None
self.current_icon_item = None
self.reload_path_flag = True
self.path_categorybar = SongPathBar(_("Local"))
self.path_categorybar.set_size_request(-1, 205)
# Song import bar.
self.import_categorybar = SongImportBar()
self.import_categorybar.reload_items(
[
(_("Scan Home dir"), lambda : ImportFolderJob([os.path.expanduser("~")])),
(_("Select dir to scan"), lambda : ImportFolderJob()),
(_("Refresh library"), lambda : ReloadDBJob())]
)
# iconview.
self.filter_view = IconView(10, 10)
targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2)]
self.filter_view.drag_source_set(gtk.gdk.BUTTON1_MASK, targets, gtk.gdk.ACTION_COPY)
self.filter_view.connect("drag-data-get", self.__on_drag_data_get)
self.filter_view.connect("double-click-item", self.__on_double_click_item)
self.filter_view.connect("single-click-item", self.__on_single_click_item)
self.filter_view.draw_mask = self.draw_filter_view_mask
self.filter_scrolled_window = ScrolledWindow()
self.filter_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.filter_scrolled_window.add_child(self.filter_view)
# songs_view
self.songs_view = MultiDragSongView()
self.songs_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Added time")])
self.songs_scrolled_window = ScrolledWindow(0, 0)
self.songs_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.songs_scrolled_window.add_child(self.songs_view)
# left_vbox
align = gtk.Alignment()
#.........这里部分代码省略.........
示例14: RecommendItem
#.........这里部分代码省略.........
def get_column_widths(self):
return [CATEGORY_ITEM_NAME_WIDTH]
def get_column_renders(self):
return [self.render_name]
def hover(self, column, offset_x, offset_y):
self.is_hover = True
if self.redraw_request_callback:
self.redraw_request_callback(self)
def unhover(self, column, offset_x, offset_y):
self.is_hover = False
if self.redraw_request_callback:
self.redraw_request_callback(self)
def select(self):
self.is_select = True
if self.redraw_request_callback:
self.redraw_request_callback(self)
def unselect(self):
self.is_select = False
if self.redraw_request_callback:
self.redraw_request_callback(self)
def button_press(self, column, offset_x, offset_y):
self.show_page()
def get_pkg_icon_view_page(self):
items = []
for info in self.recommend_infos:
items.append(RecommendIconItem(info))
self.pkg_icon_view = IconView()
self.pkg_icon_view.add_items(items)
self.pkg_icon_scrolled_window = ScrolledWindow()
self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
self.pkg_icon_view.draw_mask = self.draw_mask
self.pkg_icon_view_align = gtk.Alignment()
self.pkg_icon_view_align.set(0.5, 0.5, 1, 1)
self.pkg_icon_view_align.set_padding(6, 0, 1, 11)
self.pkg_icon_view_align.add(self.pkg_icon_scrolled_window)
return self.pkg_icon_view_align
def get_download_rank_page(self):
self.download_rank_page = DownloadRankPage(self.data_manager)
return self.download_rank_page
def get_album_page(self):
self.album_page = AlbumPage(self.data_manager)
return self.album_page
# from deepin_utils.date_time import print_exec_time
# @print_exec_time
def show_page(self):
if self.recommend_scrolled_window_initial:
global_event.emit("show-pkg-view", self.recommend_scrolled_window)
else:
self.check_network_connection()
def draw_blank_mask(self, cr, x, y, w, h):
pass
def draw_mask(self, cr, x, y, w, h):
'''
Draw mask interface.
@param cr: Cairo context.
@param x: X coordiante of draw area.
@param y: Y coordiante of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
'''
draw_vlinear(cr, x, y, w, h,
[(0, ("#FFFFFF", 0.9)),
(1, ("#FFFFFF", 0.9)),]
)
def click_page(self):
if isinstance(self.active_page, AlbumPage) and self.active_page.in_detail_view:
self.active_page.switch_to_album_summary_view()
def switch_page(self, page_index):
container_remove_all(self.page_box)
page_name = self.page_name[page_index]
if not self.page_cache.has_key(self.page_name[page_index]):
self.page_cache[page_name] = getattr(self, self.tab_switcher_pages_callback[page_index])()
self.active_page = self.page_cache[page_name]
self.page_box.pack_start(self.active_page, True, True)
if isinstance(self.active_page, AlbumPage):
if self.active_page.in_detail_view:
self.active_page.switch_to_album_summary_view()
self.recommend_scrolled_window.show_all()
示例15: SecondCategoryItem
#.........这里部分代码省略.........
def hover(self, column, offset_x, offset_y):
self.is_hover = True
if self.redraw_request_callback:
self.redraw_request_callback(self)
def unhover(self, column, offset_x, offset_y):
self.is_hover = False
if self.redraw_request_callback:
self.redraw_request_callback(self)
def select(self):
self.is_select = True
if self.redraw_request_callback:
self.redraw_request_callback(self)
def unselect(self):
self.is_select = False
if self.redraw_request_callback:
self.redraw_request_callback(self)
def scrolled_window_vscrollbar_handler(self, widget, state):
if state == "bottom":
current_item_number = len(self.pkg_icon_view.items)
all_pkgs_number = len(self.all_pkg_names)
start = current_item_number
if current_item_number < all_pkgs_number and (current_item_number+LOAD_ITEMS_NUMBER) < all_pkgs_number:
end = current_item_number+LOAD_ITEMS_NUMBER
elif current_item_number < all_pkgs_number and (current_item_number+LOAD_ITEMS_NUMBER) >= all_pkgs_number:
end = all_pkgs_number
else:
return
self.load_new_items(self.all_pkg_names[start:end])
def load_new_items(self, pkg_names):
items = []
for pkg_name in pkg_names:
info = self.data_manager.get_item_pkg_info(pkg_name)
items.append(PkgIconItem(info[0], info[1], info[2], self.data_manager))
self.pkg_icon_view.add_items(items)
global_event.emit("show-pkg-view", self.page_box)
def handle_pkg_install_status_request(self, status, items):
for (index, state) in enumerate(status):
items[index].is_installed = state
items[index].emit_redraw_request()
def button_press(self, column, offset_x, offset_y):
# init Loading widget
loading_box = LoadingBox()
global_event.emit("show-pkg-view", loading_box)
self.page_box = gtk.VBox()
self.all_pkg_names = self.data_manager.get_second_category_packages(self.second_category_name)
self.message_bar = MessageBar(18)
self.message_bar.set_message(_("%s > %s : %s applications") % (
get_category_name(self.first_category_name),
get_category_name(self.second_category_name),
len(self.all_pkg_names),
))
self.pkg_icon_view = IconView()
self.pkg_icon_view.connect("motion-notify-item", tooltip_aciton)
if len(self.all_pkg_names) > LOAD_ITEMS_NUMBER:
self.load_new_items(self.all_pkg_names[:LOAD_ITEMS_NUMBER])
else:
self.load_new_items(self.all_pkg_names)
self.pkg_icon_scrolled_window = ScrolledWindow()
self.pkg_icon_scrolled_window.connect("vscrollbar-state-changed", self.scrolled_window_vscrollbar_handler)
self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
self.pkg_icon_view.draw_mask = self.draw_mask
self.pkg_icon_view.draw_row_mask = self.draw_row_mask
self.page_box.pack_start(self.message_bar, False, False)
self.page_box.pack_start(self.pkg_icon_scrolled_window, True, True)
global_event.emit("update-current-status-pkg-page", self.pkg_icon_view)
def draw_row_mask(self, cr, rect, row):
if row % 2 == 1:
cr.set_source_rgba(1, 1, 1, 0.5)
cr.rectangle(rect.x, rect.y, rect.width, rect.height)
cr.fill()
def draw_mask(self, cr, x, y, w, h):
'''
Draw mask interface.
@param cr: Cairo context.
@param x: X coordiante of draw area.
@param y: Y coordiante of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
'''
draw_vlinear(cr, x, y, w, h,
[(0, ("#FFFFFF", 0.9)),
(1, ("#FFFFFF", 0.9)),]
)