def run(self, parent, standalone=False): ##set edje file to be used ##TODO: make one edje file per plugin self.edje_file = os.path.join(os.path.dirname(__file__), 'msgs.edj') ##get message service and list of all messages self.contact_service = tichy.Service.get('Contacts') self.contacts = self.contact_service.contacts ##sort contact by date def comp2(m1, m2): return cmp(str(m1.name).lower(), str(m2.name).lower()) self.contacts.sort(comp2) ##get message service and list of all messages self.msgs_service = tichy.Service.get('Messages') self.messages = self.msgs_service.messages self.window = gui.elm_list_window(self.edje_file, "main", "list", None, None, True) self.edje_obj = self.window.main_layout ##sort messages by date def comp(m1, m2): return cmp(m2.timestamp, m1.timestamp) self.list_label = [('label', 'peer'), ('label-number', 'text'), ('status', 'status'), ('direction', 'direction')] self.item_list = gui.elm_list(self.messages, self.window, self.edje_file, "item", self.list_label, comp) self.edje_obj.add_callback("*", "messaging", self.create_msg) self.item_list.add_callback("*", "messaging", self.adv_msg) self.item_list.add_callback("save", "*", self.create_contact) ## close the Tele app, with the back button (signal, source, method) self.edje_obj.add_callback("back", "edje", self.signal) self.oid = self.contacts.connect('inserted', self.item_list._redraw_view) self.item_list.add_callback("details", "*", self.msg_details) parent.emit("unblock") i, args = yield tichy.WaitFirst( tichy.Wait(self.window, 'delete_request'), tichy.Wait(self.window, 'back'), tichy.Wait(self.window.window, 'closing')) logger.info('Messages closing') if i != 2: self.contacts.disconnect(self.oid) self.window.delete() del self.item_list
def run(self, window, category='main'): self.category = category main = self.category == 'main' frame = self.view(window, title=self.category, back_button=not main) # We populate the frame with all the applications self.list_view = None self._populate(frame) def run_lock(action, app, view): tichy.Service('ScreenLock').run(view.window) lock_item = frame.actor.new_action('Screen Lock') # the item does not really toggle back. # we will need a one that does 'launched' probably lock_item.connect('activated', run_lock) # If the design change we repopulate the frame This is a # little bit tricky. We use the 'changed' signal from the # Service('Design') base object... def on_design_changed(s, design): self._populate(frame) tichy.Service('Design').base.connect('changed', on_design_changed) quit_item = frame.actor.new_action('Quit') yield tichy.WaitFirst(tichy.Wait(quit_item, 'activated'), tichy.Wait(frame, 'back'))
def run(self, parent=None, standalone=False): ##set edje_file self.edje_file = os.path.join(os.path.dirname(__file__), 'calculator.edj') ## edje_file, group, x=1.0, y=1.0, topbar=False, onclick=None self.window = gui.elm_layout_window(self.edje_file, "main", None, None, False) self.edje_obj = self.window.main_layout ## close the Tele app, with the back button self.edje_obj.add_callback("back", "edje", self.signal) parent.emit("unblock") ##wait until main object emits back signal or delete is requested i, args = yield WaitFirst(Wait(self.window, 'delete_request'), tichy.Wait(self.window, 'back'), tichy.Wait(self.window.window, 'closing'), tichy.Wait(self.edje_obj, 'back')) logger.info('Calculator closing') if i != 2: self.window.delete()
def run(self, parent=None, standalone=False): ##set edje_file self.edje_file = os.path.join(os.path.dirname(__file__), 'tele.edj') self.window = gui.elm_layout_window(self.edje_file, "main", None, None, True) self.edje_obj = self.window.main_layout ##connect to tichy's contacts service self.contact_service = tichy.Service.get('Contacts') ##connect to tichy's ussd service self.ussd_service = tichy.Service.get('Ussd') self.edje_obj.add_callback("num_field_pressed", "*", self.num_field_action) self.edje_obj.add_callback("*", "embryo", self.embryo) self.edje_obj.add_callback("*", "call", self.call) ## close the Tele app, with the back button self.edje_obj.add_callback("back", "edje", self.signal) parent.emit("unblock") ##wait until main object emits back signal or delete is requested i, args = yield tichy.WaitFirst( tichy.Wait(self.window, 'delete_request'), tichy.Wait(self.window, 'back'), tichy.Wait(self.window.window, 'closing'), tichy.Wait(self.edje_obj, 'back')) logger.info('Tele closing') if i != 2: self.window.delete()
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): 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 ask(self, card, level): logger.info("ask") question = card.q logger.info("generate answers set") # We also use 3 random value from the dict rand_answers = [random.choice(self.full_dic).a for i in range(3)] answers = rand_answers + [card.a] random.shuffle(answers) self.question_text.value = question self.choices.clear() choices = [Choice(a) for a in answers] for c in choices: self.choices.append(c) logger.info("wait for answer") ret = yield tichy.WaitFirst( *[tichy.Wait(c, 'selected') for c in choices]) ret = answers[ret[0]] if ret == card.a: # Correct answer # yield tichy.Dialog(self.window, # "Correct", "%s : %s" % # (card.a, card.comment or '')) yield Answer(self.window, card, True) yield True else: # yield tichy.Dialog(self.window, "Wrong Answer", "") yield Answer(self.window, card, False) yield False
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, text="", name=None, input_method=None): print "PIN called" print text print name print input_method ##set edje_file self.edje_file = os.path.join(os.path.dirname(__file__), 'paroli-dialer.edj') self.main = window self.edje_obj = gui.edje_gui(self.main, 'tele', self.edje_file) self.edje_obj.edj.layer_set(2) self.edje_obj.edj.name_set('PIN') self.edje_obj.edj.part_text_set('call-button-text', 'Enter') self.edje_obj.edj.signal_callback_add("func_btn", "*", self.func_btn) self.edje_obj.edj.signal_callback_add("add_digit", "*", self.add_digit) self.edje_obj.edj.show() yield tichy.Wait(self.main, 'value_received') number = self.edje_obj.edj.part_text_get("active-call") self.edje_obj.edj.delete() self.main.etk_obj.visibility_set(0) yield number
def register(self, on_step=None): """Tasklet that registers on the network :Parameters: on_step : callback function | None a callback function that take a string argument that will be called at every step of the registration procedure """ def default_on_step(msg): pass on_step = on_step or default_on_step try: LOGGER.info("Request the GSM resource") on_step("Request the GSM resource") yield WaitDBus(self.ousage.RequestResource, 'GSM') yield self._turn_on(on_step) on_step("Register on the network") LOGGER.info("register on the network") yield WaitDBus(self.gsm_network.Register) yield tichy.Wait(self, 'provider-modified') except Exception, ex: LOGGER.error("Error : %s", ex) raise
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): 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="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) 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 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, standalone=False): ##set edje file to be used ##TODO: make one edje file per plugin self.edje_file = os.path.join(os.path.dirname(__file__),'people.edj') ##get contact service and list of all contacts self.contact_service = tichy.Service.get('Contacts') self.contacts = self.contact_service.contacts ##sort contact by name def comp(m1, m2): return cmp(str(m1.name).lower(), str(m2.name).lower()) ##generate app-window self.window = gui.elm_list_window(self.edje_file, "main", "list", None, None, True) self.edje_obj = self.window.main_layout self.list_label = [('label','name')] self.item_list = gui.elm_list(self.contacts, self.window, self.edje_file, "item", self.list_label, comp, True) self.item_list.add_callback("contact_details", "*", self.contact_details) self.item_list.add_callback("send_all", "fold-back", self.self_test) self.item_list.add_callback("create_message", "*", self.create_msg) self.edje_obj.add_callback("back-button", "*", self.signal) self.edje_obj.add_callback("add_contact", "*", self.create_contact) self.edje_obj.add_callback("*", "dict", self.openDict) ##wait until main object emits back signal or delete is requested #self.window.scroller.elm_obj.focus() #self.item_list.jump_to_index('q') parent.emit("unblock") yield tichy.WaitFirst(tichy.Wait(self.window, 'delete_request'),tichy.Wait(self.window, 'back')) logger.info('People closing') #self.main.emit('closed') self.window.delete()
def run(self, window, text="", name=None, input_method=None, variable=None): logger.info("PIN2 called") ##set edje_file self.edje_file = os.path.join(os.path.dirname(__file__), 'tele.edj') self.main = gui.elm_layout_window(self.edje_file, "pin_enter") #logger.info("PIN2 main generated") if hasattr(self.main.bg_m, "tb"): tb = self.main.bg_m.tb.Edje tb.signal_emit("hide_clock", "*") tb.signal_emit("show_pin_title", "*") self.edje_obj = self.main.main_layout.Edje if text != "": tb.part_text_set("title", text) self.edje_obj.signal_callback_add("*", "sending_pin", self.call_btn_pressed) #self.edje_obj.signal_callback_add("*", "embryo", self.embryo) i, args = yield tichy.WaitFirst( tichy.Wait(self.main, 'value_received'), tichy.Wait(self.main.window, 'closing')) if i == 0: #value_received number = self.edje_obj.part_text_get("pin-text") if variable != None: variable.value = number self.main.delete() yield number elif i == 1: tichy.mainloop.quit()
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 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) 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): """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): 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) # 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, 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 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, 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, 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, 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
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, parent=None, text=""): if isinstance(text, str): text = tichy.Text(text) #self.window = parent #print dir(parent.etk_obj) #self.window.etk_obj.hide() ##create main evas #self.main = gui.main_edje() self.main = parent ##set title self.main.etk_obj.title_set('Paroli Dialer') ##set edje_file self.edje_file = os.path.join(os.path.dirname(__file__), 'paroli-dialer.edj') ##connect to tichy's contacts service self.contact_service = Service('Contacts') ##get contacts list self.phone_book = self.contact_service.contacts ##create list for edje objects self.contact_objects_list = None ##create main window self.edje_obj = gui.edje_gui(self.main, 'tele', self.edje_file) self.edje_obj.edj.layer_set(2) self.edje_obj.edj.name_set('main_dialer_window') self.edje_obj.edj.show() self.edje_obj.edj.signal_callback_add("func_btn", "*", self.func_btn) self.edje_obj.edj.signal_callback_add("top_bar", "*", self.top_bar) self.edje_obj.edj.signal_callback_add("add_digit", "*", self.add_digit) self.edje_obj.edj.signal_callback_add("num_field_pressed", "*", self.num_field) ##wait until main object emits back signal yield tichy.Wait(self.main, 'back') ##remove all children -- edje elements for i in self.main.children: i.remove() self.main.etk_obj.hide() # Don't forget to close the window