Sindbad~EG File Manager
�
&Μg[:��� gd�ZddlZddlZddlmZmZmZmZmZm Z m
Z
mZmZm
Z
mZmZmZmZmZmZddlmZddlmZddlmZiZGd�d�ZGd �d
e�ZGd�de�ZGd
�dej*�ZGd�de�ZGd�de�ZGd�dej*�Z d�Z!d�Z"d�Z#dd�Z$dd�Z%dd�Z&d�Z'd�Z(e)dk(re(�yy) )
�
FileDialog�LoadFileDialog�SaveFileDialog�Open�SaveAs� Directory�askopenfilename�asksaveasfilename�askopenfilenames�askopenfile�askopenfiles�
asksaveasfile�askdirectory�N)�Frame�LEFT�YES�BOTTOM�Entry�TOP�Button�Tk�X�Toplevel�RIGHT�Y�END�Listbox�BOTH� Scrollbar)�Dialog)�commondialog)�
_setup_dialogc��eZdZ dZdd�Zejdddfd�Zdd�Zd�Z d �Z
d
�Zd�Zd�Z
d
�Zdd�Zd�Zd�Zdd�Zd�Zd�Zy)rzFile Selection DialogNc�*�|�|j}||_d|_t|�|_|jj|�|jj|�t
|j�t|j�|_|jjtt��t|j�|_
|jjtt��|jjd|j�t|j�|_|j jt"t��|j jd|j$�t|j�|_|j&jt(t*��t-|j&�|_|j.jt0t2��t5|j&d|j.df��|_|j6jt0t(t*��|j6j9�}|j6j9|dd|ddz�|j6jd |j:�|j6jd
|j<�|j.j?|j6df��t-|j&�|_ |j@jtBt2��t5|j&d|j@df��|_"|jDjtBt(t*��|j@j?|jDdf��|jDj9�}|jDj9|dd|ddz�|jDjd |jF�|jDjd
|jH�tK|jd
|jL��|_'|jNjtB��tK|jd|j$��|_(|jPjtBt(��tK|jd|jR��|_*|jTjt0��|jjWd|jR�|jjd|jR�|jjd|jR�y)N)�side�fillz<Return>)�expandr&r�set)�exportselection�yscrollcommand)r%r'r&�z<ButtonRelease-1>z<Double-ButtonRelease-1>�yview)�command�OK)�textr-)r%�Filter)r%r'�Cancel�WM_DELETE_WINDOWz<Alt-w>z<Alt-W>),�title�master� directoryr�top�iconnamer"r�botframe�packrrr� selection�bind�ok_event�filterr�filter_command�midframerrr�filesbarrrr�files�bindtags�files_select_event�files_double_event�config�dirsbarr�dirs�dirs_select_event�dirs_double_eventr�
ok_command� ok_button�
filter_button�cancel_command�
cancel_button�protocol)�selfr4r3�btagss �//usr/local/lib/python3.12/tkinter/filedialog.py�__init__zFileDialog.__init__:s����=�$�*�*�%��������F�#��������u�������%� ��d�h�h���d�h�h���
��
�
����Q��/��t�x�x����������a��0������J��
�
�6��D�H�H�o��������c���*�������T�%8�%8�9��d�h�h���
��
�
���#�D��1�!�$�-�-�0��
��
�
����A��.��T�]�]�A�-1�]�]�E�,B�D��
��
�
���U�3�T��:��
�
�#�#�%���
�
���E�!�"�I��b�q� �1�2��
�
���+�T�-D�-D�E��
�
���2�D�4K�4K�L��
�
���d�j�j�'�%:��;� ����/��������t�!��,��D�M�M�1�,0�L�L�%�+@�B�� �� � ���D��4��8������T�Y�Y��$8��9�� � �"�"�$��� � ���5���9�u�R�a�y�0�1�� � ���*�D�,B�,B�C�� � ���1�4�3I�3I�J���
�
�&*�)-���:���
�������&�#�D�M�M�)1�,0�,?�,?�A���
�����T�#��6�#�D�M�M�)1�,0�,?�,?�A���
�����U��+������,�d�.A�.A�B����
�
�i��!4�!4�5����
�
�i��!4�!4�5��*�c�b�|r|tvrt|\|_}nmtjj |�}tjj|�r||_n'tjj
|�\|_}|j|j|�|j|�|j�|jj�|jj�|jj�d|_|j j#�|rS|j%�\}}|jr)tjj'|j�}||ft|<|jj)�|jS�N)�dialogstatesr5�os�path�
expanduser�isdir�split�
set_filter�
set_selectionr>r:� focus_setr6�wait_visibility�grab_set�howr4�mainloop�
get_filter�dirname�destroy)rP�dir_or_file�pattern�default�keyr5s rR�goz
FileDialog.gozs-���3�,�&�&2�3�&7�#�D�N�G��'�'�,�,�[�9�K��w�w�}�}�[�)�!,���*,�'�'�-�-��*D�'�����������0����7�#�������� � �"���� � �"�����������������!%���!2��I�w��x�x��G�G�O�O�D�H�H�5� � )�7� 2�L����������x�x�rTc�F�||_|jj�yrX)rdr4�quit)rPrds rRrozFileDialog.quit�s����������rTc�$�|j�yrX)r>�rP�events rRrIzFileDialog.dirs_double_event�s�����rTc��|j�\}}|jjd�}tjjtjj
|j|��}|j||�y�N�active) rfrG�getrZr[�normpath�joinr5r_)rPrr�dir�pat�subdirs rRrHzFileDialog.dirs_select_event�sY���?�?�$���S������x�(���g�g���r�w�w�|�|�D�N�N�F�C�D������S�!rTc�$�|j�yrX�rJrqs rRrDzFileDialog.files_double_event�������rTc�\�|jjd�}|j|�yrt)rArvr`)rPrr�files rRrCzFileDialog.files_select_event�s"���z�z�~�~�h�'�����4� rTc�$�|j�yrXr}rqs rRr<zFileDialog.ok_event�r~rTc�B�|j|j��yrX)ro�
get_selection�rPs rRrJzFileDialog.ok_command�s��� � �$�$�$�&�'rTc���|j�\}} tj|�}||_|j||�|j�tjg}g}|D]{}tjj||�}tjj|�r|j|��Ttj||�s�k|j|��}|jj!dt"�|D]"}|jj%t"|��$|j&j!dt"�|D]"}|j&j%t"|��$tjj)|j+��\} }
|
tj,k(rd}
|j/|
�y#t$r|jj�YywxYw)NrrV)rfrZ�listdir�OSErrorr4�bellr5r_�sort�pardirr[rxr]�append�fnmatchrG�deleter�insertrAr^r��curdirr`)rPrrryrz�names�subdirs�
matchingfiles�name�fullname�head�tails rRr>zFileDialog.filter_command�sq���?�?�$���S� ��J�J�s�O�E��������S�!�
�
�
���9�9�+���
��D��w�w�|�|�C��.�H��w�w�}�}�X�&����t�$�����s�+��$�$�T�*��
� � ����C� ��D��I�I���S�$�'���
�
���!�S�!�!�D��J�J���c�4�(�"��W�W�]�]�4�#5�#5�#7�8�
��d��2�9�9��R�d����4� ��-� ��K�K����� �s�G�#G1�0G1c�\�|jj�}tjj |�}|ddtj
k(stjj
|�r tjj|d�}tjj|�S)N���rU) r=rvrZr[r\�sepr]rxr^)rPr=s rRrfzFileDialog.get_filter�sn�������"�����#�#�F�+���"�#�;�"�&�&� �B�G�G�M�M�&�$9��W�W�\�\�&�#�.�F��w�w�}�}�V�$�$rTc�x�|jj�}tjj |�}|SrX)r:rvrZr[r\�rPr�s rRr�zFileDialog.get_selection�s-���~�~�!�!�#���w�w�!�!�$�'���rTc�$�|j�yrX)rorqs rRrMzFileDialog.cancel_command�s��� � �rTc��tjj|�sV tj�}|r?tjj||�}tjj
|�}|jjdt�|jjttjj|xstj|xsd��y#t$rd}Y��wxYw)NrrU)rZr[�isabs�getcwdr�rxrwr=r�rr�r�)rPryrz�pwds rRr_zFileDialog.set_filter�s����w�w�}�}�S�!�
��i�i�k����g�g�l�l�3��,���g�g�&�&�s�+�������1�c�"������3������S�-=�B�I�I�s�z�c� J�K��
�
���
�s�C+�+C9�8C9c���|jjdt�|jjttj
j
|j|��y)Nr)r:r�rr�rZr[rxr5r�s rRr`zFileDialog.set_selection�s=�������a��%������c�2�7�7�<�<�����#E�FrTrX)�__name__�
__module__�__qualname__r3rSrZr�rmrorIrHrDrCr<rJr>rfr�rMr_r`�rTrRrr!sk���*
$�E�>6�@ �Y�Y��R�T��2��"��!��(�!�8%��
�
L�GrTrc��eZdZ dZd�Zy)rzLoad File Selection Dialogc��|j�}tjj|�s|jj�y|j
|�yrX)r�rZr[�isfiler4r�ror�s rRrJzLoadFileDialog.ok_command�s;���!�!�#���w�w�~�~�d�#��K�K�����I�I�d�OrTN�r�r�r�r3rJr�rTrRrr�s��B�(�E�rTrc��eZdZ dZd�Zy)rzSave File Selection Dialogc��|j�}tjj|�ritjj |�r|j
j
�yt|jdd|�d�ddd��}|jdk7r]ytjj|�\}}tjj |�s|j
j
�y|j|�y) Nz Overwrite Existing File QuestionzOverwrite existing file �?� questheadr+)�Yesr1)r3r/�bitmaprk�stringsr)r�rZr[�existsr]r4r�r r6�numr^ro)rPr��dr�r�s rRrJzSaveFileDialog.ok_command�s����!�!�#��
�7�7�>�>�$���w�w�}�}�T�"���� � �"���t�x�x�?�=A�C�)� �0�2�A��u�u��z�������t�,�J�D�$��7�7�=�=��&���� � �"��� � �$�rTNr�r�rTrRrr�s��J�(�E�rTrc��eZdZd�Zd�Zy)�_Dialogc�n� t|jd�|jd<y#t$rYywxYw)N� filetypes)�tuple�options�KeyErrorr�s rR�_fixoptionsz_Dialog._fixoptions2s5�� �(-�d�l�l�;�.G�(H�D�L�L��%��� �� �s�%(� 4�4c���|rM |j}tjj |�\}}||j
d<||j
d<||_|S#t$rY�TwxYw)N�
initialdir�initialfile)�string�AttributeErrorrZr[r^r��filename)rP�widget�resultr[r�s rR�
_fixresultz_Dialog._fixresult9sg���
����������v�.�J�D�$�)-�D�L�L��&�*.�D�L�L��'���
��
��"�
��
�s�A� A%�$A%N)r�r�r�r�r�r�rTrRr�r�0s���
rTr�c��eZdZ dZd�Zy)r�tk_getOpenFilec
��t|t�r\t|D�cgc]}t|d|���c}�}|r4tjj|d�\}}||jd<|S|jj�s9d|jvr+|j||jj|��Stj|||�Scc}w)Nr�rr��multiple)�
isinstancer��getattrrZr[r^r��tk�wantobjectsr�� splitlistr�)rPr�r��rr[r�s rRr�zOpen._fixresultQs����f�e�$��V�D�V��G�A�x��3�V�D�E�F���W�W�]�]�6�!�9�5�
��d�-1����\�*��M��y�y�$�$�&�:����+E��?�?�6�6�9�9�+>�+>�v�+F�G�G��!�!�$���7�7��Es�CN�r�r�r�r-r�r�rTrRrrLs�� ��G�8rTrc��eZdZ dZy)r�tk_getSaveFileN)r�r�r�r-r�rTrRrr`s
��#��GrTrc��eZdZ dZd�Zy)r�tk_chooseDirectoryc�n�|r |j}||jd<||_|S#t$rY�#wxYw)Nr�)r�r�r�r5)rPr�r�s rRr�zDirectory._fixresultlsC���
�����
*0�D�L�L��&�����
��
"�
��
�s�(� 4�4Nr�r�rTrRrrgs���"�G�rTrc�6� tdi|��j�S�Nr��r�show�r�s rRrr}s�� ��?�'�?���!�!rTc�6� tdi|��j�Sr�)rr�r�s rRr r �s��#���G��!�!�#�#rTc�@� d|d<tdi|��j�S)Nr+r�r�r�r�s rRr
r
�s(���
�G�J���?�'�?���!�!rTc�T� tdi|��j�}|rt||�Syr�)rr��open��moder�r�s rRrr�s,��>���g��#�#�%�H���H�d�#�#�rTc�n� tdi|��}|r&g}|D]}|jt||���|}|Sr�)r
r�r�)r�r�rA�ofilesr�s rRrr�sE���
�'�w�'�E�����H��M�M�$�x��.�/�����LrTc�T� tdi|��j�}|rt||�Syr�)rr�r�r�s rRr
r
�s.��A�� �� �%�%�'�H���H�d�#�#�rTc�6� tdi|��j�Sr�)rr�r�s rRrr�s��3���w��$�$�&�&rTc�� t�}|j�t|�}|jd��}t |�}|jd��}t||�d} ddl}|j|jd�|j|j�}tdg��} t|d�}|j�td
|j#|��t%�} td| j#|��y#ttf$rY�|wxYw#t $r }td �t|�Yd}~�zd}~wwxYw)N�test)rlzutf-8rrV)z all filesrU)r�r�zCould not open File: r��saveas)r�withdrawrrmr�print�locale� setlocale�LC_ALL�nl_langinfo�CODESET�ImportErrorr�rr��close�
BaseException�encoder )
�root�fd�loadfile�savefile�encr��openfilename�fp�exc�saveasfilenames
rRr�r��s&���
�4�D��M�M�O� �� �B��u�u��u� �H� �� �B��u�u��u� �H� �(�H���C�
��������r�*�� � ����0��!�,>�+?�@�L����S�!��
���
�
�&�,�%�%�c�*�+�%�&�N� �(�N�)�)�#�.�/��%
��(�
��
����
�%�&�
�c�
�
���s*�%;D�.D �D�D� E �)E�E �__main__)r�)�w)*�__all__r�rZ�tkinterrrrrrrrrrrrrrrrr�tkinter.dialogr r!�tkinter.simpledialogr"rYrrrr�rrrrr r
rrr
rr�r�r�rTrR�<module>rs����K��
� ������"� �.���EG�EG�P�Z���Z��r�l�!�!��88�7�8�(�W����#�#��,"�$�"���"�'�(0�V�z���F�rT
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists