
    dne                         d Z ddlZddlmZmZmZmZ ddlmZ e	fZ
d ZddZdZdd	Zdd
Zdddej                   fdZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZd Zy)z
Compatibility functions
    N   )PYQT5PYQT6PYSIDE2PYSIDE6)QFileDialogc                 "    t        | t              S )zZReturn True if `obj` is a text string, False if it is anything else,
    like binary data.)
isinstancestrobjs    +lib/python3.12/site-packages/qtpy/compat.pyis_text_stringr      s     c3    c                 X    |t        |       S t        | t               r| S t        | |      S )z&Convert `obj` to (unicode) text string)r   r
   )r   encodings     r   to_text_stringr      s-    3x#s
sHr   Fc                     | S )zConvert Python object to QVariant
    This is a transitional function from PyQt API#1 (QVariant exist)
    to PyQt API#2 and Pyside (QVariant does not exist) r   s    r   to_qvariantr   ,   s	     Jr   c                     | S )zConvert QVariant object to Python object
    This is a transitional function from PyQt API #1 (QVariant exist)
    to PyQt API #2 and Pyside (QVariant does not exist)r   )qobjpytypes     r   from_qvariantr   3   s	     Kr    c                    t         j                  dk(  r7t         j                  t         j                  }}d\  t         _        t         _        	 t	        j
                  | |||      }t         j                  dk(  rct         _        t         _        	 t        |      st        |      }|S # t         j                  dk(  rct         _        t         _        w w xY w)zWrapper around QtGui.QFileDialog.getExistingDirectory static method
    Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0win32NN)sysplatformstdoutstderrr   getExistingDirectoryr   r   )parentcaptionbasediroptions_temp1_temp2results          r   getexistingdirectoryr+   =   s     ||wSZZ!+
CJ
411	
 <<7"%+V"CJ
&!'M <<7"%+V"CJ
 #s   B' '-Cc                 d   |t        j                  d      }t        t         |       }t        j                  dk(  r7t        j
                  t        j                  }	}d\  t        _        t        _         |||||||      }
t        j                  dk(  r	ct        _        t        _        |
\  }}||fS )Nr   r   r   )r   Optiongetattrr   r    r!   r"   )attrr$   r%   r&   filtersselectedfilterr'   funcr(   r)   r*   outputs               r   _qfiledialog_wrapperr4   [   s     $$Q';%D ||wSZZ!+
CJ&'7G^WMF
||w!'
CJ#FN >!!r   c           	      &    t        d| |||||      S )zWrapper around QtGui.QFileDialog.getOpenFileName static method
    Returns a tuple (filename, selectedfilter) -- when dialog box is canceled,
    returns a tuple of empty strings
    Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0getOpenFileNamer$   r%   r&   r0   r1   r'   r4   r7   s         r   getopenfilenamer9   y   &      % r   c           	      &    t        d| |||||      S )a   Wrapper around QtGui.QFileDialog.getOpenFileNames static method
    Returns a tuple (filenames, selectedfilter) -- when dialog box is canceled,
    returns a tuple (empty list, empty string)
    Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0getOpenFileNamesr7   r8   r7   s         r   getopenfilenamesr=      s&      % r   c           	      &    t        d| |||||      S )zWrapper around QtGui.QFileDialog.getSaveFileName static method
    Returns a tuple (filename, selectedfilter) -- when dialog box is canceled,
    returns a tuple of empty strings
    Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0getSaveFileNamer7   r8   r7   s         r   getsavefilenamer@      r:   r   c                     t         st        rddlm} |j	                  |        S t
        st        rddlm} |j                  |       S y)zgWrapper around sip.isdeleted and shiboken.isValid which tests whether
    an object is currently alive.r   )sip)shibokenN)	r   r   r   rB   	isdeletedr   r   rC   isValid)r   rB   rC   s      r   isaliverF      s:     ==%%%'$$r   )Nr   )Nr   r   r   r   N)__doc__r   r   r   r   r   r   	QtWidgetsr   r   
TEXT_TYPESr   r   
PYQT_API_1r   r   ShowDirsOnlyr+   r4   r9   r=   r@   rF   r   r   r   <module>rL      s   
   #V
  
 $$	@ "> 0 0 0r   