Attachment 'gcalc.py'

Download

   1 #!/usr/bin/env python
   2 
   3 from simple_at import *
   4 from pyatspi import StateSet
   5 
   6 def run(acc):
   7   print "[start]"
   8 
   9   col = acc.queryInterface('IDL:Accessibility/Collection:1.0')
  10   if col is None:
  11     raise NotImplementedError('%s does not implement collection' % acc.name)
  12 
  13   print "[Collection]"
  14   
  15   roles = [Accessibility.ROLE_PUSH_BUTTON]
  16   states = StateSet()
  17   
  18   states.add(Accessibility.STATE_SHOWING)
  19 
  20   print states.isEmpty()
  21   print "Roles to match:", roles  
  22   print "States to match:", states.raw().getStates()
  23   
  24   rule = col.createMatchRule(states.raw(), col.MATCH_ALL,  
  25                              "", col.MATCH_ALL,
  26                              roles, col.MATCH_ANY,
  27                              "", col.MATCH_ALL,
  28                              False)
  29 
  30   print "[getMatches]"
  31 
  32   sort =  col.SORT_ORDER_CANONICAL
  33   #sort =  col.SORT_ORDER_REVERSE_CANONICAL
  34   
  35   ls = col.getMatches (rule, sort, 0)
  36 
  37   print "all buttons shown on screen"
  38   
  39   for n in ls: 
  40     print n.name
  41 
  42   print "return only the first 5 buttons shown on screen"
  43 
  44   lsn = col.getMatches (rule, sort, 10) #only 5 matches
  45 
  46   for n in lsn: 
  47     print n.name
  48   
  49 #  col.freeMatchRule (rule)
  50 
  51   obj = lsn[9] # try to search starting from this object
  52 
  53   print "use this object as reference for getMatches[From/To]", obj
  54 
  55   print "[getMatchesFrom]"
  56 
  57 #  rsort =  col.SORT_ORDER_REVERSE_CANONICAL
  58 
  59   lsf = col.getMatchesFrom (obj, rule, sort, False, 0)
  60 
  61 #  print rule, lsf
  62 
  63   for n in lsf: 
  64     print n.name
  65 
  66   print "[getMatchesTo]"
  67 
  68   lst = col.getMatchesTo (obj, rule, sort, True, 0)
  69   for n in lst: 
  70     print n.name
  71 
  72     
  73   return 1
  74 
  75 if __name__ == '__main__':
  76   d = registry.getDesktop(0)
  77   for i in xrange(d.childCount):
  78     try:
  79       c = d.getChildAtIndex(i)
  80     except:
  81       continue
  82     if c is not None and c.name == 'gcalctool':
  83       run(c)
  84 
  85 print "[fin]"

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:41:35, 2.0 KB) [[attachment:button_collection.py]]
  • [get | view] (2021-02-25 09:41:35, 7.0 KB) [[attachment:collection.scm]]
  • [get | view] (2021-02-25 09:41:35, 2.7 KB) [[attachment:firefox.py]]
  • [get | view] (2021-02-25 09:41:35, 1.8 KB) [[attachment:gcalc.py]]
  • [get | view] (2021-02-25 09:41:35, 6.0 KB) [[attachment:match-rule-test.scm]]
  • [get | view] (2021-02-25 09:41:35, 0.6 KB) [[attachment:simple_at.py]]
  • [get | view] (2021-02-25 09:41:35, 0.6 KB) [[attachment:simple_at.pyc]]
 All files | Selected Files: delete move to page copy to page

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