本文整理汇总了Python中activity.Activity类的典型用法代码示例。如果您正苦于以下问题:Python Activity类的具体用法?Python Activity怎么用?Python Activity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, screen, items):
Activity.__init__(self, screen)
self.screen = screen
# Position of the categories menu
self.cat_pos = (675, 60)
# Position of the activities menu
self.act_pos = (270, 105)
# items holds the categories
self.menu = Menu(self.cat_pos)
# submenus holds the different activities separated by category
self.submenus = {}
# Wich category is active
self.active = None
if items:
for item in items:
if not self.submenus.has_key(item.category):
submenu = MenuActivity(self.act_pos)
self.submenus[item.category] = submenu
self.submenus[item.category].add(item)
for item in self.submenus.keys():
self.menu.add(ItemCategory(item, self.cat_pos))
introduction = (u"Este contenido educativo",
u"está diseñado con actividades ",
u"lúdicas para la adquisición de ",
u"conceptos y hábitos que contribuyen ",
u"a formar niñas y niños saludables.",
u" ",
u"Esperamos que pases momentos ",
u"agradables y divertidos ",
u"mientras aprendes.")
font_default = pygame.font.SysFont(constants.font_default[0],
constants.font_default[1])
isize = font_default.size(introduction[0])[1]
introduction_pos = (constants.screen_mode[0] / 2.0 + 3, 100)
introduction_ = []
for i in introduction:
line = font_default.render(i, True, (102, 102, 102))
introduction_.append(line)
self.text = ((introduction_, introduction_pos),)
self.finger = Finger()
self.sprites = pygame.sprite.Group()
self.icons = pygame.sprite.Group()
self.icons.add([Icons('stop')])
self.sprites.add((self.finger, self.icons))
self.pos = None
return
示例2: __init__
def __init__(self, screen):
Activity.__init__(self, screen)
self.CloseButton = pygame.sprite.RenderUpdates(([Icons('stop')]))
self.finger = Finger()
self.Cursor = pygame.sprite.RenderUpdates((self.finger))
self.pos = None
self.messages_filename = constants.poetry
示例3: __init__
def __init__(self, screen, pos):
Activity.__init__(self, screen)
self.couple = set()
self.couples = []
self.sprites0 = pygame.sprite.OrderedUpdates()
self.sprites1 = pygame.sprite.OrderedUpdates()
self.pointer_ = pygame.sprite.OrderedUpdates()
self.items = pygame.sprite.Group()
self.icons = pygame.sprite.Group()
self.icons.add([Icons('stop')])
self.sprites0.add(self.icons)
for i in pos.keys():
item = Item(i, pos[i])
self.sprites0.add(item)
self.items.add(item)
self.pointer = Pointer()
self.pointer_.add(self.pointer)
self.arrows = []
self.arrow = None
示例4: add_follower
def add_follower(cls, leader, follower):
# TODO: expand to handle more than 5000 followers, using extra entities
follower_id = follower.key().id() # TickUser.get_by_user_id(follower.user_id(),keys_only=True).id()
leader_id = leader.key().id()
check = cls.all(keys_only=True).ancestor(leader).filter("followers_ids =", follower_id).get()
if not check:
entity = cls.all().ancestor(leader).filter("leader_id =", leader_id).get()
if entity:
entity.follower_ids.append(follower_id)
index = entity.get_follow_index()
index.add_followers(follower.all_user_ids)
index.put()
entity.put()
else:
new_entity = cls(parent=leader, leader_id=leader_id, follower_ids=[follower_id])
new_entity.put()
new_index = FollowIndex(parent=new_entity)
new_index.add_leaders(leader.all_user_ids)
new_index.add_followers(follower.all_user_ids)
new_index.put()
from activity import Activity
Activity.create(
"<actor>|began following|<target>", actor=follower, target=leader, extra_recipients=[leader]
)
return True
else:
return False
示例5: validation_data
def validation_data(self, contrast=1., small_batch_size = 1000,large_batch_size = 50000):
parameters = self.network.parameters
parameters.batch_size = small_batch_size
orig_time_data = parameters.time_data
orig_keep_spikes = parameters.keep_spikes
#parameters.time_data = True
#parameters.static_data_control = True
parameters.keep_spikes = True
if orig_keep_spikes == False:
self.network.spike_train = ()
nout = parameters.M
for ii in np.arange(self.network.n_layers):
out_dim = nout[ii]
self.network.spike_train += (nw.make_shared((parameters.batch_size,
out_dim,
parameters.num_iterations)),)
small_bs = self.network.parameters.batch_size
batch_size = large_batch_size
if parameters.time_data and not parameters.static_data_control:
data = Time_Data(os.path.join(os.environ['DATA_PATH'],'vanhateren/whitened_images.h5'),
1000,
parameters.batch_size,
parameters.N,
parameters.num_frames,
start=35)
else:
data = Static_Data(os.path.join(os.environ['DATA_PATH'],'vanhateren/whitened_images.h5'),
1000,
parameters.batch_size,
parameters.N,
start=35)
self.network.to_gpu()
activity = Activity(self.network)
self.big_X = np.zeros((batch_size, parameters.N), dtype='float32')
self.big_Y = ()
for layer in range(self.network.n_layers):
self.big_Y += (np.zeros((batch_size, parameters.M[layer]), dtype='float32'),)
for ii in range(batch_size/small_bs):
data.make_X(self.network)
if contrast != 1.:
self.network.X.set_value(self.network.X.get_value() *
np.array(contrast, dtype='float32'))
activity.get_acts()
self.big_X[ii*small_bs:(ii+1)*small_bs,:] = self.network.X.get_value()
for layer in range(self.network.n_layers):
self.big_Y[layer][ii*small_bs:(ii+1)*small_bs,:] = self.network.Y[layer].get_value()
self.network.to_cpu()
self.network.Y = self.big_Y
self.network.X = self.big_X
self.network.parameters.time_data = orig_time_data
self.network.parameters.keep_spikes = orig_keep_spikes
示例6: readFile
def readFile (filename, partition) :
"""
Read files filename and partition and return the correponding work sheet
"""
Activity.readPartition (partition)
w = WorkSheet()
w.read(filename)
return w
示例7: __init__
def __init__(self, screen):
Activity.__init__(self, screen)
self.wrong_pos = [
Rect(490, 272, 21, 29),
Rect(439, 315, 47, 21),
Rect(435, 355, 34, 29),
Rect(458, 376, 45, 47),
Rect(517, 372, 63, 36),
Rect(614, 370, 37, 41),
Rect(525, 421, 33, 30),
Rect(567, 454, 25, 20),
Rect(510, 473, 34, 33),
Rect(467, 505, 36, 23),
Rect(541, 516, 33, 28),
Rect(639, 432, 53, 45),
Rect(738, 329, 41, 23),
Rect(722, 206, 29, 21),
Rect(713, 176, 33, 20),
Rect(653, 196, 30, 26),
Rect(519, 271, 61, 52),
Rect(583, 290, 24, 22),
Rect(591, 318, 29, 38),
Rect(401, 536, 105, 61),
Rect(720, 248, 74, 33),
]
self.found = 0
self.screen = screen
path = os.path.join(constants.data_folder, "backgrounds", 'illustration_020_021.png')
self.background, rect = common.load_image(path)
self.title = ("¡Orden en mi habitación!",)
self.instructions = ("Observa estas dos habitaciones. Una está ordenada",
"y la otra desordenada: descubre las 21 diferencias y",
"márcalas con una X en la habitación desordenada")
self.icons = pygame.sprite.Group()
self.icons.add([Icons('stop')])
self.pointer_ = Xs()
self.pointer = sprite.RenderUpdates([self.pointer_, self.icons])
self.xs = sprite.RenderUpdates()
self.xs.draw(self.screen)
self.pointer.draw(self.screen)
self.check = sprite.RenderUpdates()
self.room = Rect(403, 129, 393, 467)
pygame.display.update()
示例8: __init__
def __init__(self, screen):
Activity.__init__(self, screen)
self.close_button = pygame.sprite.RenderUpdates(([Icons('stop')]))
self.finger = Finger()
self.cursor = pygame.sprite.RenderUpdates((self.finger))
self.pos = None
self.line_start = (0, 0)
self.draw_color = (0, 0, 0)
self.line_width = 3
self.line_end = None
self.text()
self.transparent = pygame.Rect(297, 96, 400, 408)
# Color palette
self.palette = {}
self.mk_palette(constants.rgb_colors)
# Thickness
self.thickness = {}
self.mk_thickness()
示例9: __init__
def __init__(self, screen):
Activity.__init__(self, screen)
self.background = common.load_image(constants.illustration_019)[0]
words = {
'saludable': (114, 236),
'risa': (41, 264),
'alimentos': (143, 283),
'agua': (41, 307),
'descanso': (101, 346),
'amor': (89, 375),
'limpieza': (26, 407),
'deporte': (149, 445),
'sol': (59, 463),
'aire': (109, 490),
'aseo': (55, 514),
'banarse': (193, 542),
}
self.title = ("¡Palabras largas, palabras cortas!",)
self.instructions = ("Estas palabras están relacionadas con la salud.",
" ",
"Arrastra hacia la bolsa roja",
"las palabras que tienen",
"menos de 5 letras y hacia la",
"bolsa azul las que tienen",
"más de 5 letras.")
self.informative_text(self.title, self.instructions)
self.hand = Hand()
self.icons = pygame.sprite.Group()
self.icons.add([Icons('stop')])
self.words = pygame.sprite.Group()
self.sprites = pygame.sprite.OrderedUpdates()
for word, pos in words.items():
word_ = Word(word, pos)
self.sprites.add(word_)
self.words.add(word_)
self.sprites.add([self.icons, self.hand])
self.sprites.draw(self.screen)
self.selected = None
self.bags = (Bag('cortas', (430, 150, 170, 150), (475, 175, 100, 120)),
Bag('largas', (430, 375, 170, 160), (480, 395, 105, 130)))
return
示例10: __init__
def __init__(self, window, app, antfile):
Gtk.ListBoxRow.__init__(self)
Activity.__init__(self, app, antfile)
self.window = window
grid = Gtk.Grid(margin=6)
grid.set_column_spacing(10)
self.add(grid)
self.image = Gtk.Image(icon_name='preferences-system-time-symbolic',
icon_size=self.ICON_SIZE)
self.label = Gtk.Label()
self.label.set_ellipsize(Pango.EllipsizeMode.END)
self.label.set_valign(Gtk.Align.CENTER)
self.label.set_halign(Gtk.Align.START)
self.spinner = Gtk.Spinner()
self.spinner.set_valign(Gtk.Align.CENTER)
self.spinner.set_halign(Gtk.Align.END)
self.spinner.set_hexpand(True)
self.spinner.set_no_show_all(True)
self.selector_button = Gtk.CheckButton()
self.selector_button.set_valign(Gtk.Align.CENTER)
self.selector_button.set_halign(Gtk.Align.END)
self.selector_button.set_hexpand(True)
self.selector_button.set_no_show_all(True)
grid.attach(self.image, 0, 0, 1, 1)
grid.attach(self.label, 1, 0, 1, 1)
grid.attach(self.spinner, 2, 0, 1, 1)
# don't show spinner yet
grid.attach(self.selector_button, 3, 0, 1, 1)
# don't show selector button yet
if not self.downloaded:
self.label.set_sensitive(False)
self.image.set_from_icon_name('dialog-question-symbolic', self.ICON_SIZE)
self.connect('status-changed', self.status_changed_cb)
self.status_changed_cb(self, self.status)
示例11: __init__
def __init__(self, screen):
Activity.__init__(self, screen)
self.count = 0
self.id = ""
# Change the mouse pointer by a hand
self.button_down = 0
self.selection = 0
self.hand = Hand()
self.sprites = pygame.sprite.OrderedUpdates()
self.pictures = pygame.sprite.Group() # Picture that can be move
self.transparent= pygame.sprite.Group() # Picture that cann't be move
self.icons = pygame.sprite.Group()
self.icons.add([Icons('stop')])
self.transparent.add([ \
ImagePuzzle(302, 100, 1, "5"), \
ImagePuzzle(500, 100, 2, "5"), \
ImagePuzzle(302, 250, 3, "5"), \
ImagePuzzle(500, 250, 4, "5")]
)
示例12: _new_activity
def _new_activity(self, activity_id, tp, room):
try:
objid = self._get_next_object_id()
activity = Activity(self._session_bus, objid, self, tp, room,
id=activity_id)
except Exception:
# FIXME: catching bare Exception considered harmful
_logger.debug("Invalid activity:", exc_info=1)
try:
del self._activities_by_handle[tp][room]
except KeyError:
pass
return None
activity.connect("validity-changed",
self._activity_validity_changed_cb)
activity.connect("disappeared", self._activity_disappeared_cb)
self._activities_by_id[activity_id] = activity
self._activities_by_handle[tp][room] = activity
return activity
示例13: append_extra
def append_extra(self, trs):
"""
Append extra tiers in trs: Activity and PhnTokAlign.
"""
tokenalign = trs.Find("TokensAlign")
if tokenalign is None:
self.print_message("No time-aligned tokens found. No extra tier can be generated.", indent=2, status=WARNING_ID)
return trs
# PhnTokAlign tier
if self._options['phntok'] is True:
try:
phonalign = trs.Find("PhonAlign")
tier = self.phntokalign_tier(phonalign,tokenalign)
trs.Append(tier)
trs.GetHierarchy().addLink("TimeAssociation", tokenalign, tier)
except Exception as e:
self.print_message("PhnTokAlign generation: %s"%str(e), indent=2, status=WARNING_ID)
# Activity tier
if self._options['activity'] is True or self._options['activityduration']:
try:
activity = Activity( trs )
tier = activity.get_tier()
if self._options['activity'] is True:
trs.Append(tier)
trs.GetHierarchy().addLink("TimeAlignment", tokenalign, tier)
if self._options['activityduration'] is True:
dtier = tier.Copy()
dtier.SetName( "ActivityDuration" )
trs.Append(dtier)
for a in dtier:
d = a.GetLocation().GetDuration().GetValue()
a.GetLabel().SetValue( '%.3f' % d )
except Exception as e:
self.print_message("Activities generation: %s"%str(e), indent=2, status=WARNING_ID)
return trs
示例14: remove_follower
def remove_follower(leader, follower):
follower_id = follower.key().id()
existing = (
Follow.all()
.ancestor(leader)
.filter("leader_id =", leader.key().id())
.filter("follower_ids =", follower_id)
.get()
)
if not existing:
return False
existing.follower_ids.remove(follower_id)
existing.put()
# do dependent index
index = existing.get_follow_index()
for user_id in follower.all_user_ids:
index.remove_follower(user_id)
index.put()
from activity import Activity
Activity.create("<actor>|stopped following|<target>", actor=follower, target=leader, extra_recipients=[leader])
return True
示例15: __init__
def __init__(self, screen):
Activity.__init__(self, screen)
"""change the mouse pointer by a hand"""
self.button_down = 0
self.rectList = [
pygame.Rect(311, 91, 158, 51),
pygame.Rect(546, 414, 67, 121),
pygame.Rect(157, 358, 72, 109),
]
self.sprites = pygame.sprite.OrderedUpdates()
self.icons = pygame.sprite.Group()
self.icons.add([Icons('stop')])
image_check = image_normal = os.path.join(constants.icons_folder,\
"check.png")
self.checkImage, self.checkRect = common.load_image\
(image_check)
self.hand = Hand()
self.tex_info = {
'title': ["Una boca bien sana", None],
'instructions' : [["Selecciona aquellos objetos", \
"que son necesarios para mantener tu boca sana"], None]
}