spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.14k stars 1.58k forks source link

Need to press run twice with matplotlib in spyder #1831

Closed spyder-bot closed 7 years ago

spyder-bot commented 9 years ago

From markfran...@gmail.com on 2014-05-26T19:10:46Z

Spyder Version: 2.3.0beta2 Python Version: 3.3.5 Qt Version : 4.8.4, PyQt4 (API v2) 4.9.6 on Windows pyflakes >=0.6.0: None (OK) pep8 >=0.6 : None (NOK) IPython >=0.13 : 2.0.0 (OK) rope >=0.9.2 : 0.9.4 (OK) sphinx >=0.6.6 : 1.2.2 (OK) matplotlib >=1.0: 1.3.1 (OK) sympy >=0.7.0 : 0.7.5 (OK) pylint >=0.25 : 1.1.0 (OK)

What steps will reproduce the problem?

  1. Open a script with a matplotlib figure. For example one from the matplotlib site. http://matplotlib.org/mpl_examples/pylab_examples/figure_title.py 2. Press run or F5. It runs normally.
    1. Press run or F5 a second time and the script doesn't run
    2. Press run or F5 a third time then the script runs

What is the expected output? What do you see instead?

When you try to run a script with matplotlib you press run and it works normally the first time. Press run again and the script doesn't run. You have to hit run a second time in order for the script to run

Spyder is in "Execute in current python or ipython interpreter" mode

In the console it looks like this (i removed the file paths to make it shorter). F5 puts the runfile in. The second time you try to run it, when you click F5 or the green run arrow twice you runfile goes into the console twice before it runs.

">>> runfile('C:/.../figure_title.py', wdir=r'C:/...')

runfile('C:/.../figure_title.py', wdir=r'C:/...') runfile('C:/.../figure_title.py', wdir=r'C:/...') "

Please provide any additional information below

. I thought it was a problem with my own script, but the problem repeats even with code from the matplotlib website.

I only have this problem when I have a script with matplotlib. For example, when I run a simple script like below I can run it over and over no problem. I never have to press F5 twice.

x = int(input("enter an number: "))

if x < 0: x = 0 print('Negative') elif x > 0: print('Positive') elif x == 0: print('Zero')

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1831

spyder-bot commented 9 years ago

From contrebasse on 2014-05-27T00:28:48Z

Are you in interactive mode or do you call show() at the end of your script ? The show() call is blocking and it could explain why the script doesn't run the second time. However it doesn't explain why it would run fine the third time...

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-05-28T05:15:05Z

I have the same problem after installing Spyder 2.3.0rc, with the same configuration as markfran. I note however that the problem is present when pressing F5 from a Python console, but not from an IPython one.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-02T07:31:12Z

Changing interactive mode with plt.ion() or plt.ioff() does not affect this bug.

I typically use interactive mode and my procedures show plots without using the plt.show() command. But if I call plt.ioff() before calling my matplotlib procedure, the "press-run-twice" bug appears even if my procedure did not actually show any plot.

In summary, as long as I first call from the Python console a procedure which uses a matplotlib function, I need to press run twice to run any subsequent procedure.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-22T20:57:01Z

I can't reproduce this in Python 2. Maybe it's an error with Python 3 and Matplotlib, I'm going to check it out.

Summary: Need to press run twice with matplotlib in spyder (was: need to press run twice with matplotlib in spyder)

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-22T22:38:09Z

I have two questions for you (just out of curiousity):

  1. How did you install Matplotlib?
  2. Are you using WinPython or Anaconda?
spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-23T04:24:03Z

I tried two different distributions:

  1. I uninstalled Spyder from WinPython 3.3.5 64bit and replaced it with Spyder 2.3.0rc
  2. I used the latest Anaconda distribution with Python 3.4 64bit, which comes with Spyder 2.3.0rc

The above bug behaves in the same way in both distributions.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-23T13:15:02Z

No luck at reproducing this one for me after several hours of work :) I installed the latest Anaconda for 32bit and everything is working as expected (I don't have Win64 to test on).

I was also unable to verify issue #1837 and issue #1861 , so I don't see any of them as showstoppers for 2.3, sorry.

Maybe you would be better by using IPython instead of plain Python, because IPython guys have worked really hard to smooth all interactions with Matplotlib.

@-Sylvain, if you have some free time and access to Win64, could test it just to be sure?

Cc: sylvain....@gmail.com

spyder-bot commented 9 years ago

From sylvain....@gmail.com on 2014-06-23T13:36:09Z

Ok I can look into it tonight. I have a win64 at hand. S.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-23T15:41:09Z

@-ccordoba12 thank you very much for looking into this, and in general for your great work on improving spyder. I love it!

My main reason for not using an IPython console with spyder is the lack of a history buffer during debugging. The history only works for me during debugging in the normal Python Console. I am not sure this is intended/expected, or I am doing something wrong...

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-23T15:53:04Z

I understand your point about IPython. That's a technical limitation on its side, so (unfortunately) we can't do anything about it.

You could also try to test your issues in another machine, just to be sure if they are related to Win64 or to your particular setup.

spyder-bot commented 9 years ago

From sylvain....@gmail.com on 2014-06-23T16:40:11Z

Hi, I don't reproduce the described behavior with the current tip of the default branch, with Win7 64bits. Local version of PyQt is 4.10.4.

A problem that I have experienced with windows in general is that the matplotlib window is created and remains hidden behind the Spyder window.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-24T04:29:29Z

Yes, that's a terrible nuisance that hopefully one day mpl devs fix :)

Thanks for your help Sylvain.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-24T13:39:59Z

@-Sylvain just to be sure, did you try to reproduce this bug on Python 3.3 on Windows?

I only have this bug with Python 3.3, but the same Spyder 2.3.0rc work well for me with Python 2.7.

spyder-bot commented 9 years ago

From sylvain....@gmail.com on 2014-06-24T14:36:14Z

Indeed it seems to be a Python 3 specific thing. I will need to test it in a different environment. (Besides, the booststrap script does not seem to work with Python 3) Sylvain

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-24T15:23:12Z

I also had problems using the booststrap.py script with Python 3. It failed to start. I wanted to be sure I could reproduce the bug with the latest Spyder version.

After deleting "C:\Users\myname.spyder2-py3" a few times, Spyder eventually started and gave me the same bug as with the officially released and normally installed 2.3.0rc version.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-26T03:16:32Z

@ccordoba12 and @-Sylvain I noted that issue #1810 is also the same as this issue #1831 . So it appears this bug was confirmed by at least three different people on different computer and configurations.

It appears to be there since Spyder 2.3.0beta2. In all cases the bug appears only under Python 3, whose support is one of the highlights of Spyder 2.3. The bug, with the related issue #1837 and issue #1861 makes the Python Console essentially unusable under Python 3.

These issues force one to use IPython for debugging in Spyder, which implies one has to loose the command history.

I would vote for raising the priority of this related series of issues, if Spyder 2.3 intends to support Python 3.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-27T04:48:19Z

I did an additional test, which may help locate the source of the problems.

I just downloaded the latest Spyder version from the repository and I used bootstrap.py to start it under Python 2.7.6 (WinPython 64bit).

I then went to Preferences/Console/Advanced_settings/Python_Executable and at the section "Use the following Python interpreter" I selected Python 3.3.5.

I can confirm that issue #1810 , issue #1831 , issue #1837 and issue #1861 all still apply when I run, compile or debug programs on a Python 3 console, even when running Spyder under Python 2. Hopefully this test will help with finding a solution.

spyder-bot commented 9 years ago

From sylvain....@gmail.com on 2014-06-27T06:18:47Z

@-divenex, thank you for investigating this further. I will look further into it tonight.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-27T10:13:36Z

issue #1810 has been merged into this issue.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-27T10:24:59Z

A couple of comments:

  1. @-divenex: We can't raise the priority of these issues (and so block the final release) if we are unable to reproduce them. As I said, I spent like 5 hours last weekend trying to do it and was unable to. Besides using Anaconda, I installed Python 3.3 from python.org, PyQt, numpy and matplotlib from their official installers and no luck at all. So what else can we do?
  2. @-Sylvain: Please let me know what's the problem with bootstrap.py and Python 3. I'm not seeing problems on Windows or Linux.
spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-27T10:42:58Z

@-ccordoba12 thanks a lot for the tests.

I really hoped you could reproduce it, as I can't make it go away no matter what I try, on the two Windows (7 and 8) 64bit computers and two distributions (WinPython and Anaconda) I have tried. And two other users reported it...

But of course I understand that it's impossible for you to fix it without seeing the bug on your machine.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-27T10:59:08Z

Sigh, I'll see if I can borrow a Win64 this weekend. But even if I could confirm it, I think we should release with what we have because this seems pretty subtle and hard to debug, so solving it could take us two weeks or more.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-06-27T22:46:38Z

Just a hunch but could you try to deactivate your firewall/antivirus and run everything again to see what happens?

Maybe they are interfering with the communication between Spyder and the process where code is run (which is external to Spyder so as not blocking the GUI).

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-06-28T05:12:29Z

Thanks for the suggestion. I tried to disable both firewall and antivirus but unfortunately nothing changes. All reported bugs are still here.

As one more test I installed the 32bit version of WinPython 3.3.5.0. I can confirm that the issue #1831 , issue #1837 and issue #1861 are still there also with 32bit Python 3 under Windows.

This is true both when running with boostrap.py the latest Spyder 2.3.0rc version from the repository and when running the Spyder 2.3.0beta2, which comes preinstalled with WinPython 3.3.5.0.

The latter agrees with what originally reported by markfran, who started issue #1831 and with sstef, who opened issue #1810 .

spyder-bot commented 9 years ago

From ccordoba12 on 2014-07-06T06:16:48Z

Ok, that's progress! At least you narrowed down the problem to Windows 8. Unfortunately I don't have access to a Win 8 machine, so someone else will have to help us here.

Labels: OpSys-Windows

spyder-bot commented 9 years ago

From ccordoba12 on 2014-07-06T09:56:51Z

It seems you found the solution being some issue with WinPython. If that's the case then we could close these issues and you could move the discussion to WinPython bug tracker.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-07-06T10:19:35Z

I made a clean install of Windows 8.1 64bit in a virtual machine. I did not install anything except for Anaconda 2.01 64bit version with Python 3.4, which includes Spyder 2.3.0rc.

Unfortunately I have to confirm that issue #1831 , issue #1837 and issue #1861 are still there with a completely clean and standard configuration of Windows 8.

(@ccordoba12 apologies for my too quick and incorrect report that the problem may have been solved.)

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-07-06T10:40:46Z

As additional info: with a fresh install of Windows 8.1 and Anaconda3, the first time I run a matplotlib script, it run correctly every time I press F5 as it should. This made me think the bug was finally gone!

But as soon as I created other scripts and started to switch from one to the other, I realized that issue #1831 , issue #1837 and issue #1861 were still there.

spyder-bot commented 9 years ago

From jason.bo...@gmail.com on 2014-07-07T05:57:33Z

I experience this issue as well. I am running Win7 64bit and am running Spyder from WinPython 3.3.5. Based on the comments for this issue, and mine and my colleages experience, this seems to be something specific to the Python 3.x version of WinPython.

Here's an example of my console output (the runfile line must come from pressing the Run file button, otherwise the error does not occur):

print('test') test runfile('C:/path/to/file.py', wdir=r'C:/path/to')

UMD has deleted: rosapreaders, helpers, plot_fft

test

print('test')

test

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-07-07T07:34:06Z

@-Jason thanks for reporting this. It's very useful to know it also happens on Win7 to you and your colleagues, and not just on Win8.

I agree this is specific to Python 3, but note that this is not specific to WinPython, as I also have the same problems with Anaconda3.

I plan to test it on a clean install of Win7+Anaconda, as I did with Win8, to see if it also happens there. I am trying to nail down the conditions in which this series of bugs happens, hoping to help the developers in reproducing/fixing this.

I love Spyder, but with this issue I can't consider it yet a viable alternative for Python 3, which is where I hope the community is finally leading...

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-07-08T08:20:44Z

I made a clean install of Windows 7 64bit in a virtual machine. I did not install anything else except for (i) Anaconda3 2.01 64bit version with Python 3.4, which includes Spyder 2.3.0rc; (ii) WinPython 3.3.5, which includes Spyder 2.3.0beta2.

I confirm that all issue #1810 , issue #1831 , issue #1837 and issue #1861 still apply to the most popular completely clean and standard configuration of Windows. The same applies, as I reported in my earlier comment, with a clean install of Winodws 8.1 64bit.

I give below some detailed examples under Windows 7 and Anaconda3, but the same happens under Windows 8 and/or WinPython.


As an example of issue #1831 ---------------------------

Given the following trivial script temp1.py:

import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(5))
print("first script")

If I start a new Python console and press F5 three times I get the following output on the console:

Python 3.4.1 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 17:27:11) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
\>>> runfile('C:/dir/temp1.py', wdir=r'C:/dir')
first script
\>>> runfile('C:/dir/temp1.py', wdir=r'C:/dir')
runfile('C:/dir/temp1.py', wdir=r'C:/dir')
first script
\>>> 

Note that the application runs correctly the first time, but required two F5 the second time as originally reported for issue #1831 .


As an example of issue #1861 ---------------------------

If I now open a second similar script temp2.py

import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(5))
print("second script")

And press F5 four times I get the following output:

\>>> runfile('C:/dir/temp2.py', wdir=r'C:/dir')
runfile('C:/dir/temp2.py', wdir=r'C:/dir')
first script
\>>> runfile('C:/dir/temp2.py', wdir=r'C:/dir')
runfile('C:/dir/temp2.py', wdir=r'C:/dir')
second script
\>>> 

Note that only after pressing F5 four times temp2.py finally runs. The first two F5 presses only execute the previously active script temp1.py, even tough the console writes runfile(...temp2.py...)


As an example of issue #1837 ---------------------------

An even more serious problem is the fact that if I place a breakpoint on the third line of the temp1.py and press Ctrl+F5 to "debug file" I get the following output. Note that the console gives no prompt, contrary to what it should.

\>>> debugfile('C:/dir/temp1.py', wdir=r'C:/dir')

When I press Ctrl+F12 to "continue execution until the next breakpoint", the execution skips to the end, instead of stopping at the breakpoint

continue
first script
\>>>

BOTTOM LINE

The Python console is basically unusable in Spyder 2.3.0rc, when using Python 3 under Windows 7 or 8. Only the IPython console works there.

Given that all the bugs apply with clean install of the operating systems, many users of Python 3 are likely to be affected.

I wish I could help. I am experienced with Python, but I would not know where to start with debugging Spyder... But I hope my tests will make it easy for one of the developers to reproduce the problems. (For info, in my tests I used a free VMware virtual machine and I did not need to activate the operating systems when installing Windows 7/8, as Windows will work in trial mode for 30 days)

spyder-bot commented 9 years ago

From boukek...@gmail.com on 2014-07-22T05:01:19Z

I have the issue of scripts not running on the second F5 as well. Setup: win7 64 bit, installed everything via WinPython.

I noticed that when I type 'runfile([scriptname])' manually, everything works fine. Here is a console session demonstrating the effect (personal info from path removed):

Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Imported NumPy 1.8.1, SciPy 0.13.3, Matplotlib 1.3.1

Traceback (most recent call last): File "_ctypes/callbacks.c", line 260, in 'calling callback function' File "C:\path\to\WinPython\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 295, in qtinputhook QtCore.QCoreApplication.exec() KeyboardInterrupt

Hopefully this is helpful. My workaround now is to restart the python console for every run, but I loose figures then, which is a bit inconvenient.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-07-24T08:08:03Z

Thanks a lot for the additional info @-boukekrom. Could some of you guys go to

Preferences > Console > External modules > Qt (PyQt/PySide)

and deactivate the option called

Install Spyder's input hook for Qt

to see if that helps or fixes your problem?

Cc: -sylvain....@gmail.com

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-07-25T10:39:49Z

@-ccordoba12 thanks for looking into this. Unfortunately what you suggests does not solve the problem.

With the released version of Spyder 2.3 and Python 3.3, if I deactivate the option called "Install Spyder's input hook for Qt" then the procedure runs the very first time I press F5 as before.

However things change afterwards. Now pressing F5 again any number of times does not run the procedure any more, it simply prints on the console and never gives the prompt back:

runfile('C:/dir/temp1.py', wdir=r'C:/dir') runfile('C:/dir/temp1.py', wdir=r'C:/dir') runfile('C:/dir/temp1.py', wdir=r'C:/dir') runfile('C:/dir/temp1.py', wdir=r'C:/dir') runfile('C:/dir/temp1.py', wdir=r'C:/dir') ...

spyder-bot commented 9 years ago

From ccordoba12 on 2014-08-08T04:53:50Z

issue #1925 has been merged into this issue.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-08-08T17:20:28Z

I finally was able to test and confirm this bug (along with the other ones referenced by @-divenex).

The only solution I've found so far is to use a different Matplotlib backend. You can change it in:

Preferences > Console > External modules > Matplotlib

from the default (Qt4Agg) to TkAgg (the only other available on Windows).

Unfortunately this doesn't work for those of you that work with Anaconda. I'll try to fix that for the next Anaconda release.

Status: Accepted

spyder-bot commented 9 years ago

From ccordoba12 on 2014-08-08T17:21:21Z

issue #1837 has been merged into this issue.

spyder-bot commented 9 years ago

From ccordoba12 on 2014-08-08T17:21:53Z

issue #1861 has been merged into this issue.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-08-11T04:12:06Z

@-ccordoba12 great you were able to confirm this! I really miss the Python console in Spyder!

Your solution partially works work me. It solves the reported issues but it produce another one: with the TkAgg backend the graphics window now constantly says "(Not Responding)".

More specifically, when I run the following script

import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(5))
print("first script")

the procedure does run correctly every time I press F5, and debugging also works. However no plot appears on the screen, until I type something like "plt.pause(99)".

Moreover the Tk window is constantly unresponsive so I cannot easily bring it to the foreground, unless I again type "plt.pause(99)".

In summary the Tk windows behaves exactly in the same way as it does during debugging (see issue #620 ), even when I am not debugging any script.

Is there any configuration that can fix this behaviour (I am using WinPython with Python 3.3.5 and Spyder 2.3.0)?

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-08-11T06:13:19Z

@-ccordoba12 I confirm that using the latest Anaconda one cannot select the TkAgg backend as Spyder gives the following long error message when trying to run e.g. the above temp1.py short script. Note that the Tk graphics windows still says "(Not Responding)" as it does using WinPython (see my previous comment):

Python 3.4.1 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 17:27:11) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

runfile('C:/dir/temp1.py', wdir=r'C:/dir') Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\xxx\Anaconda3\lib\site-packages\matplotlib\backends\tkagg.py", line 13, in blit tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array)) _tkinter.TclError: invalid command name "PyAggImagePhoto"

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\xxx\Anaconda3\lib\tkinterinit.py", line 1487, in call return self.func(*args) File "C:\Users\xxx\Anaconda3\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 276, in resize self.show() File "C:\Users\xxx\Anaconda3\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 349, in draw tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2) File "C:\Users\xxx\Anaconda3\lib\site-packages\matplotlib\backends\tkagg.py", line 20, in blit tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array)) _tkinter.TclError first script

spyder-bot commented 9 years ago

From ccordoba12 on 2014-08-11T15:16:42Z

@-divenex: What happens if you try to use a 32 bits Anaconda installation instead of the 64 one? Does the same behavior still shows?

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-08-12T12:51:22Z

@-ccordoba12 Doing exactly the same on the 32bit version of Anaconda3, Python crashes when I run the temp1.py script: "the program stopped working"

spyder-bot commented 9 years ago

From ccordoba12 on 2014-08-13T10:53:34Z

@-divenex:

  1. AFAICT the error with Anaconda is a bug with their matplotlib build, so it has to be reported with them so they can fix it.
  2. If TkAgg plots are unresponsive (with WinPython, I mean), this means that there's something that is interrupting the communication between the Spyder graphical interface and the external Python process used to run code (which is done via sockets). It could be a firewall, and antivirus or something like that, because I wasn't able to reproduce this problem in another 64 bits Win 7 machine with Anaconda3 and the Qt4Agg backend.

Until we find what's that something and how to avoid the communication issue it's introducing, there is no workaround or configuration change that can be used to change the situation.

  1. I'm sorry to say it but this is way beyond my league in terms of OS (I'm a Linux guy) and expertise (I've worked very little with sockets). So we'll have to wait until Pierre (the Spyder author and Windows expert) comes back and tackles this issue, or other person with similar skills.

Owner: pierre.raybaut
Labels: Cat-Console

spyder-bot commented 9 years ago

From dive...@gmail.com on 2014-08-13T12:10:35Z

@-ccordoba12 thank you for the explanation. Then I really hope Pierre can have a look at this issue and bring the Spyder Python console to the Windows users of Python 3 too.

I really like Spyder and can't work without it. So, since I moved to Python 3, I have been tempted many times to go back to Python 2.7, where Spyder worked well. But I think it's time for the community to start embracing Python 3. For this reason I stick to it and hope someone can figure out how to solve the problems. Unfortunately I cannot be of much help myself with this specific issue...

spyder-bot commented 9 years ago

From lyh27557...@gmail.com on 2014-08-15T00:16:39Z

I came across the same problem with @-divenex, and this drives me mad. Hope Pierre fix it.

spyder-bot commented 9 years ago

From dpe...@gmail.com on 2014-11-05T10:47:23Z

Hi All,

I have installed WinPython-64bit-3.3.5.0 on my Windows 8.1 machine I think I may hit issue related with what you are discussing which I can reproduce very easy. I have file with the following content

def msgBox(caption,title='Information',buttons=['OK']): '''Displays a modal message box. Arguments: caption: message text title: titlebar text buttons: list or tuple of buttons label texts

The message box icon is set by a keyword in the title.
Following keywords are recognized: 
    'info' or 'about',
    'critical' or 'error,
    'warning' or 'caution',
    'question' or 'confirm'.
Where each keyword of these pairs is fully equivalent.

Up to three buttons can be specified, using a tuple or list of button labels.

Example:
    import PYnGUInLib as GUI
    reply=GUI.msgBox('Do you want to abort?','Question',['Abort','Continue','Restart'])

If no buttons are specified, there is one "OK" button by default.

The message box closes when a button is pressed, and the
label of the button that was pressed is returned.
'''

app=QtGui.QApplication.instance()   # checks if QApplication already exists 
if not app:                         # create QApplication if it doesnt exist 
    app = QtGui.QApplication(sys.argv)

mb=QtGui.QMessageBox()
mb.setStyleSheet("background-color: rgb(241, 241, 241);");

mb.setText(caption)
mb.setWindowTitle(title)
for str in buttons:
    mb.addButton(str, QtGui.QMessageBox.AcceptRole)

if 'info' in title.lower() or 'about' in title.lower():
    mb.setIcon(QtGui.QMessageBox.Information)
elif 'critical' in title.lower() or 'error' in title.lower():
    mb.setIcon(QtGui.QMessageBox.Critical)
elif 'warning' in title.lower() or 'caution' in title.lower():
    mb.setIcon(QtGui.QMessageBox.Warning)
elif 'question' in title.lower() or 'confirm' in title.lower():
    mb.setIcon(QtGui.QMessageBox.Question)
else:
    mb.setIcon(QtGui.QMessageBox.Information) 

return buttons[mb.exec_()]

import PYnGUInLib as GUI reply=GUI.msgBox('Do you want to abort?','Question',['Abort','Continue','Restart'])

at this point I get my message box if I hit for exmample a space in the Spyder console before hiting one of the buttons of my message box it seems something happens. So after that I get this behaviour: (have to press enter sometimes 2 tiomes, somethimes 5,6 times before getting the result)

2+2

4

spyder-bot commented 9 years ago

From dpe...@gmail.com on 2014-11-05T10:51:41Z

I've just noticed the amount of enters required (to get 4) depends of how many spaces I have entered before hiting a message box button.

spyder-bot commented 9 years ago

From ccordoba12 on 2015-01-01T15:47:59Z

issue #1597 has been merged into this issue.

spyder-bot commented 9 years ago

From dive...@gmail.com on 2015-02-03T23:16:37Z

In Spyder 2.3.2, this bug, which initially appeared specific to Windows, can now be reproduced also using Python 3.4 (Anaconda) under Ubuntu (14.04 64bit).

It would be great if somebody was able to fix this major and long-standing bug. Alternatively the console should be disabled under Python 3 to make clear it is not supported there.

spyder-bot commented 9 years ago

From ccordoba12 on 2015-02-04T07:28:07Z

This is more serious. So this code

import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(5))
print("first script")

also gives problems on Ubuntu?