Guigaga
GUIGAGA
A class to build a graphical user interface for a given command line interface.
Source code in src/guigaga/guigaga.py
16 17 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 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 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
__init__(cli, app_name=None, command_name='gui', click_context=None, *, theme='soft', hide_not_required=False, allow_file_download=False, catch_errors=True)
Initializes the GUIGAGA with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cli |
click.Group | click.Command
|
The command line interface to build a GUI for. |
required |
app_name |
str | None
|
The name of the application. Defaults to None. |
None
|
command_name |
str
|
The name of the command. Defaults to "gui". |
'gui'
|
click_context |
click.Context
|
The context of the click command. Defaults to None. |
None
|
theme |
GradioTheme
|
The theme of the GUI. Defaults to Soft. |
'soft'
|
hide_not_required |
bool
|
Whether to hide not required options. Defaults to False. |
False
|
allow_file_download |
bool
|
Whether to allow file download. Defaults to False. |
False
|
catch_errors |
bool
|
Whether to catch errors. Defaults to True. |
True
|
Side Effects
- Initializes various instance variables.
- Calls introspect_click_app to get the command schemas.
- Calls traverse_command_tree to create the interface.
Source code in src/guigaga/guigaga.py
create_block(command_schema)
Creates a block for the given command schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to create a block for. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
The name of the command and the created block. |
Side Effects
- Creates various GUI components.
- Defines the run_command function.
Source code in src/guigaga/guigaga.py
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 |
|
get_component(schema)
Gets the component for the given schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
OptionSchema | ArgumentSchema
|
The schema to get the component for. |
required |
Returns:
Type | Description |
---|---|
gradio.Interface: The component for the given schema. |
Source code in src/guigaga/guigaga.py
get_output_values(command_schema)
Gets the output values for the given command schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to get the output values for. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
The list of output values. |
Source code in src/guigaga/guigaga.py
get_outputs(command_schema)
Gets the outputs for the given command schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to get the outputs for. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
The list of outputs. |
Source code in src/guigaga/guigaga.py
has_advanced_options(command_schema)
Checks if the given command schema has advanced options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the command schema has advanced options, False otherwise. |
Source code in src/guigaga/guigaga.py
launch(queue_kwargs=None, launch_kwargs=None)
Launches the GUI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Additional keyword arguments to pass to the launch method. |
required |
Side Effects
- Launches the GUI.
Source code in src/guigaga/guigaga.py
render_help_and_header(command_schema)
Renders the help and header for the given command schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to render the help and header for. |
required |
Side Effects
- Renders the help and header.
Source code in src/guigaga/guigaga.py
render_schemas(command_schema, *, render_required=True, render_not_required=True)
Renders the schemas for the given command schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to render the schemas for. |
required |
render_required |
bool
|
Whether to render required schemas. Defaults to True. |
True
|
render_not_required |
bool
|
Whether to render not required schemas. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
The rendered schemas. |
Source code in src/guigaga/guigaga.py
sort_schemas(command_schema, schemas)
Sorts the given schemas based on the order of the command schema's function arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_schema |
CommandSchema
|
The command schema to sort the schemas based on. |
required |
schemas |
dict
|
The schemas to sort. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
The sorted schemas. |
Source code in src/guigaga/guigaga.py
traverse_command_tree(schema)
Recursively traverse the command tree and create a tabbed interface for each nested command group