Attachment 'selector_plugin.py'

Download

   1 from accerciser.plugin import Plugin
   2 import gtk
   3 import pyatspi
   4 
   5 # We will derive a new class from the Plugin base class,
   6 # and assign some mandatory class attributes:
   7 class FocusSelect(Plugin):
   8   plugin_name = 'Focus Select'
   9   plugin_description = 'Allows selecting last focused accessible.'
  10   # Override the init method.
  11   def init(self):
  12     # Register an event listener for the "focus" event
  13     pyatspi.Registry.registerEventListener(self.accEventFocusChanged, 
  14                                            'focus')
  15 
  16     # The global_hotkeys instance variable is a list of tuples, 
  17     # each tuple is one global hotkey action, and it is a list of 
  18     # an action description, desired method to call, key symbol of 
  19     # keypress, and a key modifier mask.
  20     self.global_hotkeys = [('Inspect last focused accessible',
  21                             self.inspectLastFocused, 
  22                             gtk.keysyms.e,
  23                             gtk.gdk.CONTROL_MASK | gtk.gdk.MOD1_MASK)]    
  24 
  25     # Initialize as None.
  26     self.last_focused = None
  27 
  28   # In this callback we assign the last_focused instance variable 
  29   # with the accessible that just just emitted the "focus" event.
  30   def accEventFocusChanged(self, event):
  31     if not self.isMyApp(event.source):
  32       self.last_focused = event.source      
  33 
  34   # In the hotkey action callback we update the application
  35   # wide node with the last focused accessible, if we have recorded it.
  36   def inspectLastFocused(self):
  37     if self.last_focused:
  38       self.node.update(self.last_focused)
  39 
  40   

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2021-02-25 09:44:42, 0.6 KB) [[attachment:pushbutton_event.py]]
  • [get | view] (2021-02-25 09:44:42, 1.0 KB) [[attachment:pushbutton_event.pyc]]
  • [get | view] (2021-02-25 09:44:42, 1.5 KB) [[attachment:selector_plugin.py]]
  • [get | view] (2021-02-25 09:44:42, 1.3 KB) [[attachment:selector_plugin.pyc]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.