How to call a class method in Sikuli?

Asked by MPE on 2018-03-25

I have been using Sikuli for about two years now, and I really think it is a Godsend (if you believe in that kind of thing). In some parts of my job I need to process large sets of data into a web application and I am using Sikuli to do that for me. I have familiarized myself with the concept of loops variables, functions and importing other Sikuli scripts, and now I feel comfortable enough to take what is in my mind the next step.

So now, I am trying to get the concept of classes to work in Sikuli but when I use the snippet of code I placed underneath nothing happens. I am using a simple text editor to try to get Sikuli to type the text and hit Enter.

class Test:
    def Type(self):
        type('this is just a silly example')
        type(Key.ENTER)
        wait(0.1)

Example = Test()

for step in range (5):
    Example.Type

I can easily get this to work when not placing the function within a class.I did search for other answers en checked the manual at 'read the docs' but I couldn't find a satisfying answer.

Should you have any questions, feel free to ask.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
MPE
Solved:
2018-03-25
Last query:
2018-03-25
Last reply:
MPE (maartenpelgrim) said : #1

Okay, now I feel like a complet moron. I've found the answer, and it turned out to be quite simple. After reading chapter six (object oriented jython) of the Jython documentation I noticed that I had not placed parentheses after 'Example.Type'. After that, the test worked immediately.

MPE (maartenpelgrim) said : #2

Okay, now I feel like a complet moron. I've found the answer, and it turned out to be quite simple. After reading chapter six (object oriented jython) of the Jython documentation I noticed that I had not placed parentheses after 'Example.Type'. After that, the test worked immediately.