diff --git a/gradio/blocks.py b/gradio/blocks.py index 0624497e0f..154b1e9b94 100644 --- a/gradio/blocks.py +++ b/gradio/blocks.py @@ -13,6 +13,12 @@ if TYPE_CHECKING: # Only import for type checking (is False at runtime). class Block: def __init__(self): + self.render() + + def render(self): + """ + Adds self into appropriate BlockContext + """ self._id = Context.id Context.id += 1 if Context.block is not None: @@ -55,7 +61,10 @@ class Block: class BlockContext(Block): - def __init__(self, css: Optional[str] = None): + def __init__(self, css: Optional[Dict[str, str]] = None): + """ + css: Css rules to apply to block. + """ self.children = [] self.css = css if css is not None else {} super().__init__() @@ -76,6 +85,9 @@ class BlockContext(Block): class Row(BlockContext): def __init__(self, css: Optional[str] = None): + """ + css: Css rules to apply to block. + """ super().__init__(css) def get_template_context(self): @@ -84,6 +96,9 @@ class Row(BlockContext): class Column(BlockContext): def __init__(self, css: Optional[str] = None): + """ + css: Css rules to apply to block. + """ super().__init__(css) def get_template_context(self): @@ -95,6 +110,9 @@ class Column(BlockContext): class Tabs(BlockContext): def __init__(self, css: Optional[str] = None): + """ + css: Css rules to apply to block. + """ super().__init__(css) def change(self, fn: Callable, inputs: List[Component], outputs: List[Component]): @@ -110,6 +128,9 @@ class Tabs(BlockContext): class TabItem(BlockContext): def __init__(self, label, css: Optional[str] = None): + """ + css: Css rules to apply to block. + """ super().__init__(css) self.label = label super(TabItem, self).__init__() diff --git a/gradio/flagging.py b/gradio/flagging.py index e16f039b82..cc3cc5928a 100644 --- a/gradio/flagging.py +++ b/gradio/flagging.py @@ -27,6 +27,7 @@ class FlaggingCallback(ABC): This method should be overridden and ensure that everything is set up correctly for flag(). This method gets called once at the beginning of the Interface.launch() method. Parameters: + components: Set of components that will provide flagged data. flagging_dir: A string, typically containing the path to the directory where the flagging file should be storied (provided as an argument to Interface.__init__()). """ pass diff --git a/gradio/interface.py b/gradio/interface.py index a040781127..e17c8f71db 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -490,7 +490,7 @@ class Interface(Blocks): } ): for component in self.input_components: - Block.__init__(component) + component.render() with Row(): submit_btn = Button("Submit") clear_btn = Button("Clear")