
    q'Ve-                     D   d dl mZmZmZmZ erddlT dS erddlT dS ddgZerddlm	Z	 ddl
mZmZ nQerOddlm	Z	 ddlmZ 	 dd	lmZ dd
lmZ ddlmZ  G d de          Zd Zej        e_        ee_        n# e$ r Y nw xY w G d de          Zd ZddZerddZdS dS )   )PYQT5PYQT6PYSIDE2PYSIDE6    )*loadUi
loadUiType)QMetaObject)	QUiLoaderr
   )r   )Element)	compileUi)UIParserc                       e Zd Zd ZdS )ElemPatchedc                      | j         |i |S N)iter)selfargskwargss      (lib/python3.11/site-packages/qtpy/uic.pygetiteratorzElemPatched.getiterator\   s    $49d5f555    N)__name__
__module____qualname__r    r   r   r   r   [   s#        6 6 6 6 6r   r   c                 F    |                      t          |                    S r   )_readResourcesr   )r   elems     r   readResourcesr"   _   s    **;t+<+<===r   c                   "    e Zd ZdZddZddZdS )UiLoadera  
        Subclass of :class:`~PySide.QtUiTools.QUiLoader` to create the user
        interface in a base instance.

        Unlike :class:`~PySide.QtUiTools.QUiLoader` itself this class does not
        create a new instance of the top-level widget, but creates the user
        interface in an existing instance of the top-level class if needed.

        This mimics the behaviour of :func:`PyQt4.uic.loadUi`.
        Nc                 b    t          j        | |           || _        |	i | _        dS || _        dS )ah  
            Create a loader for the given ``baseinstance``.

            The user interface is created in ``baseinstance``, which must be an
            instance of the top-level class in the user interface to load, or a
            subclass thereof.

            ``customWidgets`` is a dictionary mapping from class name to class
            object for custom widgets. Usually, this should be done by calling
            registerCustomWidget on the QUiLoader, but with PySide 1.1.2 on
            Ubuntu 12.04 x86_64 this causes a segfault.

            ``parent`` is the parent object of this loader.
            N)r   __init__baseinstancecustomWidgets)r   r'   r(   s      r   r&   zUiLoader.__init__s   sA      t\222 ,D$%'"""%2"""r    c                 D   || j         r| j         S ||                                 v s|dk    rt          j        | |||          }n>	  | j        |         |          }n&# t
          $ r}t          d| d          |d}~ww xY w| j         rt          | j         ||           |S )z
            Function that is called for each widget defined in ui file,
            overridden here to populate baseinstance instead.
            NLinezNo custom widget z found in customWidgets)r'   availableWidgetsr   createWidgetr(   KeyErrorNoCustomWidgetsetattr)r   
class_nameparentnamewidgeterrors         r   r-   zUiLoader.createWidget   s     ~$"3~ (( T224444
f8L8L"/	 !;T/
;FCCFF ! ! !(1J 1 1 1  !!!   9 )4888Ms   A 
B 'A;;B r   )Nr)   )r   r   r   __doc__r&   r-   r   r   r   r$   r$   g   sF        		 			3 	3 	3 	32(	 (	 (	 (	 (	 (	r   r$   c                 j   ddl }ddlm}  |            }|                    |           }|                    d          }|i S i }t          |          D ]^}|                    d          j        }|                    d          j        }	|                    |	          }
t          |
|          ||<   _|S )z
        This function is used to parse a ui file and look for the <customwidgets>
        section, then automatically load all the custom widget classes.
        r   NElementTreecustomwidgetsclassheader)		importlibxml.etree.ElementTreer9   parsefindlisttextimport_modulegetattr)ui_filer=   r9   etreeuicustom_widgetscustom_widget_classescustom_widgetcw_class	cw_headermodules              r   _get_custom_widgetsrN      s     	555555 [[!! 11!I "!.11 	H 	HM$))'227H%**8449I,,Y77F.5fh.G.G!(++$$r   Nc                     t          |           }t          ||          }||                    |           |                    |           }t	          j        |           |S )aj  
        Dynamically load a user interface from the given ``uifile``.

        ``uifile`` is a string containing a file name of the UI file to load.

        If ``baseinstance`` is ``None``, the a new instance of the top-level
        widget will be created. Otherwise, the user interface is created within
        the given ``baseinstance``. In this case ``baseinstance`` must be an
        instance of the top-level widget class in the UI file to load, or a
        subclass thereof. In other words, if you've created a ``QMainWindow``
        interface in the designer, ``baseinstance`` must be a ``QMainWindow``
        or a subclass thereof, too. You cannot load a ``QMainWindow`` UI file
        with a plain :class:`~PySide.QtGui.QWidget` as ``baseinstance``.

        :method:`~PySide.QtCore.QMetaObject.connectSlotsByName()` is called on
        the created user interface, so you can implemented your slots according
        to its conventions in your widget class.

        Return ``baseinstance``, if ``baseinstance`` is not ``None``. Otherwise
        return the newly created instance of the user interface.
        )rN   r$   setWorkingDirectoryloadr   connectSlotsByName)uifiler'   workingDirectoryr(   loaderr4   s         r   r	   r	      sb    0 ,F33,66'&&'7888V$$&v...r   Fc                 $   ddl }ddlm} ddlm} ddlm}  |            }|                    |           }|                    d          	                    d          }|                    d          j
        }	t          | d	
          5 }
 |            }i }t          |
|d|           t          |                                dd          }t          ||           |d|	z           }	t!          ||          }ddd           n# 1 swxY w Y   |	|fS )aV  Load a .ui file and return the generated form class and
            the Qt base class.

            The "loadUiType" command convert the ui file to py code
            in-memory first and then execute it in a special frame to
            retrieve the form_class.

            Credit: https://stackoverflow.com/a/14195313/15954282
            r   N)StringIOr8   r   )	QtWidgetsr4   r;   zutf-8)encoding)indentfrom_importsz<string>execzUi_%s)sysiorW   r>   r9   r)   rX   r?   r@   getrB   openr   compilegetvaluer\   rD   )rS   r[   r]   rW   r9   rX   rF   rG   widget_class
form_classfdcode_streamframepyc
base_classs                  r   r
   r
      sz    JJJ######999999######  KMMEV$$B778,,0099L)).Jfw/// >2&hjj"k!,OOOOk2244j&IIS%    #7Z#78
$Y==
> > > > > > > > > > > > > > > z))s   	A.DD
D)NN)F)r)   r   r   r   r   	PyQt6.uic	PyQt5.uic__all__PySide6.QtCorer   PySide6.QtUiToolsr   r
   PySide2.QtCorePySide2.QtUiToolsr>   r   
pyside2uicr   pyside2uic.uiparserr   r   r"   r    ImportErrorr$   rN   r	   r   r   r   <module>rt      s   , , , , , , , , , , , , \*
 Y* &G@  ......;;;;;;;;;	 ......//////	555555,,,,,,
 5444446 6 6 6 6g 6 6 6> > > '/&<H#%2H"" 	 	 	D	M M M M M9 M M M^% % %>! ! ! !F  '*%	* %	* %	* %	* %	* %	*'* '*s   6A8 8B ?B 