open a SWING GUI by running a Sikuli script

Asked by RayanRoger

Hi,

I'm using the last sikuli version (1.0.0 - May 2013) running on a Windows7 - 64 bit with Java jre-7u21-windows-x64.

I'm trying to run a sikuli script by using the command line :
"%SIKULI%"\sikuli-script.cmd -r Myscript.sikuli

Where Myscript.sikuli contains :

from javax.swing import JFrame # The JFrame is a top-level window with a title and a border

class Example(JFrame):
    def __init__(self):
   super(Example, self).__init__()
   self.initUI()

    def initUI(self):
   self.setTitle("Simple")
   self.setSize(300, 200)
   self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
   self.setLocationRelativeTo(None)
   self.setVisible(True)

if __name__ == '__main__':
  Example()

The problem is that no GUI appears on the screen and there's no message on the standard output :
[info] Exit code: 0

that's all...

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

LOL, that is nice ;-)

It does what you expect, but you cannot see it, because the script ends in the moment after

self.setVisible(True)

Nothing tells the script to wait.

e.g. this:

if __name__ == '__main__':
  Example()
  popup("can you seee me?")

might help.

Revision history for this message
RayanRoger (rayanroger2) said :
#2

Thanks RaiMan, that solved my question.