← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #240592]: Input text field or input field that maintains formatting

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Sorry, not with the current features on the script level.

But since we run on Java, you might try this (tested and works):
# make your own input function
def myInput(title):
    import javax.swing.JTextArea as JTextArea
    import javax.swing.JPanel as JPanel
    import java.awt.Dimension as Dimension
    import javax.swing.JOptionPane as JOptionPane
    
    ta = JTextArea("")
    ta.setPreferredSize(Dimension(50,50));
    myPanel = JPanel();
    myPanel.add(ta);
    
    if 0 == JOptionPane.showConfirmDialog(None, myPanel, title, JOptionPane.OK_CANCEL_OPTION):
        return ta.getText()
    else:
        return ""

# and use it like this
given = myInput("gimmi some text")
if given != "":
    print given
else:
    print "no input"

With Dimension(50,50) you set the size of the displayed text area (which may take content of any size).
This is a quick and dirty solution and might be beautified at your needs.

I will add an inputText() function to the scripting API.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.