def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1) self.file_name = tichy.Text("No file") self.file_name.view(vbox) self.x_window = gui.XWindow(vbox) self.status_name = tichy.Text("") self.status_name.view(vbox) # We put a few buttons box = gui.Box(vbox, axis=0) play_button = gui.Button(box, optimal_size=gui.Vect(96, 96)) tichy.Image(self.path('play.png')).view(play_button) pause_button = gui.Button(box, optimal_size=gui.Vect(96, 96)) tichy.Image(self.path('pause.png')).view(pause_button) stop_button = gui.Button(box, optimal_size=gui.Vect(96, 96)) tichy.Image(self.path('stop.png')).view(stop_button) open_button = gui.Button(box, optimal_size=gui.Vect(96, 96)) tichy.Image(self.path('open.png')).view(open_button) stop_button.connect('clicked', self.on_stop) play_button.connect('clicked', self.on_play) pause_button.connect('clicked', self.on_pause) open_button.connect('clicked', self.on_open) frame.actor.new_action("Volume").connect('activated', self.on_volume) yield tichy.Wait(frame, 'back')
def __init__(self): self.outbox = tichy.List() self.inbox = tichy.List() # Prepare the future notification self.notification_icon = tichy.Image(self.path('pics/message.png'), (32, 32)) self.notification = None
def view_actor(self, parent, actor, **kargs): ret = gui.Button(parent, item=actor, holdable=1000, **kargs) hbox = gui.Box(ret, axis=0, border=0, spacing=0) if actor.item.icon: icon_path = actor.item.path(actor.item.icon) icon = tichy.Image(icon_path, size=Vect(96, 96)).view(hbox) else: gui.Widget(hbox, min_size=Vect(0, 96)) text_box = gui.Box(hbox, axis=1, border=0, spacing=0) actor.item.get_text().view(text_box) sub_text = actor.get_sub_text() if sub_text: sub_text.view(text_box) def on_clicked(b, actor, self): self.select_actor(actor, b) ret.connect('clicked', on_clicked, actor, self) def on_holded(b, actor, self): self.select_actor(actor, b, use_default=False) ret.connect('holded', on_holded, actor, self) return ret
def run(self, window): self.image = tichy.Image(self.path('battery0.png'), (32, 32)) self.image.view(window) self.capacity = None # XXX: specific to openmoko ! self.sys_dir = \ '/sys/devices/platform/bq27000-battery.0/power_supply/bat/' tichy.mainloop.timeout_add(5000, self.on_timer) yield None
def view(self, parent): ### should I use actor? displayButton = gui.Button(parent) displayButtonBox = gui.Box(displayButton, axis=0) tichy.Image(self.get_icon_path(), size=Vect(96, 96)).view(displayButtonBox) tichy.Text(self.name).view(displayButtonBox) self.button = displayButton self.button.connect('clicked', self.on_click) return self.button
def __init__(self, parent, actor, **kargs): assert isinstance(actor, tichy.Actor) super(ActorView, self).__init__(parent, item=actor, tags=['grid-item']) box = gui.Box(self, axis=1, spacing=0, border=0) icon_frame = gui.Frame(box, border=0) if actor.item.icon: icon_path = actor.item.path(actor.item.icon) icon = tichy.Image(icon_path, size=Vect(96, 96)).view(icon_frame) else: gui.Widget(icon_frame, min_size=Vect(96, 96)) actor.get_text().view(box)
def __init__(self, parent, actors, **args): super(Wheel, self).__init__(parent, min_size=Vect(480, 480)) box = gui.Fixed(self, min_size=Vect(480, 480)) self.wheel = tichy.Image(WheelDesign.path('wheel.png'), Vect(480, 288)).view(box) self.actors = [] for i, actor in enumerate(actors): label = actor.get_text().view(box) self.actors.append(label) self.radius = 200 self.center = Vect(self.radius, 0) self.angle = pi
def run(self, window): image = tichy.Image(self.path('network0.png'), (32, 32)) image.view(window) gsm_service = tichy.Service('GSM') def on_network_strength(gsm, strength): # We assume the strenght can go from 0 to 100 (is it true # ?). The images index go from 0 to 4 index = strength * 4 / 100 assert index >= 0 and index <= 4 image.path = self.path('network%d.png' % index) gsm_service.connect('network-strength', on_network_strength) yield None
def code(cls): return { 'background': None, 'font': Font(None, 26), gui.Edit: {'background': Frame(tichy.Image( MyStyle.path('edit_frame.png')))}, gui.Button: { 'background': Frame(tichy.Image( MyStyle.path('button_frame.png'))), 'min-size': gui.Vect(3, 3) * 32}, # The tag here is a filter on the widgets that have this # string in there keys Tag('application-bar'): { 'background': Frame(tichy.Image( MyStyle.path('bar_frame.png'))), 'children-style': { 'background': None, Tag('selected'): {'background': Frame(tichy.Image( MyStyle.path('button_pressed_frame.png')))}, Tag('back-button'): { 'background': Frame(tichy.Image( MyStyle.path('button_frame.png')))}}}, Tag('application-content'): { 'background': Frame(tichy.Image( MyStyle.path('content_frame.png')))}, 'pressed-style': { 'background': Frame(tichy.Image( MyStyle.path('button_pressed_frame.png')))}, Tag('selected'): { 'background': Frame(tichy.Image( MyStyle.path('button_pressed_frame.png')))}, Menu: { 'children-style': { gui.Button: { 'background': Frame(tichy.Image( MyStyle.path('menu_button_frame.png')))}}}, gui.Box: {'spacing': 8, 'border': 4}, tichy.List: { 'border': 16, 'children-style': { gui.Box: {'spacing': 8, 'border': 8}, gui.Table: {'spacing': 32}, gui.Button: { 'background': Frame(tichy.Image( MyStyle.path('button_frame.png'))), Tag('selected'): { 'background': Frame(tichy.Image( MyStyle.path( 'button_pressed_frame.png')))}}, Tag('grid-item'): { 'background': None, 'min-size': gui.Vect(128, 128)}}}, gui.ScrollableSlide: { 'background': Frame(tichy.Image( MyStyle.path('button_frame.png')))}}