本文整理汇总了Python中sprites.Sprite.hide方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.hide方法的具体用法?Python Sprite.hide怎么用?Python Sprite.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sprites.Sprite
的用法示例。
在下文中一共展示了Sprite.hide方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Stator
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Stator():
""" Create a sprite for a stator """
def __init__(self, sprites, path, name, x, y, w, h, svg_engine=None,
calculate=None, result=None):
if svg_engine is None:
self.spr = Sprite(sprites, x, y, file_to_pixbuf(path, name, w, h))
else:
self.spr = Sprite(sprites, x, y,
svg_str_to_pixbuf(svg_engine().svg))
self.spr.type = name
self.name = name
self.calculate = calculate
self.result = result
def draw(self, layer=1000):
self.spr.set_layer(layer)
def match(self, sprite):
if self.spr == sprite:
return True
return False
def move(self, dx, dy):
self.spr.move((dx, dy))
def move_relative(self, dx, dy):
self.spr.move_relative((dx, dy))
def hide(self):
self.spr.hide()
示例2: Slide
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Slide(Stator):
""" Create a sprite for a slide """
def __init__(self, sprites, path, name, x, y, w, h, svg_engine=None,
function=None):
if svg_engine is None:
self.spr = Sprite(sprites, x, y, file_to_pixbuf(path, name, w, h))
else:
self.spr = Sprite(sprites, x, y,
svg_str_to_pixbuf(svg_engine().svg))
self.tab_dx = [0, SWIDTH - TABWIDTH]
self.tab_dy = [2 * SHEIGHT, 2 * SHEIGHT]
self.tabs = []
self.tabs.append(Tab(sprites, path, 'tab', x + self.tab_dx[0],
y + self.tab_dy[0], TABWIDTH, SHEIGHT))
self.tabs.append(Tab(sprites, path, 'tab', x + self.tab_dx[1],
y + self.tab_dy[1], TABWIDTH, SHEIGHT))
self.calculate = function
self.name = name
def add_textview(self, textview, i=0):
self.tabs[i].textview = textview
self.tabs[i].textbuffer = textview.get_buffer()
def set_fixed(self, fixed):
for tab in self.tabs:
tab.fixed = fixed
def match(self, sprite):
if sprite == self.spr or sprite == self.tabs[0].spr or \
sprite == self.tabs[1].spr:
return True
return False
def draw(self, layer=1000):
self.spr.set_layer(layer)
self.spr.draw()
for tab in self.tabs:
tab.draw()
def move(self, dx, dy):
self.spr.move((dx, dy))
for i, tab in enumerate(self.tabs):
tab.move(dx + self.tab_dx[i], dy + self.tab_dy[i])
def move_relative(self, dx, dy):
self.spr.move_relative((dx, dy))
for i, tab in enumerate(self.tabs):
tab.move_relative(dx, dy)
def hide(self):
self.spr.hide()
for tab in self.tabs:
tab.hide()
def label(self, label, i=0):
self.tabs[i].label(label)
示例3: __init__
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Card:
''' Individual cards '''
def __init__(self, scale=1.0):
''' Create the card and store its attributes '''
self.spr = None
self.index = None # Calculated index
self._scale = scale
def create(self, string, attributes=None, sprites=None, file_path=None):
if attributes is None:
if self.spr is None:
self.spr = Sprite(sprites, 0, 0, svg_str_to_pixbuf(string))
else:
self.spr.set_image(svg_str_to_pixbuf(string))
self.index = None
else:
self.shape = attributes[0]
self.color = attributes[1]
self.num = attributes[2]
self.fill = attributes[3]
self.index = self.shape * COLORS * NUMBER * FILLS + \
self.color * NUMBER * FILLS + \
self.num * FILLS + \
self.fill
if self.spr is None:
self.spr = Sprite(sprites, 0, 0, svg_str_to_pixbuf(string))
else:
self.spr.set_image(svg_str_to_pixbuf(string))
if file_path is not None:
self.spr.set_image(load_image(file_path, self._scale), i=1,
dx=int(self._scale * CARD_WIDTH * .125),
dy=int(self._scale * CARD_HEIGHT * .125))
self.spr.set_label_attributes(self._scale * 24)
self.spr.set_label('')
def show_card(self, layer=2000):
''' Show the card '''
if self.spr is not None:
self.spr.set_layer(layer)
self.spr.draw()
def hide_card(self):
''' Hide a card '''
if self.spr is not None:
self.spr.hide()
示例4: Tab
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Tab():
""" Create tabs for the slide; include a TextView for OSK input """
def __init__(self, sprites, path, name, x, y, w, h):
self.spr = Sprite(sprites, x, y, file_to_pixbuf(path, name, w, h))
self.spr.label = "1.0"
self.spr.type = name
self.name = name
self.width = w
self.textview = None
self.textbuffer = None
self.fixed = None
self.textview_y_offset = 0
def label(self, label):
if self.textbuffer is not None:
self.textbuffer.set_text(label)
def _move_textview(self, x, y):
y += self.textview_y_offset
if self.textview is not None:
if x > 0 and x < Gdk.Screen.width() - self.width and y > 0:
self.fixed.move(self.textview, x, y)
self.textview.show()
else:
self.textview.hide()
def move(self, x, y):
self.spr.move((x, y))
self._move_textview(x, y)
def move_relative(self, dx, dy):
self.spr.move_relative((dx, dy))
x, y = self.spr.get_xy()
self._move_textview(x, y)
def draw(self, layer=100):
self.spr.set_layer(layer)
self.spr.draw()
x, y = self.spr.get_xy()
self._move_textview(x, y)
def hide(self):
self.spr.hide()
示例5: __init__
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
#.........这里部分代码省略.........
if not self._pen_fill:
self._poly_points = []
def set_poly_points(self, poly_points=None):
if poly_points is not None:
self._poly_points = poly_points[:]
def start_fill(self):
self._pen_fill = True
self._poly_points = []
def stop_fill(self, share=True):
self._pen_fill = False
if len(self._poly_points) == 0:
return
self._turtles.turtle_window.canvas.fill_polygon(self._poly_points)
if self._turtles.turtle_window.sharing() and share:
shared_poly_points = []
for p in self._poly_points:
x, y = self._turtles.turtle_to_screen_coordinates(
(p[1], p[2]))
if p[0] in ['move', 'line']:
shared_poly_points.append((p[0], x, y))
elif p[0] in ['rarc', 'larc']:
shared_poly_points.append((p[0], x, y, p[3], p[4], p[5]))
event = 'F|%s' % (data_to_string(
[self._turtles.turtle_window.nick,
shared_poly_points]))
self._turtles.turtle_window.send_event(event)
self._poly_points = []
def hide(self):
if self.spr is not None:
self.spr.hide()
if self.label_block is not None:
self.label_block.spr.hide()
self._hidden = True
def show(self):
if self.spr is not None:
self.spr.set_layer(TURTLE_LAYER)
self._hidden = False
self.move_turtle_spr((self._x, self._y))
self.set_heading(self._heading, share=False)
if self.label_block is not None:
self.label_block.spr.set_layer(TURTLE_LAYER + 1)
def move_turtle(self, pos=None):
''' Move the turtle's position '''
if pos is None:
pos = self.get_xy()
self._x, self._y = pos[0], pos[1]
if self.spr is not None:
self.move_turtle_spr(pos)
def move_turtle_spr(self, pos):
''' Move the turtle's sprite '''
pos = self._turtles.turtle_to_screen_coordinates(pos)
pos[0] -= self._half_width
pos[1] -= self._half_height
if not self._hidden and self.spr is not None:
示例6: Selector
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Selector():
''' Selector class abstraction '''
def __init__(self, turtle_window, n):
'''This class handles the display of palette selectors (Only relevant
to GNOME version and very old versions of Sugar).
'''
self.shapes = []
self.spr = None
self._turtle_window = turtle_window
self._index = n
if not n < len(palette_names):
# Shouldn't happen, but hey...
debug_output('palette index %d is out of range' % n,
self._turtle_window.running_sugar)
self._name = 'extras'
else:
self._name = palette_names[n]
icon_pathname = None
for path in self._turtle_window.icon_paths:
if os.path.exists(os.path.join(path, '%soff.svg' % (self._name))):
icon_pathname = os.path.join(path, '%soff.svg' % (self._name))
break
if icon_pathname is not None:
off_shape = svg_str_to_pixbuf(svg_from_file(icon_pathname))
else:
off_shape = svg_str_to_pixbuf(svg_from_file(os.path.join(
self._turtle_window.icon_paths[0], 'extrasoff.svg')))
error_output('Unable to open %soff.svg' % (self._name),
self._turtle_window.running_sugar)
icon_pathname = None
for path in self._turtle_window.icon_paths:
if os.path.exists(os.path.join(path, '%son.svg' % (self._name))):
icon_pathname = os.path.join(path, '%son.svg' % (self._name))
break
if icon_pathname is not None:
on_shape = svg_str_to_pixbuf(svg_from_file(icon_pathname))
else:
on_shape = svg_str_to_pixbuf(svg_from_file(os.path.join(
self._turtle_window.icon_paths[0], 'extrason.svg')))
error_output('Unable to open %son.svg' % (self._name),
self._turtle_window.running_sugar)
self.shapes.append(off_shape)
self.shapes.append(on_shape)
x = int(ICON_SIZE * self._index)
self.spr = Sprite(self._turtle_window.sprite_list, x, 0, off_shape)
self.spr.type = 'selector'
self.spr.name = self._name
self.set_layer()
def set_shape(self, i):
if self.spr is not None and i in [0, 1]:
self.spr.set_shape(self.shapes[i])
def set_layer(self, layer=TAB_LAYER):
if self.spr is not None:
self.spr.set_layer(layer)
def hide(self):
if self.spr is not None:
self.spr.hide()
示例7: Game
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Game():
def __init__(self, canvas, parent=None, colors=['#A0FFA0', '#FF8080']):
self._activity = parent
self._colors = [colors[0]]
self._colors.append(colors[1])
self._colors.append('#FFFFFF')
self._colors.append('#000000')
self._colors.append('#FF0000')
self._colors.append('#FF8000')
self._colors.append('#FFFF00')
self._colors.append('#00FF00')
self._colors.append('#00FFFF')
self._colors.append('#0000FF')
self._colors.append('#FF00FF')
self._canvas = canvas
if parent is not None:
parent.show_all()
self._parent = parent
self._canvas.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
self._canvas.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
self._canvas.add_events(Gdk.EventMask.POINTER_MOTION_MASK)
self._canvas.connect("draw", self.__draw_cb)
self._canvas.connect("button-press-event", self._button_press_cb)
self._canvas.connect("button-release-event", self._button_release_cb)
self._canvas.connect("motion-notify-event", self._mouse_move_cb)
self._width = Gdk.Screen.width()
self._height = Gdk.Screen.height() - GRID_CELL_SIZE
scale = [self._width / (10 * DOT_SIZE * 1.2),
self._height / (6 * DOT_SIZE * 1.2)]
self._scale = min(scale)
self._dot_size = int(DOT_SIZE * self._scale)
self._space = int(self._dot_size / 5.)
self._orientation = 'horizontal'
self.we_are_sharing = False
self.playing_with_robot = False
self._press = False
self.last_spr = None
self._timer = None
self.roygbiv = False
# Generate the sprites we'll need...
self._sprites = Sprites(self._canvas)
self._dots = []
for y in range(SIX):
for x in range(TEN):
xoffset = int((self._width - TEN * self._dot_size - \
(TEN - 1) * self._space) / 2.)
self._dots.append(
Sprite(self._sprites,
xoffset + x * (self._dot_size + self._space),
y * (self._dot_size + self._space),
self._new_dot(self._colors[2])))
self._dots[-1].type = 2 # not set
self._dots[-1].set_label_attributes(40)
self.vline = Sprite(self._sprites,
int(self._width / 2.) - 1,
0, self._line(vertical=True))
n = SIX / 2.
self.hline = Sprite(
self._sprites, 0,
int(self._dot_size * n + self._space * (n - 0.5)) - 1,
self._line(vertical=False))
self.hline.hide()
# and initialize a few variables we'll need.
self._all_clear()
def _all_clear(self):
''' Things to reinitialize when starting up a new game. '''
for dot in self._dots:
dot.type = 2
dot.set_shape(self._new_dot(self._colors[2]))
dot.set_label('')
self._set_orientation()
def _set_orientation(self):
''' Set bar and message for current orientation '''
if self._orientation == 'horizontal':
self.hline.hide()
self.vline.set_layer(1000)
elif self._orientation == 'vertical':
self.hline.set_layer(1000)
self.vline.hide()
else:
self.hline.set_layer(1000)
self.vline.set_layer(1000)
'''
if self._orientation == 'horizontal':
self._set_label(
_('Click on the dots to make a horizontal reflection.'))
elif self._orientation == 'vertical':
self._set_label(
#.........这里部分代码省略.........
示例8: Game
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Game():
def __init__(self, canvas, parent=None, path=None):
self._canvas = canvas
self._parent = parent
self._parent.show_all()
self._path = path
self._canvas.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
self._canvas.connect("draw", self.__draw_cb)
self._canvas.connect("button-press-event", self._button_press_cb)
self._width = Gdk.Screen.width()
self._height = Gdk.Screen.height()
self._scale = self._width / 1200.
self._target = 0
self._tries = 0
self.level = 0
self._picture_cards = []
self._small_picture_cards = []
self.food_cards = []
self._group_cards = []
self._quantity_cards = []
self._balance_cards = []
self._last_twenty = []
self._background = None
# Generate the sprites we'll need...
self._sprites = Sprites(self._canvas)
self._background = Sprite(
self._sprites, 0, 0, GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images','background.png'),
self._width, self._height))
self._background.set_layer(0)
self._background.type = None
self._background.hide()
self.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images', 'word-box.png'),
int(350 * self._scale), int(100 * self._scale))
for i in range(len(FOOD_DATA) / 4):
FOOD.append([FOOD_DATA[i * 4 + NAME], FOOD_DATA[i * 4 + CALS],
FOOD_DATA[i * 4 + GROUP], FOOD_DATA[i * 4 + IMAGE]])
self.food_cards.append(None)
self._picture_cards.append(None)
for j in range(6):
self._small_picture_cards.append(None)
self.allocate_food(0)
x = 10
dx, dy = self.food_cards[0].get_dimensions()
y = 10
for i in range(len(MYPLATE)):
self.word_card_append(self._group_cards, self.pixbuf)
self._group_cards[-1].type = i
self._group_cards[-1].set_label(MYPLATE[i][0])
self._group_cards[-1].move((x, y))
y += int(dy * 1.25)
y = 10
for i in range(len(QUANTITIES)):
self.word_card_append(self._quantity_cards, self.pixbuf)
self._quantity_cards[-1].type = i
self._quantity_cards[-1].set_label(QUANTITIES[i])
self._quantity_cards[-1].move((x, y))
y += int(dy * 1.25)
y = 10
for i in range(len(BALANCE)):
self.word_card_append(self._balance_cards, self.pixbuf)
self._balance_cards[-1].type = i
self._balance_cards[-1].set_label(BALANCE[i])
self._balance_cards[-1].move((x, y))
y += int(dy * 1.25)
self._smile = Sprite(self._sprites,
int(self._width / 4),
int(self._height / 4),
GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images', 'correct.png'),
int(self._width / 2),
int(self._height / 2)))
self._smile.set_label_attributes(36)
self._smile.set_margins(10, 0, 10, 0)
self._frown = Sprite(self._sprites,
int(self._width / 4),
int(self._height / 4),
GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images', 'wrong.png'),
int(self._width / 2),
int(self._height / 2)))
self._frown.set_label_attributes(36)
self._frown.set_margins(10, 0, 10, 0)
self.build_food_groups()
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
#.........这里部分代码省略.........
else:
if n != 1:
_logger.debug("%d images passed to set_shapes: ignoring" % (n))
images = [shapes[0]]
if self.heading == 0:
for i in range(3):
images.append(images[i].rotate_simple(270))
for i in range(SHAPES):
j = (i + 4) % SHAPES
self.shapes[j] = images[int(j / 9)]
else:
j = int(self.heading + 5) % 360 / (360 / SHAPES)
self.shapes[j] = images[0]
self.custom_shapes = True
self.show()
def reset_shapes(self):
""" Reset the shapes to the standard turtle """
if self.custom_shapes:
self.shapes = generate_turtle_pixbufs(self.colors)
self.custom_shapes = False
def set_heading(self, heading):
""" Set the turtle heading (one shape per 360/SHAPES degrees) """
self.heading = heading
i = (int(self.heading + 5) % 360) / (360 / SHAPES)
if not self.hidden and self.spr is not None:
try:
self.spr.set_shape(self.shapes[i])
except IndexError:
self.spr.set_shape(self.shapes[0])
def set_color(self, color):
""" Set the pen color for this turtle. """
self.pen_color = color
def set_gray(self, gray):
""" Set the pen gray level for this turtle. """
self.pen_gray = gray
def set_shade(self, shade):
""" Set the pen shade for this turtle. """
self.pen_shade = shade
def set_pen_size(self, pen_size):
""" Set the pen size for this turtle. """
self.pen_size = pen_size
def set_pen_state(self, pen_state):
""" Set the pen state (down==True) for this turtle. """
self.pen_state = pen_state
def hide(self):
""" Hide the turtle. """
if self.spr is not None:
self.spr.hide()
self.hidden = True
def show(self):
""" Show the turtle. """
if self.spr is not None:
self.spr.set_layer(TURTLE_LAYER)
self.hidden = False
self.move((self.x, self.y))
self.set_heading(self.heading)
def move(self, pos):
""" Move the turtle. """
self.x, self.y = int(pos[0]), int(pos[1])
if not self.hidden and self.spr is not None:
self.spr.move(pos)
return(self.x, self.y)
def get_xy(self):
""" Return the turtle's x, y coordinates. """
return(self.x, self.y)
def get_heading(self):
""" Return the turtle's heading. """
return(self.heading)
def get_color(self):
""" Return the turtle's color. """
return(self.pen_color)
def get_gray(self):
""" Return the turtle's gray level. """
return(self.pen_gray)
def get_shade(self):
""" Return the turtle's shade. """
return(self.pen_shade)
def get_pen_size(self):
""" Return the turtle's pen size. """
return(self.pen_size)
def get_pen_state(self):
""" Return the turtle's pen state. """
return(self.pen_state)
示例10: Game
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
class Game():
def __init__(self, canvas, parent=None, path=None):
self._canvas = canvas
self._parent = parent
self._parent.show_all()
self._path = path
self._canvas.connect("draw", self.__draw_cb)
self._canvas.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
self._canvas.connect("button-press-event", self._button_press_cb)
self._canvas.add_events(Gdk.EventMask.POINTER_MOTION_MASK)
self._canvas.connect("motion-notify-event", self._mouse_move_cb)
self._canvas.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
self._canvas.connect('button-release-event', self._button_release_cb)
self._canvas.add_events(Gdk.EventMask.KEY_PRESS_MASK)
self._canvas.connect('key-press-event', self._keypress_cb)
self._canvas.set_can_focus(True)
self._canvas.grab_focus()
self._width = Gdk.Screen.width()
self._height = Gdk.Screen.height()
self._scale = self._width / 1200.
self._first_time = True
self._loco_pos = (0, 0)
self._loco_dim = (0, 0)
self._loco_quadrant = 3
self._drag_pos = [0, 0]
self._counter = 0
self._correct = 0
self._timeout_id = None
self._pause = 200
self._press = None
self._clicked = False
self._dead_key = None
self._waiting_for_delete = False
self._waiting_for_enter = False
self._seconds = 0
self._timer_id = None
self.level = 0
self.score = 0
# Generate the sprites we'll need...
self._sprites = Sprites(self._canvas)
self._BG = ['background0.jpg', 'background0.jpg', 'background0.jpg',
'background1.jpg', 'background2.jpg', 'background2.jpg',
'background2.jpg']
self._backgrounds = []
for bg in self._BG:
self._backgrounds.append(Sprite(
self._sprites, 0, 0, GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images', bg),
self._width, self._height)))
self._backgrounds[-1].type = 'background'
self._backgrounds[-1].hide()
self._panel = Sprite(
self._sprites, int(400 * self._scale), int(400 * self._scale),
GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images', 'ventana.png'),
int(720 * self._scale), int(370 * self._scale)))
self._panel.type = 'panel'
self._panel.set_label(LABELS[0])
self._panel.set_label_attributes(20)
self._panel.hide()
self._LOCOS = glob.glob(
os.path.join(self._path, 'images', 'loco*.png'))
self._loco_cards = []
for loco in self._LOCOS:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
self._loco_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._loco_cards[-1].type = 'loco'
self._loco_dim = (int(150 * self._scale), int(208 * self._scale))
self._MEN = glob.glob(
os.path.join(self._path, 'images', 'man*.png'))
self._man_cards = []
for loco in self._MEN:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
self._man_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._man_cards[-1].type = 'loco'
self._TAUNTS = glob.glob(
os.path.join(self._path, 'images', 'taunt*.png'))
self._taunt_cards = []
for loco in self._TAUNTS:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
self._taunt_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._taunt_cards[-1].type = 'loco'
self._GHOSTS = glob.glob(
os.path.join(self._path, 'images', 'ghost*.png'))
self._ghost_cards = []
for loco in self._GHOSTS:
#.........这里部分代码省略.........
示例11: BBoardActivity
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
#.........这里部分代码省略.........
if 'title' in ds.metadata:
title = ds.metadata['title']
else:
title = None
pixbuf = None
media_object = False
mimetype = None
if 'mime_type' in ds.metadata:
mimetype = ds.metadata['mime_type']
if mimetype[0:5] == 'image':
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
ds.file_path, MAXX, MAXY)
# ds.file_path, 300, 225)
media_object = True
else:
pixbuf = get_pixbuf_from_journal(ds, MAXX, MAXY) # 300, 225)
if 'description' in ds.metadata:
desc = ds.metadata['description']
else:
desc = None
self.slides.append(Slide(True, ds.object_id, self.colors,
title, pixbuf, desc))
# Generate the sprites we'll need...
self._sprites = Sprites(self._canvas)
self._help = Sprite(
self._sprites,
int((self._width - int(PREVIEWW * self._scale)) / 2),
int(PREVIEWY * self._scale),
gtk.gdk.pixbuf_new_from_file_at_size(
os.path.join(activity.get_bundle_path(), 'help.png'),
int(PREVIEWW * self._scale), int(PREVIEWH * self._scale)))
self._help.hide()
self._genblanks(self.colors)
self._title = Sprite(self._sprites, 0, 0, self._title_pixbuf)
self._title.set_label_attributes(int(titlef * self._scale),
rescale=False)
self._preview = Sprite(self._sprites,
int((self._width - int(PREVIEWW * self._scale)) / 2),
int(PREVIEWY * self._scale), self._preview_pixbuf)
self._description = Sprite(self._sprites,
int(DESCRIPTIONX * self._scale),
int(DESCRIPTIONY * self._scale),
self._desc_pixbuf)
self._description.set_label_attributes(int(descriptionf * self._scale))
self._my_canvas = Sprite(self._sprites, 0, 0, self._canvas_pixbuf)
self._my_canvas.set_layer(BOTTOM)
self._clear_screen()
self.i = 0
self._show_slide()
self._playing = False
self._rate = 10
def _genblanks(self, colors):
''' Need to cache these '''
self._title_pixbuf = svg_str_to_pixbuf(
genblank(self._width, int(TITLEH * self._scale), colors))
self._preview_pixbuf = svg_str_to_pixbuf(
示例12: __init__
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import hide [as 别名]
#.........这里部分代码省略.........
j = int(self.heading + 5) % 360 / (360 / SHAPES)
self.shapes[j] = shapes[0]
self.custom_shapes = True
self.show()
def reset_shapes(self):
""" Reset the shapes to the standard turtle """
if self.custom_shapes:
self.shapes = generate_turtle_pixbufs(self.colors)
self.custom_shapes = False
def set_heading(self, heading):
""" Set the turtle heading (one shape per 360/SHAPES degrees) """
self.heading = heading
i = (int(self.heading + 5) % 360) / (360 / SHAPES)
if not self.hidden and self.spr is not None:
try:
self.spr.set_shape(self.shapes[i])
except IndexError:
self.spr.set_shape(self.shapes[0])
def set_color(self, color):
""" Set the pen color for this turtle. """
self.pen_color = color
def set_gray(self, gray):
""" Set the pen gray level for this turtle. """
self.pen_gray = gray
def set_shade(self, shade):
""" Set the pen shade for this turtle. """
self.pen_shade = shade
def set_pen_size(self, pen_size):
""" Set the pen size for this turtle. """
self.pen_size = pen_size
def set_pen_state(self, pen_state):
""" Set the pen state (down==True) for this turtle. """
self.pen_state = pen_state
def hide(self):
""" Hide the turtle. """
if self.spr is not None:
self.spr.hide()
if self.label_block is not None:
self.label_block.spr.hide()
self.hidden = True
def show(self):
""" Show the turtle. """
if self.spr is not None:
self.spr.set_layer(TURTLE_LAYER)
self.hidden = False
self.move((self.x, self.y))
self.set_heading(self.heading)
if self.label_block is not None:
self.label_block.spr.set_layer(TURTLE_LAYER + 1)
def move(self, pos):
""" Move the turtle. """
self.x, self.y = pos[0], pos[1]
if not self.hidden and self.spr is not None:
self.spr.move((int(pos[0]), int(pos[1])))
if self.label_block is not None:
self.label_block.spr.move((int(pos[0] + self.label_xy[0]),
int(pos[1] + self.label_xy[1])))
return(self.x, self.y)
def get_name(self):
''' return turtle name (key) '''
return self.name
def get_xy(self):
""" Return the turtle's x, y coordinates. """
return(self.x, self.y)
def get_heading(self):
""" Return the turtle's heading. """
return(self.heading)
def get_color(self):
""" Return the turtle's color. """
return(self.pen_color)
def get_gray(self):
""" Return the turtle's gray level. """
return(self.pen_gray)
def get_shade(self):
""" Return the turtle's shade. """
return(self.pen_shade)
def get_pen_size(self):
""" Return the turtle's pen size. """
return(self.pen_size)
def get_pen_state(self):
""" Return the turtle's pen state. """
return(self.pen_state)