raw_input() for Processing.py (how to get/use)

edited March 2016 in Python Mode

Hello, I have been working in python, and love the fact that I can use the processing IDE, setup, and awesome visually Processing features. However, one of the most useful and basic features is missing. text = raw_input("Enter some text: ")

You get; IOError: The handle is invalid

Enter some text: processing.app.SketchException: IOError: The handle is invalid at jycessing.mode.run.SketchRunner.convertPythonSketchError(SketchRunner.java:243) at jycessing.mode.run.SketchRunner.access$4(SketchRunner.java:222) at jycessing.mode.run.SketchRunner$3.run(SketchRunner.java:117) at java.lang.Thread.run(Unknown Source)

I would appreciate a work around or way that brings up a command line window.

Thank you very much!

Tagged:

Answers

  • Dunno about Python and its Python Mode much... But Java has a class called Scanner:
    http://docs.Oracle.com/javase/8/docs/api/java/util/Scanner.html

    It can be used to get input from the console.
    Even though it doesn't throw any Exception, nothing happens while using Processing's PDE.
    But once exported and run from the command line, it magically works! :bz

    Who knows it's the same issue w/ Python's raw_input()? :-/

  • The processing sketch does not run in a real console; this technique will not work in the PDE.

    It may work fine using the processing.py command line, but I'm not sure.

  • edited March 2018

    I'm not sure this helps but here I go:

    How about a nasty swing InputDialog?

    def input(message=''):
        from javax.swing import JOptionPane
        return JOptionPane.showInputDialog(frame, message)
    
  • edited March 2018 Answer ✓

    Cancel button will make it return None

    def setup():
        answer = input('enter your name')
        if answer:
            println('hi ' + answer)
        elif answer == '':
            println('[empty string]')
        else:
            println(answer) # Canceled dialog will print None
    
    def input(message=''):
        from javax.swing import JOptionPane
        return JOptionPane.showInputDialog(frame, message)
    
  • July 2015...

Sign In or Register to comment.