This is a terminal widget in Tkinter and Python.
Note: running applications such as gcc or such, which have infinite loops, will hang this, since no new thread/process is created when executing user input.
Download the folder and in command-line, travel to the 'terminal' directory. Use pip install .
.
A simple script
from tkinter import *
from terminal import *
root = Tk()
terminal = Terminal(root)
terminal.pack()
root.mainloop()
A terminal will be shown.
To use dark mode:
terminal.dark_mode()
Use the dark_mode
method.
To run a command, use the run
method:
terminal.run('echo hello')
To clear the console programmatically, use the clear_screen
method:
terminal.clear_screen()
To clear it within the console, use the cls
command.
To get used commands, use the commands
method:
used_commands = terminal.commands()
To get all output, use the output
method:
all_output = terminal.output()
To clear the output list, use the clear_output
method:
terminal.clear_output()
To clear the used commands list, use the clear_commands
method:
terminal.clear_commands()
To disable all commands except for what commands you manually set:
terminal.disable_commands()
To set a command that the user can run:
terminal.new_custom_command("my-cool-command", myfunction)
To change color:
terminal.dark_mode(bg='grey7', fg='white', insertbackground='white')
Same goes for .light_mode()
, but the default colors are different.