a
    dX0                     @  s$  d dl mZ d dlZd dlmZmZ d dlmZmZ d dl	m
Z
 d dlmZmZ d dlmZmZ erpd dl	mZ ed	 e G d
d de
Ze G dd de
ZG dd de
eeZe G dd de
eZeZe G dd de
ZG dd de
ZG dd de
Ze G dd de
ZdS )    )annotationsN)TYPE_CHECKINGLiteral)documentset_documentation_group)BlockContext)warn_deprecationwarn_style_method_deprecation)
Changeable
Selectable)BlockZlayoutc                      sl   e Zd ZdZdddddddddd fd	d
Z fddZedddddZddddddZ  Z	S )Rowa3  
    Row is a layout element within Blocks that renders all children horizontally.
    Example:
        with gr.Blocks() as demo:
            with gr.Row():
                gr.Image("lion.jpg", scale=2)
                gr.Image("tiger.jpg", scale=1)
        demo.launch()
    Guides: controlling-layout
    defaultTN)variantvisibleelem_idequal_height&Literal['default', 'panel', 'compact']bool
str | Nonec                  s6   || _ || _|dkrd| _t jf ||d| dS )a  
        Parameters:
            variant: row type, 'default' (no background), 'panel' (gray background color and rounded corners), or 'compact' (rounded corners and no internal gap).
            visible: If False, row will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
            equal_height: If True, makes every child element have equal height
        compactFr   r   N)r   r   allow_expected_parentssuper__init__)selfr   r   r   r   kwargs	__class__ W/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/gradio/layouts.pyr      s
    zRow.__init__c                   s   d| j | jdt  S )Nrow)typer   r   )r   r   r   
get_configr   r   r   r    r#   5   s    zRow.get_configbool | Noner   c                 C  s
   | ddS Nupdate)r   __type__r   r&   r   r   r    r(   =   s    z
Row.update)r   c                K  s   t   |dur|| _| S )z
        Styles the Row.
        Parameters:
            equal_height: If True, makes every child element have equal height
        N)r	   r   )r   r   r   r   r   r    styleF   s    z	Row.style)N
__name__
__module____qualname____doc__r   r#   staticmethodr(   r*   __classcell__r   r   r   r    r      s    r   c                      s^   e Zd ZdZddddddddd	d
dd fddZ fddZeddddddZ  ZS )Columna~  
    Column is a layout element within Blocks that renders all children vertically. The widths of columns can be set through the `scale` and `min_width` parameters.
    If a certain scale results in a column narrower than min_width, the min_width parameter will win.
    Example:
        with gr.Blocks() as demo:
            with gr.Row():
                with gr.Column(scale=1):
                    text1 = gr.Textbox()
                    text2 = gr.Textbox()
                with gr.Column(scale=4):
                    btn1 = gr.Button("Button 1")
                    btn2 = gr.Button("Button 2")
    Guides: controlling-layout
       i@  r   TN)scale	min_widthr   r   r   intr   r   r   c                  sX   |t |krtd| d || _|| _|| _|dkr<d| _t jf ||d| dS )a  
        Parameters:
            scale: relative width compared to adjacent Columns. For example, if Column A has scale=2, and Column B has scale=1, A will be twice as wide as B.
            min_width: minimum pixel width of Column, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in a column narrower than min_width, the min_width parameter will be respected first.
            variant: column type, 'default' (no background), 'panel' (gray background color and rounded corners), or 'compact' (rounded corners and no internal gap).
            visible: If False, column will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
        z*'scale' value should be an integer. Using z will cause issues.r   Fr   N)roundr   r4   r5   r   r   r   r   )r   r4   r5   r   r   r   r   r   r   r    r   h   s    
zColumn.__init__c                   s   d| j | j| jdt  S )Ncolumn)r"   r   r4   r5   )r   r4   r5   r   r#   r$   r   r   r    r#      s    zColumn.get_configr%   r   r   c                 C  s   | |ddS )Nr(   )r   r   r)   r   r9   r   r   r    r(      s    zColumn.update)NN	r,   r-   r.   r/   r   r#   r0   r(   r1   r   r   r   r    r2   W   s   	  r2   c                      sP   e Zd ZdZdddddddddd	Z fd
dZedddddZ  ZS )Tabsz\
    Tabs is a layout element within Blocks that can contain multiple "Tab" Components.
    NT)selectedr   r   int | str | Noner   r   c                K  s6   t j| f||d| t|  t|  || _dS )ap  
        Parameters:
            selected: The currently selected tab. Must correspond to an id passed to the one of the child TabItems. Defaults to the first TabItem.
            visible: If False, Tabs will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
        r   N)r   r   r
   r   r<   )r   r<   r   r   r   r   r   r    r      s    

zTabs.__init__c                   s   d| j itt|  S )Nr<   )r<   r   r   r#   r$   r   r   r    r#      s    zTabs.get_configr<   c                 C  s
   | ddS )Nr(   )r<   r)   r   r>   r   r   r    r(      s    zTabs.update)Nr:   r   r   r   r    r;      s    r;   c                      sP   e Zd ZdZddddddddd	Z fd
