本文整理汇总了Python中sprites.Sprite.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.draw方法的具体用法?Python Sprite.draw怎么用?Python Sprite.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sprites.Sprite
的用法示例。
在下文中一共展示了Sprite.draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Slide
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import draw [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)
示例2: __init__
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import draw [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()
示例3: Tab
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import draw [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()