Closed sla-te closed 10 months ago
Thanks for the bug report. By default, PyCharm does not create a full terminal instance which is needed by simple-term-menu, thus raising the error, you got. You can enable emulating a full terminal emulator in the output console as a workaround. See https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003383619/comments/6589796593042 for details.
Thank you for the explanation and I can confirm, that it works if activating terminal emulation in the run configuration. Do note though, that on linux hitting run actually sometimes even crashes the entire IDE.
Another drawback is, that if activating terminal emulation in PyCharm we cannot use its built in debugger anymore btw.
Ok I see. But the main problem is, that simple-tem-menu relies on being run in a terminal emulator. Without the terminal emulation option, pyCharm uses simple stdin and stdout redirection (as far as I know) and simple-term-menu cannot work with that.
Ah well, we just have to remember to activate it before running - its a bit cumbersome though, because then we have to manually create a run config and right click run file will not work anymore - maybe it would be easy to add some kind of "debug" mode?
How shall the debug mode look like?
Well something, that gives less functionality but wont crash Pycharm ^^
Hmm, difficult, since simple-term-menu needs terminal capabilities for redrawing the screen... maybe it can be combined with pyte in this special case? I am quite unsure about this.
Well, maybe for starters: Can we somehow detect, that the current terminal is not suitable and then throw before the entire IDE crashes? That would, at least for me, help big time, because if you get unlucky and PyCharm crashes like this too often, you have to reinstall it completely (already had to 2 times), because of yea.. I wish I know but PyCharms error console was full of plugin errors, that would not disappear anymore.
Next step I think would be trying to find out how exactly PyCharms console or rather "terminal emulator" works internally and then investigate further how we can get the functionality we need or disable features, that are not compatible.
Ah ok, I thought the IDE would only crash sometimes with terminal emulation mode turned on. So it crashes without terminal emulation?
Exactly, it never crashes if terminal emulation is activated, it only crashes if not (thats the default) and that pretty consistently.
I have run some tests in PyCharm. In the latest PyCharm version, the output console seems to always have some kind of terminal emulation and terminal emulation cannot be switched on separately. However, no menu is shown :disappointed:. Therefore, I have added a check for the PyCharm output console on branch fix/pycharm-console
and abort the execution. Is this ok for now? You can test this change by getting the patched package version:
pip install 'git+https://github.com/IngoMeyer441/simple-term-menu@fix/pycharm-console'
Sorry for the late reply. It does block execution but also blocks it if emulate terminal output in console
is enabled, could you determine whether or not it is enabled and only throw if not, else it would not run in Pycharm at all.
The emulate terminal output in console
checkbox is missing in the latest PyCharm release. Do you still use an older version?
It just moved, its still there
Thanks, I didn't find this.
I have updated the branch and added a check for the TERM
variable. It can be used to detect a terminal in the PyCharm output console.
However, there is still an issue left: If PyCharm itself is started from a terminal emulator, the TERM
variable is always set and the detection won't work.
The fix is added in release v1.6.2. If it still needs improvement, please feel free to reopen.
Start Pycharm, create a new file with the following content and hit "Run"