← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #631887]: GET VALUE FROM SWING GUI

 

Question #631887 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/631887

Description changed to:
Hi. I can't get value from swing simple gui to the rest script
I think it must be in a different thread but I can't find any working example
Can you show me a working example??
*im running throw command line the script

My simple code is this:

from javax.swing import (JButton, JFrame, JPanel, JCheckBox, JLabel, BoxLayout,WindowConstants)
from java.awt import BorderLayout
myval = 0
#---------------------------------------------------------------
class Mytest():
	def tally(event):
		global myval
		if checkbox1.isSelected():
			myval = 2
		else:
			myval = 3			
		frame.visible = False
#---------------------------------------------------------------
	frame = JFrame('Test!', defaultCloseOperation = JFrame.EXIT_ON_CLOSE,size = (300, 300))
	selectionPanel = JPanel()
	selectionPanel.layout=BoxLayout(selectionPanel, BoxLayout.Y_AXIS)
	frame.add(selectionPanel)
#---------------------------------------------------------------
	text = JLabel('---------------------------------------------')
	selectionPanel.add(text)
	text = JLabel('hello there')
	selectionPanel.add(text)
	checkbox1 = JCheckBox('2', selected = False)
	selectionPanel.add(checkbox1)
	checkbox2 = JCheckBox('3', selected = False)
	selectionPanel.add(checkbox2)
#---------------------------------------------------------------
	buttonPanel = JPanel()
	frame.add(buttonPanel, BorderLayout.SOUTH)
	button = JButton('ok', actionPerformed = tally)
	buttonPanel.add(button)
	frame.visible = True
print myval

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.