API Reference
Terminals
Bases: Frame
Mono's tabbed terminal manager
This widget is a container for multiple terminal instances. It provides methods to create, delete, and manage terminal instances. It also provides methods to run commands in the active terminal and switch between terminals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
master |
Tk
|
Main window. |
required |
cwd |
str
|
Working directory. |
None
|
theme |
Theme
|
Custom theme instance. |
None
|
Source code in mono\__init__.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
active_terminal: Terminal
property
Get the active terminal instance.
active_terminal_type: Terminal
property
Get the type of the active terminal. If there is no active terminal, return Default type.
add_default_terminal(*_)
Add a default terminal to the list. Create a tab for it.
Returns:
Name | Type | Description |
---|---|---|
Default |
Default
|
Default terminal instance. |
Source code in mono\__init__.py
add_terminal(terminal)
Append terminal to list. Create tab for it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
terminal |
Terminal
|
Shell type to append. |
required |
add_terminals(terminals)
Append multiple terminals to list. Create tabs for them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
terminals |
list
|
List of Shell types to append. |
required |
clear_terminal(*_)
delete_active_terminal(*_)
delete_all_terminals(*_)
Permanently delete all terminal instances.
delete_terminal(terminal)
Permanently delete a terminal instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
terminal |
Terminal
|
Terminal instance to delete. |
required |
open_another_terminal(cwd=None)
Opens another instance of the active terminal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cwd |
str
|
Directory path. |
None
|
Source code in mono\__init__.py
open_bash(*_)
open_cmd(*_)
open_pwsh(*_)
open_python(*_)
open_shell(shell)
Creates an instance and opens a shell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shell |
Terminal
|
Shell type to open (not instance) use add_terminal() to add existing instance. |
required |
Source code in mono\__init__.py
refresh(*_)
Generates <
run_command(command)
Run a command in the active terminal. If there is no active terminal, create a default terminal and run the command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command |
str
|
Command to run. |
required |
Source code in mono\__init__.py
run_in_external_console(command)
staticmethod
Run a command in an external console.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command |
str
|
Command to run. |
required |
Source code in mono\__init__.py
set_active_terminal(terminal)
Switch tabs to the terminal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
terminal |
Terminal
|
Terminal instance to switch to. |
required |
Source code in mono\__init__.py
set_active_terminal_by_name(name)
Switch tabs to the terminal by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the terminal to switch to. |
required |
Source code in mono\__init__.py
set_cwd(cwd)
Set current working directory for all terminals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cwd |
str
|
Directory path. |
required |
Shells
get_available_shells()
get_shell_from_name(name)
Return the shell class from the name.
If the shell is not found, return the default shell for the platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the shell to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
Terminal |
Terminal | Default
|
The shell class. |
Source code in mono\shells\__init__.py
is_shell_registered(name)
Check if a shell is registered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the shell. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the shell is registered, False otherwise. |
register_shell(name, shell)
Register a new shell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the shell. |
required |
shell |
Terminal
|
The shell class. |
required |
Terminal
Bases: Frame
Terminal abstract class. All shell types should inherit from this class.
The inherited class should implement following attributes
name (str): Name of the terminal. shell (str): command / path to shell executable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
master |
Tk
|
Main window. |
required |
cwd |
str
|
Working directory. |
'.'
|
Source code in mono\terminal.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
__init__(master, cwd='.', theme=None, standalone=True, *args, **kwargs)
Source code in mono\terminal.py
check_shell()
clear()
enter(*_)
Enter key event handler for running commands.
Source code in mono\terminal.py
run_command(command)
Run a command in the terminal. TODO: Implement a queue for running multiple commands.
start_service(*_)
Theme
Theme
Color theme for the terminal.
Attributes:
Name | Type | Description |
---|---|---|
bg |
str
|
Background color. |
fg |
str
|
Foreground color. |
abg |
str
|
Active background color. |
afg |
str
|
Active foreground color. |
border |
str
|
Border color. |
tabbar |
str
|
Tab bar background color. This can be modified only after initialization. |
tab |
tuple
|
Tab color scheme. This can be modified only after initialization. |
tabs |
tuple
|
Tabs color scheme. This can be modified only after initialization. |
tab_active |
tuple
|
Active tab color scheme. This can be modified only after initialization. |
terminal |
tuple
|
Terminal color scheme. This can be modified only after initialization. |
scrollbar |
tuple
|
Scrollbar color scheme. This can be modified only after initialization. |