Processing.py-Bugs icon indicating copy to clipboard operation
Processing.py-Bugs copied to clipboard

Including input function and some imports from __future__

Open TobiasBaeumlin opened this issue 5 years ago • 2 comments

As I am using processing.py to teach an introductory course to computer science I'd be interested to have an input function:

def input(message=''):
    from javax.swing import JOptionPane
    return JOptionPane.showInputDialog(frame, message)

from a solution mentioned in an answer to another request.

Additionally I need some imports from future, namely division, print_function and unicode_literals.

For the time being I managed to do that by patching some files in modes/PythonMode.jar.

Would it be possible to add these changes in the officially distributed version of the Python mode?

Regards Tobias

TobiasBaeumlin avatar Jan 27 '20 12:01 TobiasBaeumlin

Why can you not use that input function? It works fine for me.

What files did you patch?

jdf avatar Jan 27 '20 15:01 jdf

Yes, I can use the function above. But for use in a class room I'd like to hide it from the students and have it transparently available.

I patched jycessing/core.py in PythonMode/mode/PythonMode.jar:

  • Added at top of file from future import division, unicode_literals

  • Added at bottom of file: def input(message=''): from javax.swing import JOptionPane return JOptionPane.showInputDialog(frame, message) builtin.input = input

Would it be possible to add something along these lines in the distribution of PythonMode?

arbuscula avatar Jan 27 '21 12:01 arbuscula