2

I have written a python script, made it executable and pasted it in

~/.local/share/nautilus/scripts

The problem is that my script needs some user inputs and while it does that, nautilus generates error saying

Enter your username: Traceback (most recent call last):
  File "/home/sumit/.local/share/nautilus/scripts/sms.py", line 30, in <module>
    username = input("Enter your username: ")
EOFError: EOF when reading a line

However the script works fine when I assign the variables in the program itself (without any user input).

How to make the script run for user inputs as well ?

pdm
  • 2,248
  • 16
  • 23
Sumit Jha
  • 1,837
  • 1
  • 17
  • 30
  • Maybe [this](http://stackoverflow.com/questions/12547683/python-3-eof-when-reading-a-line-sublime-text-2-is-angry) helps – GAVD Feb 29 '16 at 05:37

1 Answers1

2

Use zenity to get interactive user input (read more)

#!/usr/bin/env python

import subprocess

def get_interactive_input(title, text):
    try:
        result =  subprocess.check_output(['zenity','--entry','--title={}'.format(title),'--text={}'.format(text)])
        return result.strip()
    except subprocess.CalledProcessError as e:
        return None


def main():
    print get_interactive_input('asd', 'asdasd asdasd asdasdasd')


main()

enter image description here

Jossef Harush
  • 24,765
  • 7
  • 95
  • 103