def _record_from_history(self): """ Inspects the recognition history, formats it for the GUI component which lets the user choose which of their prior utterances will become the Playbacks for the new command. """ # save the list as it was when the command was spoken self._preserved = self._history[:] # format for display formatted = "" for t in self._preserved: for w in t: formatted += w.split("\\")[0] + "[w]" formatted += "[s]" formatted = formatted.encode("unicode_escape") # use a response window to get a spec and word sequences for the new macro h_launch.launch(settings.QTYPE_RECORDING, data=formatted) on_complete = AsynchronousAction.hmc_complete( lambda data: self._add_recorded_macro(data)) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def settings_window(): h_launch.launch(settings.WXTYPE_SETTINGS) on_complete = AsynchronousAction.hmc_complete(lambda data: receive_settings(data)) AsynchronousAction( [L(S(["cancel"], on_complete))], time_in_seconds=1, repetitions=300, blocking=False).execute()
def _execute(self, data=None): '''the factory (ConfirmAction) sharing data with the objects it generates (StackItemConfirm) would be a problem if there could ever be more than one of these at a time, but there can't''' self.mutable_integer["value"] = 0 confirm_stack_item = StackItemConfirm(self, data) confirm_stack_item.shared_state(self.mutable_integer) h_launch.launch(settings.QTYPE_CONFIRM, data=settings.HMC_SEPARATOR.join( self.instructions.split(" "))) self.nexus().state.add(confirm_stack_item)
def alias(self, spec): text = read_highlighted(10) spec = str(spec) if text is not None: if spec: self.refresh(spec, str(text)) else: h_launch.launch(settings.QTYPE_INSTRUCTIONS, data="Enter_spec_for_command|") on_complete = AsynchronousAction.hmc_complete( lambda data: self.refresh(data[0].replace("\n", ""), text), self.nexus) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def record_from_history(self): # save the list as it was when the command was spoken self.nexus.preserved = self.nexus.history[:] # format for display formatted = "" for t in self.nexus.preserved: for w in t: formatted += w.split("\\")[0] + "[w]" formatted += "[s]" # use a response window to get a spec and word sequences for the new macro h_launch.launch(settings.QTYPE_RECORDING, data=formatted) on_complete = AsynchronousAction.hmc_complete( lambda data: self.add_recorded_macro(data), self.nexus) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def _alias(self, spec): """ Takes highighted text and makes a Text action of it and the passed spec. Uses an AsynchronousAction to wait for a GUI to get the aliased word. :param spec: str :return: """ text = BaseAliasRule._read_highlighted(10) spec = str(spec) if text is not None: if spec: self._refresh(spec, str(text)) else: h_launch.launch(settings.QTYPE_INSTRUCTIONS, data="Enter_spec_for_command|") on_complete = AsynchronousAction.hmc_complete( lambda data: self._refresh(data[0].replace("\n", ""), text)) AsynchronousAction( [L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def _execute(self, data=None): self._["tries"] = 0 # reset self._["dragonfly_data"] = data h_launch.launch(self.box_type, data=self.encode_box_settings()) self.nexus().state.add(StackItemAsynchronous(self, data))