
    
8dZ	                     8    d Z ddlmZmZmZmZ ddZd ZddZdS )zA Defines utility functions for working with SVG documents in Qt.
    )QtCoreQtGuiQtSvg	QtWidgetsNc                 (   t          | t                    r|                     d          } t          j        |d          }|                    t          j        j                   |                    d           |                    d           |	                                rp|
                                d         }t          |d          }	 |                    |            |                                 n# |                                 w xY w|S dS )aj   Prompts the user to save an SVG document to disk.

    Parameters
    ----------
    string : basestring
        A Python string containing a SVG document.

    parent : QWidget, optional
        The parent to use for the file dialog.

    Returns
    -------
    The name of the file to which the document was saved, or None if the save
    was cancelled.
    utf-8zSave SVG DocumentsvgzSVG document (*.svg)r   wbN)
isinstancestrencoder   QFileDialogsetAcceptMode
AcceptSavesetDefaultSuffixsetNameFilterexec_selectedFilesopenwriteclose)stringparentdialogfilenamefs        -lib/python3.11/site-packages/qtconsole/svg.pysave_svgr      s      &# (w''"6+>??F
.9:::
E"""
/000||~~ ''))!,4  	GGFOOOGGIIIIAGGIIII4s   C7 7Dc                    t          | t                    r|                     d          } t          j                    }|                    d|            t          j                                        	                    |           dS )z Copy a SVG document to the clipboard.

    Parameters
    ----------
    string : basestring
        A Python string containing a SVG document.
    r   zimage/svg+xmlN)
r   r   r   r   	QMimeDatasetDatar   QApplication	clipboardsetMimeData)r   	mime_datas     r   svg_to_clipboardr&   )   st     &# (w'' ""Iov...$$&&229=====    c                    t          | t                    r|                     d          } t          j        t          j        |                     }|                                st          d          ||	                                }t          j        |t          j        j                  }|                    d           t          j        |          }|                    |           |S )a   Convert a SVG document to a QImage.

    Parameters
    ----------
    string : basestring
        A Python string containing a SVG document.

    size : QSize, optional
        The size of the image that is produced. If not specified, the SVG
        document's default size is used.
    
    Raises
    ------
    ValueError
        If an invalid SVG string is provided.

    Returns
    -------
    A QImage of format QImage.Format_ARGB32.
    r   zInvalid SVG data.Nr   )r   r   r   r   QSvgRendererr   
QByteArrayisValid
ValueErrordefaultSizer   QImageFormat_ARGB32fillQPainterrender)r   sizerendererimagepainters        r   svg_to_imager7   8   s    * &# (w''!&"3F";";<<H .,---|##%%Lu|9::E	JJqMMMnU##GOOGLr'   )N)	__doc__qtpyr   r   r   r   r   r&   r7    r'   r   <module>r;      sw     1 0 0 0 0 0 0 0 0 0 0 0   B> > >" " " " " "r'   