In this entry I will show you how to open a file via Geany text-editor (or any other program) by using Python dialog function. I intend to keep things short and simple and explain majority of things with pictures.
On the above image you see that we execute the python file by writing ./set.py to terminal. We could also write python set.py and the file would still open. Do remember however that before you open a python file you need to make the file executable. You do this by writing chmod +x set.py when you are within a terminal client and under the directory where you python file (set.py, in this case) is located.
Once you select your file the above result should emerge. However, if you select nothing and press Cancel button instead you will get something like.
You can use the dialog example provided within the zip file below as part of your own trials with python. Remember to make the file executable before trying. to run it. If geany is not your program of choice change the line: subprocess.Popen([‘geany’, filename]) to be something else like: subprocess.Popen([‘vlc’, filename]) . Do remember to quit and restart your program when making changes.