These are chat archives for spyder-ide/public

18th
May 2019
jproy
@jproy
May 18 13:27

@ccordoba12 Here is a simple turtle script run with Spyder 3.3.4 console, with no error (except that the primitive bye() should shut the turtle window, from the official CPython doc, but does not shut it).

from turtle import *   # Python 3.7.3, Spyder 3.3.4
tracer(False)
for i in range(100):
    forward(10) ; left(11)
tracer(True)
mainloop()     # blocks
print('OK')
bye()

If I run this in the Unix terminal, I get a Terminator error when closing the window, because of bye(). If I suppress bye(), it runs ok in the terminal, but once upon two there is a Terminator error in the Spyder console. How may I write a program running the same in the terminal (or IDLE or Jupyter) and Spyder ? Thanks a lot.

@ccordoba12 I forgot to remind you that I am using a Mac.
oras903
@oras903
May 18 13:42
can spyder use git ? have git plugin ?
jproy
@jproy
May 18 13:58
@ccordoba12 I saw your patch with an exception to capture the Terminator error from bye(), it's OK but should I tell that to my readers to encourage them to use Spyder ?
@ccordoba12 @CAM-Gerlach May I suggest that you clean completely the OS dependency of Spyder (Linux, Mac, Windows) and have deep tests of compatibility before bringing the same problems (maybe amplified) to the version 4 ? My 2 cents of course, you already do a great job.
jproy
@jproy
May 18 14:04
@ccordoba12 @CAM-Gerlach In the meantime providing an execution in an external Unix terminal on Mac should be acceptable ?
Rohan
@RohanVB
May 18 14:55
@oras903 i found a relevant issue spyder-ide/spyder#816
I was wondering if there is a way to return the current open file in spyder
CAM Gerlach
@CAM-Gerlach
May 18 15:34

should I tell that to my readers to encourage them to use Spyder ?

@jproy Its up to you. Spyder is not explicitly designed to be a replacement for IDLE as a toy IDE designed for teaching and learning Python, though many beginners do find it quite accessible, and its not specifically intended for developing GUI applications, though some users do such quite successfully (to note, Spyder itself is primary developed using Spyder). However, if your book or its audience is oriented toward scientists, data analysis, statistics or engineering, then Spyder would be a very good tool to recommend, since its explictly designed for that and the closest equivalent of Matlab or Rstudio in the Python world.

May I suggest that you clean completely the OS dependency of Spyder (Linux, Mac, Windows)

Sorry, but completely eliminating every single OS-specific differences isn't a very practicable request. We work to eliminate it as much as possible, but most of the remaining per-OS difficulties are either underlying constraints of the OS/third party dependency stack, or typically Mac-specific bugs that are difficult or impossible to fix without having a developer on the Mac platform (which we haven't had until very recently). To address the latter, we have recruited several Mac developers and are considering additional steps to help fix most of the existing known issues on the Mac platform.

have deep tests of compatibility before bringing the same problems (maybe amplified) to the version 4

Which problems, specifically, that aren't already recorded in our bug tracker? If they aren't documented in our bug tracker, then we can't know to fix them. Furthermore, whenever we fix a bug, we add one or more regression tests, that run across our CI servers on all three platforms, to ensure it doesn't happen again.

In the meantime providing an execution in an external Unix terminal on Mac should be acceptable ?

