TkXTerm - XTerm in Tkinter
TkXTerm makes available a Terminal Ttk frame, that have XTerm embedded and it can be used in the Tkinter GUI as a normal frame. It's possible to send any commands to execute it, having back in the code an object that, after the end of the command, contains the exit code and can execute a callback. It's also possible to use XTerm normally.
This project is born with the purpose of having an embedded and fully functional bash terminal in a Tkinter GUI, to interact with it and run some commands automatically, viewing in real-time the output and the results and having the exit code back into an object in the code.
Installation
TkXTerm can be installed from PyPI using the command pip install tkxterm.
Besides Tkinter, it has XTerm and screen (a GNU software, generally preinstalled in all Linux system) as dependecies. Make sure you have both installed before trying to use this library. Because of these dependencies, this library is available only for Linux system; correct functioning in other systems is not guaranteed.
If you want to change any behaviour or the style of the terminal itself, for example to enable the scrolling or the colors, you can relate to the settings of GNU screen tool and the XTerm settings.
Usage
Terminal
TkXTerm makes available the Terminal Ttk frame, so all the Ttk Frame options are available.
In addition, it can accept the following options:
restore_on_close, which enables automatic restart of the terminal when it is closed (e.g. by accidentally pressing Ctrl-D);read_interval_ms, which specifies how many milliseconds should pass between each reading of the terminal to retrieve exit codes;read_length, which specifies how many bytes to read in each interval.
All these options can be changed like any option of the frame.
The terminal will only be launched once it has been visible!
You can manually type a command in the terminal only if the cursor was in its frame!
It has also its methods to interact with the terminal:
run_commandis the resposible for run any command you want on the terminal. This method will add an end command to your command, which will print the exit code to capture it. To execute a command in background, use thebackgroundargument rather than using the classic&method, because otherwise the exit code indicates only if the command started correctly or not, and not the actual exit code of the command runned in background. You can also specify acallbackthat will be called immediatly after the command is terminated, this callback receive the Command object as argument.send_stringis the function for the actual sending any string to the terminal, and stores it if the terminal is not ready. With this you can send any string at any moment to the terminal.restart_termis the procedure for reboot the terminal if it is closed.
Furthermore, it have the properties ready, that indicates if the terminal is ready or not, and end_string, that returns the string appended at the end of any command executed.
Terminal generates also some events: when the terminal is ready or no more ready, it generates <<TerminalReady>> and <<TerminalClosed>>; when a command finishes it generates <<CommandEnded>> with the referiment to the Command object, while when a string is sent to the terminal, it generates <<StringSent>> with the referiment to the string itself.
Command
The run_command method returns an instance of the Command class, that hold the command string in the cmd property, the exit code of itself in the exit_code property, and the callback in the callback property.
Metadata
Release files for tkxterm 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tkxterm-1.0.3.tar.gz | 65.0 kB | Without provenance | Details for tkxterm-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tkxterm-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for tkxterm-1.0.3-py3-none-any.whl |
Total release size: 97.7 kB
Release files / tkxterm-1.0.3.tar.gz
| Download URL | tkxterm-1.0.3.tar.gz |
|---|---|
| Size | 65.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d605e4ccd14dc00466def89f5d0015221b0258639eaaf3fbf7ef34b4e4d34f58
|
|
BLAKE2b-256 checksum How to use checksums |
a08274b5fc231adec8cfda1e14027ee896ffefcbf7ba4902d4984270b2cd6c92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / tkxterm-1.0.3-py3-none-any.whl
| Download URL | tkxterm-1.0.3-py3-none-any.whl |
|---|---|
| Size | 32.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0c3dcae24868cdc6d5eefa416def8a4c77bfa2235687bdc9ac349e24b370d30
|
|
BLAKE2b-256 checksum How to use checksums |
b64d04dc1292c39b7405d0703dc6a28b8b0d6f7b579c5b9e9c6999f956699fd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Security for tkxterm 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.