~ubuntu-branches/ubuntu/utopic/dogtail/utopic

« back to all changes in this revision

Viewing changes to dogtail/apps/wrappers/gcalctool.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-12-21 13:33:47 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20061221133347-xo9jg11afp5plcka
Tags: upstream-0.6.1
ImportĀ upstreamĀ versionĀ 0.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import dogtail.tree
2
 
 
3
 
class GCalcTool(dogtail.tree.Application):
4
 
        def clickNumeral(self, num):
5
 
                self.button('Numeric %s'%num).click()   
6
 
        
7
 
        def typeNumber(self, num, base):
8
 
                digits = []
9
 
                while num>0:
10
 
                        digit = num%base
11
 
                        digits.insert(0, digit)
12
 
                        num = num/base
13
 
                if len(digits)==0:
14
 
                        digits=[0]
15
 
                # print digits
16
 
                for digit in digits:
17
 
                        self.clickNumeral(digit)
18
 
                
19
 
        def clearEntry(self):
20
 
                self.button('Clear entry').click()
21
 
 
22
 
        def doBinaryInfixOp(self, a, b, button):
23
 
                self.clearEntry()
24
 
                self.typeNumber(a, 10)
25
 
                self.button(button).click()
26
 
                self.typeNumber(b, 10)
27
 
                self.button('Calculate result').click()
28
 
                return self.getText()
29
 
 
30
 
        def doSum(self, a, b):
31
 
                return self.doBinaryInfixOp(a, b, 'Add')
32
 
 
33
 
        def doProduct(self, a, b):
34
 
                return self.doBinaryInfixOp(a, b, 'Multiply')
35
 
                
36
 
        def getText(self):
37
 
                return self.child(roleName='edit bar').text