a
    ¢–Be%  ã                   @   s`   d dl Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZ G d	d
„ d
eƒZdS )é    Né   )Ú
Properties)ÚUIParseré   )Ú	qtproxies)ÚcreateCodeIndenterÚgetIndenterÚ
write_code)ÚCompilerCreatorPolicyc                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )Ú
UICompilerc                 C   s   t  | tjtjtjtƒ ¡ d S ©N)r   Ú__init__r   ZQtCoreZQtGuiZ	QtWidgetsr
   ©Úself© r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/PyQt5/uic/Compiler/compiler.pyr   3   s    ÿzUICompiler.__init__c                 C   s   g t _t | ¡ d S r   )r   Úi18n_stringsr   Úresetr   r   r   r   r   7   s    zUICompiler.resetc                 C   s
   |t _d S r   )r   Zi18n_context)r   Úcontextr   r   r   Ú
setContext;   s    zUICompiler.setContextc                 C   s„   t ƒ }d|_| d¡ | d¡ | d¡ | d| j ¡ | ¡  | d| ¡ | ¡  | jj||dddd	�}||_d
| j |_|S )Nr   z*from PyQt5 import QtCore, QtGui, QtWidgetsÚ zclass Ui_%s(object):zdef setupUi(self, %s):r   FT)Zis_attributeZno_instantiationzUi_%s)	r   ÚlevelÚwriteZuinameÚindentÚfactoryZcreateQObjectÚ	baseclassÚuiclass)r   Ú	classnameÚ
widgetnameÚindenterÚwr   r   r   ÚcreateToplevelWidget>   s     


þzUICompiler.createToplevelWidgetc                 C   s$   t dƒ t d| j ƒ t | ¡ d S )Nr   zself.retranslateUi(%s))r	   ÚtoplevelWidgetr   ÚsetDelayedPropsr   r   r   r   r#   Q   s    zUICompiler.setDelayedPropsc                 C   s†   t ƒ }d|_| d¡ | d| j ¡ | ¡  tjrV| d¡ tjD ]}| |¡ qDn
| d¡ | ¡  | ¡  | j| _	| j	 
¡  d S )Nr   r   zdef retranslateUi(self, %s):z._translate = QtCore.QCoreApplication.translateÚpass)r   r   r   r"   r   r   r   ÚdedentÚ	resourcesÚ
_resourcesÚsort)r   r   Úsr   r   r   ÚfinalizeV   s    



zUICompiler.finalizec                 C   sb   t |ƒ |  ||¡}| jj ¡  | jD ]&}|r@td||f ƒ q&td| ƒ q&t|ƒ|j|j	dœS )Nzfrom %s import %sz	import %s)r   r   r   )
r   Úparser   Z_cpolicyZ_writeOutImportsr'   r	   Ústrr   r   )r   Zinput_streamZoutput_streamZfrom_importsZresource_suffixZimport_fromr    Úresr   r   r   Ú	compileUim   s    
þzUICompiler.compileUiN)
Ú__name__Ú
__module__Ú__qualname__r   r   r   r!   r#   r*   r.   r   r   r   r   r   2   s   r   )ÚsysÚ
propertiesr   Zuiparserr   r   r   r   r   r   r	   Zqobjectcreatorr
   r   r   r   r   r   Ú<module>)   s   