sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #42456
Re: [Question #631887]: GET VALUE FROM SWING GUI
Question #631887 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/631887
Status: Open => Answered
RaiMan proposed the following answer:
try this:
from javax.swing import (JButton, JFrame, JPanel, JCheckBox, JLabel, BoxLayout,WindowConstants)
from java.awt import BorderLayout
myval = -1
checkbox1 = None
frame = None
def tally(event):
global myval
if checkbox1.isSelected():
myval = 2
else:
myval = 3
frame.setVisible(False)
def gui():
global frame
global checkbox1, checkbox2
frame = JFrame('Test!', size = (300, 300))
frame.setUndecorated(True)
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.setVisible(True)
gui()
while myval < 0:
wait(1)
print myval
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.