from math import sin, cos, pi from tichy.service import Service from tichy import gui from tichy.gui import Vect from tichy.tasklet import Tasklet, WaitFirst, Wait class ActorView(gui.Button): """An actor view with the icon above the name""" def __init__(self, parent, actor, **kargs): super(ActorView, self).__init__(parent, item=actor, min_size=Vect(128,128)) box = gui.Box(self, axis=1, spacing=0, border=0) if actor.item.icon: icon_path = actor.item.path(actor.item.icon) icon = gui.Image(icon_path, size=Vect(96,96)).view(box) else: gui.Widget(box, min_size=Vect(96,96)) actor.get_text().view(box, font_size=16) class GridDesign(Service): enabled = True service = 'Design' name = 'Grid' def view_actor_list(self, parent, actors, **kargs): ret = gui.Scrollable(parent, border=0, item=actors, axis=1, expandable = True) box = gui.GridBox(ret, axis=1, spacing=8) for actor in actors: view = ActorView(box, actor) def on_clicked(b, actor): # This method is defined in the default design # It will put the actors action in the application frame self.select_actor(actor, b) view.connect('clicked', on_clicked, actor) return ret def __getattr__(self, name): # This is a hack to use the Default Design service methods if the methid is not defined # I which I could instead declare the class like : class WheelDesign(Service("Default")) return getattr(Service('Design', 'Default'), name)