MathInspector / MathInspector

A visual programing environment for scientific computing with python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

View source button doesn't work on linux

EtienneDesticourt opened this issue · comments

Hi,

This line is the culprit:

command = "start " + file

There is no start command to my knowledge on Linux. I'd suggest checking the $EDITOR environment variable instead.

Cheers

Screen Shot 2021-02-23 at 10 24 40 PM

I think this should do it, have not had a chance to test on linux yet tho. (the dev branch on my local has fixes for almost all the things we discussed today btw)

The previous solution had a bug, but it has been fixed now and I tested this on linux

    elif platform.system() == "Linux":
        editor = os.environ["EDITOR"] if "EDITOR" in os.environ else "vi"
        command = editor + " " + file

I was wondering about using & to launch vi in the background. It was causing some strange issue. e.g.

os.system("vi file.py &")

do you know if i was doing that wrong, or is there a better way to run vi in the background? Otherwise it makes the entire app freeze up, which is not how it works on mac/windows.

Use the subprocess module and start the process so python doesn't wait for it to exit. Also ideally it'd be good to test if $EDITOR is set and popup an error or something if it isn't.

Also ideally it'd be good to test if $EDITOR is set and popup an error or something if it isn't.

I have it doing this at the moment, but error popup is probably better

editor = os.environ["EDITOR"] if "EDITOR" in os.environ else "vi"

I think git does it your way so it's probably a good way and pretty hassle free

The positive aspect of showing an error message is it encourages best practices to the user. This kind of goal for a UI design pattern is something I haven't thought much about before now.

If setting $EDITOR is something that you don't want to do, you don't have to. If the reason you don't want to do it is you don't know how, then this is a gentle way of suggesting to the user they really should take the time to find out how to do it.