本文整理汇总了Python中utils.get_match_parent函数的典型用法代码示例。如果您正苦于以下问题:Python get_match_parent函数的具体用法?Python get_match_parent怎么用?Python get_match_parent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_match_parent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: select_up_item
def select_up_item(self):
'''
Select up row item.
'''
if len(self.items) > 0:
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
if self.focus_index == None:
self.focus_index = 0
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to top.
vadjust.set_value(vadjust.get_lower())
else:
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
if self.focus_index - columns >= 0:
self.emit("lost-focus-item", self.items[self.focus_index])
self.focus_index -= columns
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to item.
row = int(self.focus_index / columns)
if vadjust.get_value() - self.padding_y > row * item_height:
vadjust.set_value(vadjust.get_lower() + row * item_height + self.padding_y)
elif vadjust.get_value() - self.padding_y == row * item_height:
vadjust.set_value(vadjust.get_lower())
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:29,代码来源:iconview.py
示例2: select_down_item
def select_down_item(self):
'''
Select next row item.
'''
if len(self.items) > 0:
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
if self.focus_index == None:
self.focus_index = 0
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to top.
vadjust.set_value(vadjust.get_lower())
else:
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
if self.focus_index + columns <= len(self.items) - 1:
self.emit("lost-focus-item", self.items[self.focus_index])
self.focus_index += columns
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to item.
row = int(self.focus_index / columns)
if vadjust.get_value() + vadjust.get_page_size() - self.padding_y < (row + 1) * item_height:
vadjust.set_value(vadjust.get_lower() + (row + 1) * item_height - vadjust.get_page_size() + self.padding_y)
elif vadjust.get_value() + vadjust.get_page_size() - self.padding_y == (row + 1) * item_height:
vadjust.set_value(vadjust.get_upper() - vadjust.get_page_size())
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:28,代码来源:iconview.py
示例3: scroll_page_down
def scroll_page_down(self):
'''
Scroll page down of iconview.
'''
if len(self.items):
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
if self.focus_index == None:
self.focus_index = len(self.items) - 1
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to top.
vadjust.set_value(vadjust.get_upper() - vadjust.get_page_size())
else:
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
column = int(self.focus_index % columns)
if (vadjust.get_value() - vadjust.get_lower() + vadjust.get_page_size()) % item_height == 0:
row = int((vadjust.get_value() - vadjust.get_lower() + vadjust.get_page_size() - self.padding_y) / item_height) - 1
else:
row = int((vadjust.get_value() - vadjust.get_lower() + vadjust.get_page_size() - self.padding_y) / item_height)
if row * columns + column <= len(self.items) - 1:
self.emit("lost-focus-item", self.items[self.focus_index])
self.focus_index = row * columns + column
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
else:
self.emit("lost-focus-item", self.items[self.focus_index])
self.focus_index = (row - 1) * columns + column
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
vadjust.set_value(min(vadjust.get_upper() - vadjust.get_page_size(),
vadjust.get_value() + vadjust.get_page_size() - self.padding_y))
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:32,代码来源:iconview.py
示例4: leave_icon_view
def leave_icon_view(self, widget, event):
'''leave-notify-event signal handler.'''
# Hide hover row when cursor out of viewport area.
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
hadjust = get_match_parent(self, ["ScrolledWindow"]).get_hadjustment()
if not is_in_rect((event.x, event.y),
(hadjust.get_value(), vadjust.get_value(), hadjust.get_page_size(), vadjust.get_page_size())):
self.clear_focus_item()
开发者ID:netphi,项目名称:deepin-ui,代码行数:8,代码来源:iconview.py
示例5: draw_items
def draw_items(self, cr, rect):
# Draw items.
if len(self.items) > 0:
with cairo_state(cr):
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
vadjust_value = int(scrolled_window.get_vadjustment().get_value())
hadjust_value = int(scrolled_window.get_hadjustment().get_value())
# Draw on drawing area.
(item_width, item_height, columns, start_index, end_index) = self.get_render_item_info()
for (index, item) in enumerate(self.items[start_index:end_index]):
row = int((start_index + index) / columns)
column = (start_index + index) % columns
render_x = self.padding_x + column * item_width - hadjust_value
render_y = self.padding_y + row * item_height - vadjust_value
# Draw row background.
self.draw_row_mask(cr, gtk.gdk.Rectangle(render_x, render_y, rect.width, item_height), row)
item.row_index = row
with cairo_state(cr):
# Don't allow draw out of item area.
cr.rectangle(render_x, render_y, item_width, item_height)
cr.clip()
item.render(cr, gtk.gdk.Rectangle(render_x, render_y, item_width, item_height))
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:27,代码来源:iconview.py
示例6: set_double_items
def set_double_items(self, item):
# 设置双击items.
self.__double_items = item
# print "__listview_down_event..."
vadjustment = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
# 获取 start, end index.
start_index, end_index = self.__get_start_end_index()
row_index = self.items.index(self.__double_items)
if vadjustment:
value = vadjustment.get_value()
#
if start_index <= row_index <= end_index:
# row_index += 1
if row_index <= len(self.items) - 1:
# 滚动窗口.
if row_index + 1 == end_index:
if row_index == len(self.items) - 1:
self.__listview_end_event()
else:
vadjustment.set_value(value + self.__items_padding_height)
else: # 超出范围,需要处理. 比如随机播放...
# value = vadjustment.get_value()
# start_index, end_index = self.__get_start_end_index()
# 滚动窗口.
max_value = vadjustment.get_upper() - vadjustment.get_page_size()
move_value = self.__items_padding_height * self.items.index(item) # abs(end_index - start_index - 1)
value = move_value
# 如果滚动的页超出了,直接到末尾.
if value > max_value:
vadjustment.set_value(max_value + self.__items_padding_height)
else:
print value
vadjustment.set_value(value)
#
self.on_queue_draw_area()
开发者ID:martyr-deepin,项目名称:deepin-media-player,代码行数:35,代码来源:listview.py
示例7: update_vadjustment
def update_vadjustment(self):
'''
Update vertical adjustment.
'''
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
if len(self.items) > 0:
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
if columns > 0:
if len(self.items) % columns == 0:
view_height = int(len(self.items) / columns) * item_height
else:
view_height = (int(len(self.items) / columns) + 1) * item_height
self.set_size_request(columns * item_width + self.padding_x * 2,
view_height + self.padding_y * 2)
if scrolled_window != None:
vadjust = scrolled_window.get_vadjustment()
vadjust.set_upper(max(view_height + self.padding_y * 2,
scrolled_window.allocation.height))
else:
self.set_size_request(scrolled_window.allocation.width,
scrolled_window.allocation.height)
vadjust = scrolled_window.get_vadjustment()
vadjust.set_upper(scrolled_window.allocation.height)
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:26,代码来源:iconview.py
示例8: expose_icon_view
def expose_icon_view(self, widget, event):
'''
Internal callback for `expose-event` signal.
'''
# Update vadjustment.
self.update_vadjustment()
# Init.
cr = widget.window.cairo_create()
rect = widget.allocation
# Get offset.
(offset_x, offset_y, viewport) = self.get_offset_coordinate(widget)
# Draw background.
with cairo_state(cr):
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
cr.translate(-scrolled_window.allocation.x, -scrolled_window.allocation.y)
cr.rectangle(offset_x, offset_y,
scrolled_window.allocation.x + scrolled_window.allocation.width,
scrolled_window.allocation.y + scrolled_window.allocation.height)
cr.clip()
(shadow_x, shadow_y) = get_window_shadow_size(self.get_toplevel())
skin_config.render_background(cr, self, offset_x + shadow_x, offset_y + shadow_y)
# Draw mask.
self.draw_mask(cr, offset_x, offset_y, viewport.allocation.width, viewport.allocation.height)
# Draw items.
self.draw_items(cr, rect, offset_x, offset_y, viewport)
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:31,代码来源:iconview.py
示例9: draw_icon_view_mask
def draw_icon_view_mask(widget, x, y, w, h, render_callback):
'''
Draw icon view mask with given render method.
@param widget: Target widget.
@param x: X coordinate of draw area.
@param y: Y coordinate of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
@param render_callback: Render callback.
'''
cr = widget.window.cairo_create()
viewport = get_match_parent(widget, ["Viewport"])
toplevel = widget.get_toplevel()
(offset_x, offset_y) = viewport.translate_coordinates(toplevel, 0, 0)
(shadow_x, shadow_y) = get_window_shadow_size(toplevel)
with cairo_state(cr):
cr.rectangle(x, y, w, h)
cr.clip()
render_callback(
cr,
x - offset_x + shadow_x,
y - offset_y + shadow_y,
toplevel.allocation.width,
toplevel.allocation.height)
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:27,代码来源:mask.py
示例10: update_redraw_request_list
def update_redraw_request_list(self):
'''
Internal function to update redraw request list.
'''
# Redraw when request list is not empty.
if len(self.redraw_request_list) > 0:
# Get offset.
(offset_x, offset_y, viewport) = self.get_offset_coordinate(self)
# Get viewport index.
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
start_y = offset_y - self.padding_y
start_row = max(int(start_y / item_height), 0)
start_index = start_row * columns
end_y = offset_y - self.padding_y + viewport.allocation.height
if end_y % item_height == 0:
end_row = end_y / item_height - 1
else:
end_row = end_y / item_height
end_index = min((end_row + 1) * columns, len(self.items))
# Redraw whole viewport area once found any request item in viewport.
for item in self.redraw_request_list:
if item in self.items[start_index:end_index]:
self.queue_draw()
break
# Clear redraw request list.
self.redraw_request_list = []
return True
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:35,代码来源:iconview.py
示例11: icon_view_get_event_index
def icon_view_get_event_index(self, event):
'''Get index at event.'''
if len(self.items) > 0:
(event_x, event_y) = get_event_coords(event)
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
if len(self.items) % columns == 0:
rows = int(len(self.items) / columns)
else:
rows = int(len(self.items) / columns) + 1
if event_x > columns * item_width:
return None
elif event_y > rows * item_height:
return None
else:
if event_x % item_width == 0:
column_index = max(event_x / item_width - 1, 0)
else:
column_index = min(event_x / item_width, columns - 1)
if event_y % item_height == 0:
row_index = max(event_y / item_height - 1, 0)
else:
row_index = min(event_y / item_height, rows - 1)
item_index = row_index * columns + column_index
if item_index > len(self.items) - 1:
return None
else:
return (row_index, column_index, item_index,
event_x - column_index * item_width,
event_y - row_index * item_height)
开发者ID:netphi,项目名称:deepin-ui,代码行数:35,代码来源:iconview.py
示例12: get_render_item_info
def get_render_item_info(self):
'''
Internal function to get information of render items.
'''
# Get offset.
(offset_x, offset_y, viewport) = self.get_offset_coordinate(self)
# Get item size.
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
# Get viewport index.
start_y = offset_y - self.padding_y
start_row = max(int(start_y / item_height), 0)
start_index = start_row * columns
end_y = offset_y - self.padding_y + viewport.allocation.height
if end_y % item_height == 0:
end_row = end_y / item_height - 1
else:
end_row = end_y / item_height
end_index = min((end_row + 1) * columns, len(self.items))
return (item_width, item_height, columns, start_index, end_index)
开发者ID:liuhuan520,项目名称:deepin-ui,代码行数:25,代码来源:iconview.py
示例13: __listview_realize_event
def __listview_realize_event(self, widget):
widget.set_realized(True)
scroll_win = get_match_parent(widget, "ScrolledWindow")
if scroll_win:
scroll_win.get_vadjustment().connect("value-changed", self.__scroll_win_vajustment_changed)
scroll_win.get_hadjustment().connect("value-changed", self.__scroll_win_hajustment_changed)
scroll_win.connect("scroll-event", self.__scroll_win_scroll_event)
开发者ID:martyr-deepin,项目名称:deepin-media-player,代码行数:8,代码来源:listview.py
示例14: size_allocated_icon_view
def size_allocated_icon_view(self, widget, rect):
# Cairo render surface.
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
try:
self.render_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, scrolled_window.allocation.width, scrolled_window.allocation.height)
self.render_surface_cr = gtk.gdk.CairoContext(cairo.Context(self.render_surface))
except Exception:
pass
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:9,代码来源:iconview.py
示例15: __listview_end_event
def __listview_end_event(self): # 最末尾项.
#print "__listview_end_event..."
vadjustment = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
if vadjustment:
value = vadjustment.get_upper() - vadjustment.get_page_size()
# 设置选中items.
if self.items != []:
self.__single_items = [self.items[len(self.items) - 1]]
vadjustment.set_value(value)
self.on_queue_draw_area()
开发者ID:hailongqiu,项目名称:new-deepin-media-player,代码行数:10,代码来源:listview.py
示例16: __listview_home_event
def __listview_home_event(self): # 开头第一个项.
#print "__listview_home_event..."
vadjustment = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
if vadjustment:
value = vadjustment.get_lower()
# 设置选中items.
if self.items != []:
self.__single_items = [self.items[0]]
vadjustment.set_value(value)
self.on_queue_draw_area()
开发者ID:hailongqiu,项目名称:new-deepin-media-player,代码行数:10,代码来源:listview.py
示例17: __on_draw_item_fg
def __on_draw_item_fg(self, cr, rect):
top_pixbuf = app_theme.get_pixbuf("playlist/list_top.png").get_pixbuf()
bottom_pixbuf = app_theme.get_pixbuf("playlist/list_bottom.png").get_pixbuf()
#
scroll_win = get_match_parent(self, "ScrolledWindow")
vadjust = scroll_win.get_vadjustment()
if vadjust.get_value() != vadjust.get_lower():
draw_pixbuf(cr, top_pixbuf, 0, vadjust.get_value() - 1)
if vadjust.get_value() + vadjust.get_page_size() != vadjust.get_upper():
y = vadjust.get_value() + vadjust.get_page_size() - bottom_pixbuf.get_height()
draw_pixbuf(cr, bottom_pixbuf, 0, y)
开发者ID:martyr-deepin,项目名称:deepin-media-player,代码行数:11,代码来源:listview.py
示例18: select_first_item
def select_first_item(self):
'''Select first item.'''
if len(self.items) > 0:
self.clear_focus_item()
self.focus_index = 0
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to top.
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
vadjust.set_value(vadjust.get_lower())
开发者ID:netphi,项目名称:deepin-ui,代码行数:11,代码来源:iconview.py
示例19: select_last_item
def select_last_item(self):
'''Select last item.'''
if len(self.items) > 0:
self.clear_focus_item()
self.focus_index = len(self.items) - 1
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to bottom.
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
vadjust.set_value(vadjust.get_upper() - vadjust.get_page_size())
开发者ID:netphi,项目名称:deepin-ui,代码行数:11,代码来源:iconview.py
示例20: select_right_item
def select_right_item(self):
'''Select next column.'''
if len(self.items) > 0:
vadjust = get_match_parent(self, ["ScrolledWindow"]).get_vadjustment()
if self.focus_index == None:
self.focus_index = 0
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
# Scroll to top.
vadjust.set_value(vadjust.get_lower())
else:
item_width, item_height = self.items[0].get_width(), self.items[0].get_height()
scrolled_window = get_match_parent(self, ["ScrolledWindow"])
columns = int((scrolled_window.allocation.width - self.padding_x * 2) / item_width)
row = int(self.focus_index / columns)
max_index = min((row + 1) * columns - 1, len(self.items) - 1)
if self.focus_index + 1 <= max_index:
self.emit("lost-focus-item", self.items[self.focus_index])
self.focus_index += 1
self.emit("motion-notify-item", self.items[self.focus_index], 0, 0)
开发者ID:netphi,项目名称:deepin-ui,代码行数:21,代码来源:iconview.py
注:本文中的utils.get_match_parent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论