o
    eX0                     @  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r8d 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                      s\   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Z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_heightr   &Literal['default', 'panel', 'compact']r   boolr   
str | Noner   c                  s6   || _ || _|dkrd| _t jd||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__r   >D:\Projects\ConvertPro\env\Lib\site-packages\gradio/layouts.pyr      s
   zRow.__init__c                      d| j | jdt  S )Nrow)typer   r   )r   r   r   
get_configr   r   r   r    r$   5      zRow.get_configbool | Nonec                 C  
   | ddS Nupdate)r   __type__r   r   r   r   r    r*   =      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)r   r   r   r   r   r   r   r   Nr   r'   )r   r'   
__name__
__module____qualname____doc__r   r$   staticmethodr*   r.   __classcell__r   r   r   r    r      s    r   c                      sP   e Zd ZdZddddddd fddZ fddZe		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   r:   intr;   r   r   r   r   r   r   c                  sX   |t |krtd| d || _|| _|| _|dkrd| _t jd||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   Nr   )roundr   r:   r;   r   r   r   r   )r   r:   r;   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   r:   r;   )r   r:   r;   r   r$   r%   r   r   r    r$      s   zColumn.get_configr'   c                 C  s   | |ddS )Nr*   )r   r   r+   r   )r   r   r   r   r    r*      s   zColumn.update)
r:   r<   r;   r<   r   r   r   r   r   r   )NN)r   r   r   r'   	r2   r3   r4   r5   r   r$   r6   r*   r7   r   r   r   r    r8   W   s    	r8   c                      sF   e Zd ZdZdddddddZ fddZe	ddddZ  ZS )Tabsz\
    Tabs is a layout element within Blocks that can contain multiple "Tab" Components.
    NT)selectedr   r   rA   int | str | Noner   r   r   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   rA   )r   rA   r   r   r   r   r   r    r      s   


zTabs.__init__c                   s   d| j itt|  S )NrA   )rA   r   r   r$   r%   r   r   r    r$      s   zTabs.get_configc                 C  r(   )Nr*   )rA   r+   r   )rA   r   r   r    r*      r-   zTabs.update)rA   rB   r   r   r   r   r/   )rA   rB   r?   r   r   r   r    r@      s    r@   c                      sD   e Zd ZdZddddd
dZ fddZ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   labelstrrD   rB   r   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   rE   rD   )r   rE   rD   r   r   r   r   r    r      s   

zTab.__init__c                   s   | j | jdtt|  S )N)rE   rD   )rE   rD   r   r   r$   r%   r   r   r    r$      s
   zTab.get_configreturn
type[Tabs]c                 C  s   t S r/   )r@   r%   r   r   r    get_expected_parent      zTab.get_expected_parentc                 C  s   dS )NZtabitemr   r%   r   r   r    get_block_name   rJ   zTab.get_block_name)rE   rF   rD   rB   r   r   )rG   rH   )	r2   r3   r4   r5   r   r$   rI   rK   r7   r   r   r   r    rC      s    
rC   c                      sH   e Zd ZdZdddd fd	d
Z fddZe	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   r   r   c                  s   t  jd||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   Nr   )r   r   r   r   r   r   r   r   r    r      s   zGroup.__init__c                      ddit   S )Nr#   groupr   r$   r%   r   r   r    r$        zGroup.get_configr'   c                 C  r(   r)   r   r,   r   r   r    r*     r-   zGroup.updater   r   r   r   r/   r0   r?   r   r   r   r    rL      s    rL   c                      sP   e Zd ZdZdddd fd	d
Z fddZe	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   r   r   c                  s(   t dt t jd||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   Nr   )warningswarnDeprecationWarningr   r   rM   r   r   r    r   $  s   zBox.__init__c                   rN   )Nr#   boxrP   r%   r   r   r    r$   3  rQ   zBox.get_configr'   c                 C  r(   r)   r   r,   r   r   r    r*   6  r-   z
Box.updatec                 K  s
   t   | S r/   )r	   )r   r   r   r   r    r.   ?  s   z	Box.stylerR   r/   r0   r1   r   r   r   r    rS     s    rS   c                      s@   e Zd Zdddd fddZd fd
dZ fddZ  ZS )Formr   )r:   r;   r:   r<   r;   c                  s"   || _ || _t jd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.
        Nr   )r:   r;   r   r   )r   r:   r;   r   r   r   r    r   E  s   zForm.__init__childr   c                   s\   t | jtr&t|dd }|  j|d u rdn|7  _|  jt|ddp#d7  _t | d S )Nr:   r9   r;   r   )
isinstanceparentr   getattrr:   r;   r   	add_child)r   rY   r:   r   r   r    r]   O  s
   zForm.add_childc                   r!   )Nform)r#   r:   r;   )r:   r;   r   r$   r%   r   r   r    r$   V  r&   zForm.get_config)r:   r<   r;   r<   )rY   r   )r2   r3   r4   r   r]   r$   r7   r   r   r   r    rX   D  s    
rX   c                      sN   e Zd ZdZddddd fd
dZ fddZe			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   r   r   r   c                  s(   || _ || _t jd||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   Nr   )rE   r`   r   r   )r   rE   r`   r   r   r   r   r   r    r   h  s   zAccordion.__init__c                   r!   )NZ	accordion)r#   r`   rE   )r`   rE   r   r$   r%   r   r   r    r$   {  r&   zAccordion.get_configr'   rE   c                 C  s   ||| ddS )Nr*   )r   rE   r`   r+   r   )r`   rE   r   r   r   r    r*     s
   zAccordion.update)r`   r   r   r   r   r   )NNN)r`   r'   rE   r   r   r'   r?   r   r   r   r    r_   _  s    r_   )
__future__r   rT   typingr   r   Zgradio_client.documentationr   r   Zgradio.blocksr   Zgradio.deprecationr   r	   Zgradio.eventsr
   r   r   r   r8   r@   rC   ZTabItemrL   rS   rX   r_   r   r   r   r    <module>   s0    DC%/%+