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 ?

1
  • Maybe this helps Commented Feb 29, 2016 at 5:37

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.