Skip to main content

gradio_doctestcode

PyPI - Version

Python library for easily interacting with trained machine learning models

Installation

pip install gradio_doctestcode

Usage

import gradio as gr
from gradio_doctestcode import DocTestCode


example = DocTestCode().example_inputs()

demo = gr.Interface(
    lambda x:x,
    DocTestCode(),  # interactive version of your component
    DocTestCode(),  # static version of your component
    # examples=[[example]],  # uncomment this line to view the "example version" of your component
)


if __name__ == "__main__":
    demo.launch()

DocTestCode

Initialization

name type default description
value
str | tuple[str] | None
None Default value to show in the code editor. If callable, the function will be called whenever the app loads to set the initial value of the component.
language
"python"
    | "markdown"
    | "json"
    | "html"
    | "css"
    | "javascript"
    | "typescript"
    | "yaml"
    | "dockerfile"
    | "shell"
    | "r"
    | None
None The language to display the code as. Supported languages listed in `gr.Code.languages`.
every
float | None
None If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
lines
int
5 None
label
str | None
None The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
interactive
bool | None
None Whether user should be able to enter code or only view it.
show_label
bool | None
None if True, will display label.
container
bool
True If True, will place the component in a container - providing some extra padding around the border.
scale
int | None
None relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
min_width
int
160 minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
visible
bool
True If False, component will be hidden.
elem_id
str | None
None An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes
list[str] | str | None
None An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
render
bool
True If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.

Events

name description
change Triggered when the value of the DocTestCode changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.
input This listener is triggered when the user changes the value of the DocTestCode.
focus This listener is triggered when the DocTestCode is focused.
blur This listener is triggered when the DocTestCode is unfocused/blurred.

User function

def predict(
    value: Any
) -> tuple | str | None:
    return value

Metadata

Release files for gradio-doctestcode 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradio-doctestcode 0.0.4
File Size Uploaded
gradio_doctestcode-0.0.4.tar.gz 322.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gradio-doctestcode 0.0.4
File Interpreter ABI Platform
gradio_doctestcode-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 630.4 kB

Release files / gradio_doctestcode-0.0.4.tar.gz

Download URL gradio_doctestcode-0.0.4.tar.gz
Size 322.1 kB
Tags Source
SHA-256 checksum
How to use checksums
903cc1c9cc804e61c344e6df724b536eb87b95ccf784f470c740efadb9a1960a
BLAKE2b-256 checksum
How to use checksums
c759f3e137d1a0562af600beb7f193bdad58f888bbc957f5d348d26bda32a3d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / gradio_doctestcode-0.0.4-py3-none-any.whl

Download URL gradio_doctestcode-0.0.4-py3-none-any.whl
Size 308.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
289997ec0369813bc002e8769851afde68055e56e5ed1c29bd237f5ddd77564c
BLAKE2b-256 checksum
How to use checksums
d8cb7205df087f4581db516723af5aae63c21862c415fe130a1d04b577fa9644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page