本文整理匯總了Python中sprites.Sprites.set_cairo_context方法的典型用法代碼示例。如果您正苦於以下問題:Python Sprites.set_cairo_context方法的具體用法?Python Sprites.set_cairo_context怎麽用?Python Sprites.set_cairo_context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sprites.Sprites
的用法示例。
在下文中一共展示了Sprites.set_cairo_context方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SlideRule
# 需要導入模塊: from sprites import Sprites [as 別名]
# 或者: from sprites.Sprites import set_cairo_context [as 別名]
#.........這裏部分代碼省略.........
def update_textview_y_offset(self, dy):
''' Need to account for menu height in GNOME '''
self.reticule.tabs[0].textview_y_offset += dy
self.reticule.tabs[1].textview_y_offset += dy
for slide in self.slides:
slide.tabs[0].textview_y_offset += dy
slide.tabs[1].textview_y_offset += dy
def _text_focus_out_cb(self, widget=None, event=None):
''' One of the four textviews was in focus '''
i = None
if widget in self.text_entries:
i = self.text_entries.index(widget)
bounds = self.text_buffers[i].get_bounds()
text = self.text_buffers[i].get_text(bounds[0], bounds[1], True)
text = text.strip()
self._process_numeric_input(i, text)
def _set_screen_dpi(self):
dpi = _get_screen_dpi()
font_map_default = PangoCairo.font_map_get_default()
font_map_default.set_resolution(dpi)
def __draw_cb(self, canvas, cr):
self.sprites.redraw_sprites(cr=cr)
# Handle the expose-event by drawing
def do_expose_event(self, event):
# Create the cairo context
cr = self.canvas.window.cairo_create()
print 'set cr in do_expose'
self.sprites.set_cairo_context(cr)
# Restrict Cairo to the exposed area; avoid extra work
cr.rectangle(event.area.x, event.area.y,
event.area.width, event.area.height)
cr.clip()
# Refresh sprite list
self.sprites.redraw_sprites(cr=cr)
def _destroy_cb(self, win, event):
Gtk.main_quit()
def _keypress_cb(self, area, event):
""" Keypress: moving the slides with the arrow keys """
k = Gdk.keyval_name(event.keyval)
if not self.sugar:
return
if k == 'a':
self.parent.show_a()
elif k == 'k':
self.parent.show_k()
elif k in ['c', 'asterisk', 'x']:
self.parent.show_c()
elif k in ['i', '/']:
self.parent.show_ci()
elif k == 's':
self.parent.show_s()
elif k == 't':
self.parent.show_t()
elif k in ['l', 'plus']:
self.parent.show_l()
elif k in ['Left', 'less']: