d0vgan / nppexec

NppExec (plugin for Notepad++)
GNU General Public License v3.0
129 stars 23 forks source link

Issue with plots (matplotlib) or other UIs #100

Open mrrezaie opened 1 week ago

mrrezaie commented 1 week ago

Hi, NppExec does not show any plot. Here is an example:

import matplotlib.pyplot as plt
plt.plot([0,1,2,3,4,5,6,7,8,9,10])
plt.show()

Any help is appreciated.

d0vgan commented 6 days ago

This seems to be similar to the 4th case here, where a separate console window is required for python program: https://d0vgan.github.io/nppexec/?q=4.6.4

When a console program is started in its own window, NppExec can wait until this console program finishes. Refer to the Q3 here: https://d0vgan.github.io/nppexec/?q=FAQ

Finally, if your python program is a "cell" in the current file (that needs to be selected and then passed to python) rather than the entire current file, then you first need to save the selected text into a temporary file via sel_saveto and pass that temporary file to python, similarly as described here: https://d0vgan.github.io/nppexec/?q=4.6.3

mrrezaie commented 1 day ago

Thanks for your response. I'm not sure I understand your solution.

I tested IPython console. It doesn't work with qt backend: Cannot install event loop hook for "qt" when running with `--simple-prompt`. NOTE: Tk is supported natively; use Tk apps and Tk backends with `--simple-prompt`.

In the tk backend however, the plot window appears, but it is not functional: image

I'm looking forward to improvements in this regard, as this issue is prohibitive for interactive python users. Thank you.

d0vgan commented 6 hours ago

As I wrote, this seems to be the case where "a separate console window is required for python program". The links mentioned above describe in details how to start a program in its own console window. I'm afraid there's nothing I can add or do in addition to that.