Saadmairaj / tkterminal

Terminal widget for Tkinter library.
https://pypi.org/project/tkterminal
Apache License 2.0
58 stars 6 forks source link

Can't give input when user runs python script #6

Open Moosems opened 2 years ago

Moosems commented 2 years ago

I was hoping to use this for a personal IDE made in tkinter but when I try to run a python script that has an input command it gives the error: "Exception in Tkinter callback Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/init.py", line 1892, in call return self.func(*args) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/tkterminal/ternimal.py", line 203, in _on_keypress or ((insert_idx.column <= self._limit_backspace or False) TypeError: '<=' not supported between instances of 'int' and 'NoneType'"

Not only this, but when I use the command "python" it also gives that error.

Saadmairaj commented 2 years ago

thanks for reporting it, will look into it 👍

Moosems commented 2 years ago

@Saadmairaj Any progress?

lebao3105 commented 11 months ago

Tkterminal is not a real terminal, it just like is (well my bad) an extended Input Text widget with custom commands override the default ones.

Python interperter/input() takes input, right? As well as any other shells like cmd, bash. And tkterminal can't handle this since it uses subprocess as described in README.md.

This is an advanced topic that even I cannot explain:.

Better spawn a new external terminal process, or switch to toolkit that has a terminal widget like Gtk (not cross-platform) or Qt.

lebao3105 commented 11 months ago

Tkterminal is not a real terminal, it just like an extended Input widget with custom commands override the default ones.

Python interperter/input() takes input, right? As well as any other shells like cmd, bash. And tkterminal can't handle this since it uses subprocess as described in README.md.

This is an advanced topic, and if tkterminal could take inputs for other programs easily without passing HTML tags, we could have a proper Tkinter terminal a long time ago (except for its ugly when used on Linux).

Better spawn a new external terminal process, or switch to toolkit that has a terminal widget like Gtk (not cross-platform) or Qt.

My bad for not remembering that IDLE has Python interpreter in Tkinter, and commenting right before I go to school.

Here's what I'm talking about Python shell in IDLE: https://github.com/python/cpython/blob/main/Lib/idlelib/pyshell.py

Tkterminal works like that shell too (see the PyShell class), a lot of things have been made in order to make the Tkinter shell work.

So actually, making TkTerminal, or Tkinter.Text accept inputs for shells is able, but takes a lot of work.

Moosems commented 11 months ago

Using Tcls Expect package could work :).