dZddddZdd Z  ZS )Taba  
    Tab (or its alias TabItem) is a layout element. Components defined within the Tab will be visible when this tab is selected tab.
    Example:
        with gr.Blocks() as demo:
            with gr.Tab("Lion"):
                gr.Image("lion.jpg")
                gr.Button("New Lion")
            with gr.Tab("Tiger"):
                gr.Image("tiger.jpg")
                gr.Button("New Tiger")
    Guides: controlling-layout
    N)idr   strr=   r   )labelr@   r   c                K  s0   t j| fd|i| t|  || _|| _dS )aW  
        Parameters:
            label: The visual label for the tab
            id: An optional identifier for the tab, required if you wish to control the selected tab from a predict function.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
        r   N)r   r   r   rB   r@   )r   rB   r@   r   r   r   r   r    r      s    
zTab.__init__c                   s   | j | jdtt|  S )N)rB   r@   )rB   r@   r   r   r#   r$   r   r   r    r#      s
    zTab.get_configz
type[Tabs])returnc                 C  s   t S N)r;   r$   r   r   r    get_expected_parent   s    zTab.get_expected_parentc                 C  s   dS )NZtabitemr   r$   r   r   r    get_block_name   s    zTab.get_block_name)	r,   r-   r.   r/   r   r#   rE   rF   r1   r   r   r   r    r?      s   r?   c                      sP   e Zd ZdZdddddd fddZ fd	d
ZedddddZ  ZS )Groupa  
    Group is a layout element within Blocks which groups together children so that
    they do not have any padding or margin between them.
    Example:
        with gr.Group():
            gr.Textbox(label="First")
            gr.Textbox(label="Last")
    TNr   r   r   c                  s   t  jf ||d| dS )z
        Parameters:
            visible: If False, group will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
        r   N)r   r   r   r   r   r   r   r   r    r      s    zGroup.__init__c                   s   ddit   S )Nr"   groupr   r#   r$   r   r   r    r#     s    zGroup.get_configr%   r&   c                 C  s
   | ddS r'   r   r&   r   r   r    r(     s    zGroup.update)Nr:   r   r   r   r    rG      s    rG   c                      sX   e Zd ZdZdddddd fddZ fd	d
ZedddddZdd Z  Z	S )Boxz
    DEPRECATED.
    Box is a a layout element which places children in a box with rounded corners and
    some padding around them.
    Example:
        with gr.Box():
            gr.Textbox(label="First")
            gr.Textbox(label="Last")
    TNr   r   r   c                  s(   t dt t jf ||d| dS )z
        Parameters:
            visible: If False, box will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
        z+gr.Box is deprecated. Use gr.Group instead.r   N)warningswarnDeprecationWarningr   r   rH   r   r   r    r   $  s    zBox.__init__c                   s   ddit   S )Nr"   ZboxrJ   r$   r   r   r    r#   3  s    zBox.get_configr%   r&   c                 C  s
   | ddS r'   r   r&   r   r   r    r(   6  s    z
Box.updatec                 K  s
   t   | S rD   )r	   )r   r   r   r   r    r*   ?  s    z	Box.style)Nr+   r   r   r   r    rK     s    rK   c                      sJ   e Zd Zdddddd fddZdd fdd	Z fd
dZ  ZS )Formr   )r4   r5   r6   c                  s"   || _ || _t jf i | dS )a  
        Parameters:
            scale: relative width compared to adjacent Columns. For example, if Column A has scale=2, and Column B has scale=1, A will be twice as wide as B.
            min_width: minimum pixel width of Column, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in a column narrower than min_width, the min_width parameter will be respected first.
        N)r4   r5   r   r   )r   r4   r5   r   r   r   r    r   E  s    zForm.__init__r   )childc                   s\   t | jtrLt|dd }|  j|d u r*dn|7  _|  jt|ddpFd7  _t | d S )Nr4   r3   r5   r   )
isinstanceparentr   getattrr4   r5   r   	add_child)r   rP   r4   r   r   r    rT   O  s
    zForm.add_childc                   s   d| j | jdt  S )Nform)r"   r4   r5   )r4   r5   r   r#   r$   r   r   r    r#   V  s    zForm.get_config)r,   r-   r.   r   rT   r#   r1   r   r   r   r    rO   D  s   
rO   c                      sX   e Zd ZdZdddddddd fddZ fd	d
ZedddddddZ  ZS )	Accordionz
    Accordion is a layout element which can be toggled to show/hide the contained content.
    Example:
        with gr.Accordion("See Details"):
            gr.Markdown("lorem ipsum")
    TN)openr   r   r   r   c                  s(   || _ || _t jf ||d| dS )a  
        Parameters:
            label: name of accordion section.
            open: if True, accordion is open by default.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
        r   N)rB   rW   r   r   )r   rB   rW   r   r   r   r   r   r    r   h  s    zAccordion.__init__c                   s   d| j | jdt  S )NZ	accordion)r"   rW   rB   )rW   rB   r   r#   r$   r   r   r    r#   {  s    zAccordion.get_configr%   rW   rB   r   c                 C  s   ||| ddS )Nr(   )r   rB   rW   r)   r   rX   r   r   r    r(     s
    zAccordion.update)NNNr:   r   r   r   r    rV   _  s      rV   )
__future__r   rL   typingr   r   Zgradio_client.documentationr   r   Zgradio.blocksr   Zgradio.deprecationr   r	   Zgradio.eventsr
   r   r   r   r2   r;   r?   ZTabItemrG   rK   rO   rV   r   r   r   r    <module>   s.   DC%/%+