sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #22697
Re: [Question #240592]: [request] Input text field or input field that maintains formatting
Question #240592 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/240592
RaiMan proposed the following answer:
this is a somewhat enhanced version:
def myInput(title, width = 10, lines = 5):
import javax.swing.JTextArea as JTextArea
import javax.swing.JPanel as JPanel
import java.awt.Dimension as Dimension
import javax.swing.JOptionPane as JOptionPane
import javax.swing.BorderFactory as BF
import java.awt.Color as COLOR
textH = 16
textW = 10
inner = 5
ta = JTextArea("")
ta.setPreferredSize(Dimension(width*textW,lines*textH + inner*2));
b0 = BF.createEmptyBorder(inner, inner, inner, inner)
b1 = BF.createLineBorder(COLOR.BLACK)
ta.setBorder(BF.createCompoundBorder(b1, b0))
myPanel = JPanel();
myPanel.add(ta);
if 0 == JOptionPane.showConfirmDialog(None, myPanel, title, JOptionPane.OK_CANCEL_OPTION):
return ta.getText()
else:
return ""
given = myInput("gimmi some text")
if given != "":
print given
else:
print "no input"
The text area now has a simple border.
You may specify the number of characters (width = 10 default) per line and the number of lines (lines = 5 default) (this is based on the assumption, that a character is 10x16 Pixel.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.