Would you like to work on this? It should be pretty straightforward if you have a Mac to test it on. You would just need to add something like subprocess.call(['open', '-W', '-a', 'Terminal.app', 'python', '--args', SCRIPT_NAME]) as discussed on [this SO answer](https://stackoverflow.com/questions/19308415/execute-terminal-command-from-python-in-new-terminal-window) to [this line](https://github.com/spyder-ide/spyder/blob/master/spyder/utils/programs.py#L344) under anelif sys.platform == 'darwin':`` block and make any nessesary tweaks to ensure it works.

can spyder use git ? have git plugin ?

@oras903 Currently, we offer the ability to commit single or selected files, and open the Git GUI at any given location in the filesystem for more complex actions. We also have a feature in work for Spyder 4 that will color code files by their version control status (unchanged, untracked, ignored, modified, added, deleted, merged, etc). We had a Google Summer of Code project planned for this summer that would add full Git integration and advanced features using Git-Cola and qGit, but unfortunately due to last-minute logistical issues we had to pull out. However, we hope to get that funded again in the future, if a volunteer developer isn't able to step up.

CAM Gerlach
@CAM-Gerlach
May 18 15:48

I was wondering if there is a way to return the current open file in spyder

In the Internal Console (i.e. top level in the application), you get get the current filename in EditorStack n (i.e. split pane) with spy.window.editor.editorstacks[n].get_current_finfo().filename; you can get other properties via other attributes of the finfo object (use dir to see). Therefore, if you have a reference to the editor, you can proceed from there to do the same elsewhere. In general, you can usually figure this stuff out using the Internal Console, spy.window and __dir__(), if not by looking through the codebase.

@RohanVB
Rohan
@RohanVB
May 18 16:06
Thanks a bunch
jproy
@jproy
May 18 17:01
@CAM-Gerlach Thanks for your answer, I am sure you will do your best. I think that even if Spyder is data science oriented, it should be "complete" with respect to the python norm, so any data scientist (like a friend who is physicist) wants to develop a GUI to interface a database with tkinter, he should be able to do so, ans he is on Mac too. As for the patch you suggest, please send it to one of your Mac dev as I must send my book within 10 days and I am rewriting small parts of the book because of this kind of problems. Thanks.
CAM Gerlach
@CAM-Gerlach
May 18 18:49

Good luck on your book!

I think that even if Spyder is data science oriented, it should be "complete" with respect to the python norm

Actually, Tk itself is not part of Python, is developed by ActiveState, not the core CPython team, and is not available on all Python platforms or nor distributions to begin with. Furthermore, much of this involves Spyder's dependencies rather than Spyder itself. That said, it seems we've fixed most of the primary issues with it that we can, and many of the remainder appear to be limitations of how some of our core dependencies work. If you can repro a problem that is not currently documented on our bug tracker, or can provide further information about one that is, we would be happy to have you file it, so long as it manifests itself when running your program via Spyder's IPython Console but not when running the same via a Jupyter QtConsole instance.

so any data scientist (like a friend who is physicist) wants to develop a GUI to interface a database with tkinter,

Is there currently some bug that would prevent this without an easy workaround, that occurs in Spyder but not Jupyter QtConsole and is not currently documented on our bug tracker? If so, please file it. Also, in the meantime, your friend can always work on his code within Spyder, and then just run it externally when he wants to test or use the main GUI mainloop (that's how we develop Spyder itself; we can sometimes launch individual widgets within Spyder but for testing the full program, we just run it properly in the normal fashion).

As for the patch you suggest, please send it to one of your Mac dev as I must send my book within 10 days and I am rewriting small parts of the book because of this kind of problems.

We're all volunteers other than for specific projects we're funded for (and I'm one of the newer of the bunch). I understand you have a deadline, but if it takes more than a few minutes to re-write those sections maybe you could instead consider using that time to implement and testing the suggested patch to fix the problem (there are already tests for this functionality, you just need to unskip them on macOS)? I would be happy to guide you through it; I'd do it myself if I had a Mac. Alternatively, you could kindly ask one of our Mac-using core devs, like @goanpeca or @juanis2112 , if they have free time to implement it, although right now with Spyder 4 Beta 2 about to be released they might be busy.

jproy
@jproy
May 18 20:22
@CAM-Gerlach I tried to patch my programs.pyfor Python 3.7.3 with 'open' (and runinstead of call) without success. I tried also the appscript module with :

sorry, with ideas from Applescript in Python (Mac only) :

import appscript
TERM = appscript.app('Terminal')
TERM.do_script('python foo.py')

Those 3 lines work from Spyder and open a new terminal window and execute foo.py in that terminal window, but I couldn't get some more interesting thing (too much work for now)... Can it help ?