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 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): """run the app The screen is spearated in on part showing the chunk of the text that can be read, and one part showing the possible actions : read, or get next chunk. The application also define a few actions to open a file, set the speed of the voice, etc. """ self.file = None self.speed = 120 self.voice = 'm1' frame = self.view(window, back_button=True) # create the app menu actor = frame.actor open_item = actor.new_action("Open") open_item.connect('activated', self.on_open) speed_item = actor.new_action("Speed") for speed in [50, 120, 170, 300]: item = speed_item.new_action("%d" % speed) item.connect('activated', self.on_set_speed, speed) voice_item = actor.new_action("Voice") for voice in ['m1', 'm2', 'f1', 'f2']: item = voice_item.new_action("%s" % voice) item.connect('activated', self.on_set_voice, voice) # Show the text zone vbox = gui.Box(frame, axis=1, expand=True) self.text = tichy.Text('') self.text.view(vbox, expand=True) hbox = gui.Box(vbox, axis=0) # Create the buttons read_button = gui.Button(hbox) gui.Label(read_button, "Read") read_button.connect('clicked', self.on_read) next_button = gui.Button(hbox) gui.Label(next_button, "Next") next_button.connect('clicked', self.on_next) # Wait till we quit yield tichy.Wait(frame, 'back')
def run(self, window): """Create a new box for the notifications""" self.box = gui.Box(window, axis=0) notifications_service = tichy.Service('Notifications') notifications_service.connect('new-notification', self.on_new_notification) yield None
def run(self, window, text="", name=None, input_method=None): """Edit a text object The actual value of the text object will be modifed only when we quit the app. """ text = tichy.Text.as_type(text) title = "Edit %s" % name if name else "Edit Text" frame = self.view(window, title=title, back_button="OK") vbox = gui.Box(frame, axis=1, border=0, spacing=0) self.text = tichy.Text(text) self.text.view(vbox, editable=True, auto_keyboard=False, expand=True) self.keyboard = tichy.Service('Keyboard').get() if input_method: self.keyboard.set_input_method(input_method) self.keyboard.view(vbox) yield tichy.Wait(frame, 'back') text.value = self.text.value yield self.text.value
def run(self, window): self.window = window frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) self.question_text = tichy.Text("Question") self.question_text.view(vbox, expand=True, font_size=58) self.choices = tichy.List() self.choices.view(vbox, expand=True) frame.connect('back', self.on_quit) dic = codecs.open(Learn.path('characters.dic'), encoding='utf-8') logger.info("opening the dict") # dic = open(Learn.path('characters.dic'), 'r') dic = Dic.read(dic) self.full_dic = dic[:] brain = Brain() logger.info("start game") self.task = None while True: self.task = brain.ask(self.ask, dic) try: yield self.task except GeneratorExit: break
def run(self, window, sms): frame = self.view(window, title="Message", back_button=True) vbox = gui.Box(frame, axis=1, expand=True) self.sms = sms # The destination field hbox = gui.Box(vbox, axis=0) gui.Label(hbox, "to:") self.sms.number.create_actor().view(hbox, expand=True) # The message self.sms.text.view(vbox, editable=True, expand=True) frame.actor.new_action("Send").connect('activated', self.on_send) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, title="Outbox", back_button=True) vbox = gui.Box(frame, axis=1, expand=True) messages_service = tichy.Service('Messages') # We create a view on actors of every items in the outbox messages_service.outbox.actors_view(vbox) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button="Load") vbox = gui.Box(frame, axis=1, expand=True) list_view = self.list.view(vbox) self.select_path(os.path.expanduser('~/')) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) master = VolumeItem('master') master.view(vbox) yield tichy.Wait(frame, 'back')
def run(self, window, sms): frame = self.view(window, title="Sending...") vbox = gui.Box(frame, axis=1, expand=True) try: yield sms.send() yield tichy.Dialog(window, "Sent", "") except Exception, e: logger.error("Error: %s", e) yield tichy.Dialog(window, "Error", e)
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) gsm_service = tichy.Service('GSM') gsm_service.logs.actors_view(vbox) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) button = gui.Button(vbox) gui.Label(button, "fake SMS") button.connect('clicked', self.on_fake_sms) # Wait until the quit button is clicked yield tichy.Wait(frame, 'back')
def view(self, parent): box = gui.Box(parent, axis=0) gui.Label(box, self.name) self.text.view(box) inc = gui.Button(box) gui.Label(inc, '+') inc.connect('clicked', self._on_inc) dec = gui.Button(box) gui.Label(dec, '-') dec.connect('clicked', self._on_dec) return box
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 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 run(self, parent, title, msg): w = gui.Window(parent) frame = self.view(w, title=title) vbox = gui.Box(frame, axis=1, expand=True) gui.Label(vbox, msg, expand=True) b = gui.Button(vbox) gui.Label(b, 'OK') yield Wait(b, 'clicked') w.destroy()
def run(self, window, contact): self.contact = contact self.name = "Edit %s" % contact.name self.frame = self.view(window, back_button=True) vbox = gui.Box(self.frame, axis=1, expand=True) self.attr_list = tichy.ActorList() self.update() list_view = self.attr_list.view(vbox) yield tichy.Wait(self.frame, 'back')
def run(self, parent): self.window = gui.Window(parent, modal=True) vbox = gui.Box(self.window, axis=1, border=0, spacing=0) self.lock_widget = ScreenLockWidget(vbox, Vect(480, 560)) size = Vect(42, 42) gui.Label(vbox, ' Trace the pattern to unlock', min_size=size, optimal_size=size) yield tichy.Wait(self.lock_widget, 'unlocked-screen') self.window.destroy()
def view(self, parent, **kargs): """Create a view of the Item :Parameters: `parent` : gui.Widget The parent widget the view will be created in :Returns: the widget that represents the item """ ret = gui.Box(parent, axis=0, border=0) gui.Label(ret, "%s:" % self.field.name) if self.value: self.value.view(ret) return ret
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) self.contacts_service = tichy.Service('Contacts') self.contacts = self.contacts_service.contacts self.contacts.actors_view(vbox) new_action = frame.actor.new_action('New') new_action.connect('activated', self._on_new) copy_all_action = frame.actor.new_action('Copy All') copy_all_action.connect('activated', self._on_copy_all) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) # We create a list of the sub applications actors list = tichy.ActorList() for app in [New, Inbox, Outbox]: actor = app.create_actor() list.append(actor) list.view(vbox) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) # The search entry text = tichy.Text('') text.view(vbox, editable=True) text.connect('modified', self.on_text_modified) # The result actions self.results = tichy.List() self.results.actors_view(vbox, can_delete=False, expand=True) self.dict = Dict(self.path()) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) styles = [s.create() for s in tichy.Style.subclasses] styles_list = tichy.ActorList() for s in styles: actor = tichy.Actor(s) use_action = actor.new_action('Use') use_action.connect('activated', self.on_use_style) styles_list.append(actor) styles_list.view(vbox) yield tichy.Wait(frame, 'back')
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) # We create a list of the sub applications actors list = tichy.ActorList() for app in [ ProfilesConf, StyleConf, PhoneConf, ScreenLockConf, SoundConf ]: actor = app.create_actor() list.append(actor) list.view(vbox, expand=True) # Wait until the quit button is clicked yield tichy.Wait(frame, 'back')
def run(self, window, file_name='', can_create=False): msg = can_create and 'Save' or 'Load' frame = self.view(window, title='Select File', back_button=msg) vbox = gui.Box(frame, axis=1, expand=True) self.file_name_item = tichy.Text(file_name, editable=can_create) self.file_name_item.view(vbox) list_view = self.list.view(vbox) self.select_path(os.path.expanduser('~/')) yield tichy.Wait(frame, 'back') # Return the result yield os.path.join(self.dir, self.file_name_item.value)
def __init__(self, parent, list, expand=True, **kargs): super(ListView, self).__init__(parent, item=list, axis=1, border=0, spacing=0, expand=expand) vbox = gui.Box(self, axis=1) # We add the already present items : for item in list: item.view(vbox) self.monitor(list, 'appened', self.on_appened, vbox) self.monitor(list, 'removed', self.on_removed, vbox) self.monitor(list, 'cleared', self.on_clear, vbox) self.monitor(list, 'inserted', self.on_insert, vbox)
def run(self, window): frame = self.view(window, back_button=True) vbox = gui.Box(frame, axis=1, expand=True) prefs = tichy.Service('Prefs') phone = prefs['phone'] # We create a list of actor on all the params we want to show self.params_list = tichy.List() for param in ['ring-tone', 'ring-volume']: param_item = ParamItem(phone, param) actor = tichy.Actor(param_item) self.params_list.append(actor) self.params_list.view(vbox) yield tichy.Wait(frame, 'back')
def run(self, parent): #### build and layout #### mainWindow = gui.Window(parent, modal=True) appFrame = self.view(mainWindow, back_button=True) vbox = gui.Box(appFrame, axis=1, border=0) appListView = self.list.view(vbox) gui.Spring(vbox, axis=1) upButton = gui.Button(vbox) gui.Label(upButton, '.. previous menu ..') upButton.connect('clicked', self.go_up) #### retrieve app list #### self.generate_xdg_menu(xdg.Menu.parse()) #### close button #### yield tichy.Wait(appFrame, 'back') mainWindow.destroy()
def run(self, window): self.frame = self.view(window) cancel = self.frame.actor.new_action("Cancel") cancel.connect('activated', self._on_cancel) vbox = gui.Box(self.frame, axis=1, expand=True) for contact in tichy.Service('Contacts').contacts: actor = tichy.Actor(contact) actor.view(vbox) select = actor.new_action("Select") actor.default_action = select select.connect('activated', self._on_select) # Wait until the quit button is clicked yield tichy.Wait(self.frame, 'destroyed') yield self.ret