Hacked By AnonymousFox

Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/query.cpython-36.pyc

3

� f�0�@s�dZddlZddlZddlmZmZddlmZmZm	Z	m
Z
mZddlm
Z
mZmZmZddlmZddlmZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zedkr�ddlmZedddd�ddlmZeee�dS)a�
Dialogs that query users and verify the answer before accepting.
Use ttk widgets, limiting use to tcl/tk 8.5+, as in IDLE 3.6+.

Query is the generic base class for a popup dialog.
The user must either enter a valid answer or close the dialog.
Entries are validated when <Return> is entered or [Ok] is clicked.
Entries are ignored when [Cancel] or [X] are clicked.
The 'return value' is .result set to either a valid answer or None.

Subclass SectionName gets a name for a new config file section.
Configdialog uses it for new highlight theme and keybinding set names.
Subclass ModuleName gets a name for File => Open Module.
Subclass HelpSource gets menu item and path for additions to Help menu.
�N)�
executable�platform)�Toplevel�	StringVar�W�E�S)�Frame�Button�Entry�Label)�
filedialog)�FontcsbeZdZdZdiddd�dd�Zdd�Zdd
d�Zdd
�Zddd�Zddd�Z	�fdd�Z
�ZS)�QueryzoBase class for getting verified answer from a user.

    For this base class, accept any non-blank string.
    �F)�text0�
used_names�_htest�_utestc	
CsXtj||�|j�||_|j|�||_||_||_|j|�|j	�|j
jdd�}|dkr�y|j
jdd|jdd�WnYnX|j
d|j�|j
d	|j�|jd
|j�|j
d|j�|j
d|j�|jd
d
d�|j�|j�|jd|j�|j�d|j�d|j�|�s2|j�d|j�dndf�|�sT|j�|j�dS)a�Create popup, do not return until tk widget destroyed.

        Additional subclass init must be done before calling this
        unless  _utest=True is passed to suppress wait_window().

        title - string, title of popup dialog
        message - string, informational message to display
        text0 - initial value for entry
        used_names - names already in use
        _htest - bool, change box location when running htest
        _utest - bool, leave window hidden and not modal
        �tk�windowingsystemZaquaz!::tk::unsupported::MacWindowStyleZstyleZ
moveableModalrz<Command-.>z<Key-Escape>ZWM_DELETE_WINDOWz<Key-Return>z
<KP_Enter>F)Zheight�widthz+%d+%d��N)r�__init__Zwithdraw�parent�title�messagerrZ	transientZgrab_setrZcallZ_wZbind�cancelZprotocol�okZ	resizable�create_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	deiconifyZwait_window)	�selfrrrrrrrr�r"�2/opt/alt/python36/lib64/python3.6/idlelib/query.pyr%sB


*zQuery.__init__cCs.t|dd�|_}|jdddd�|jddd�t|dd	|jd
�}t||j�|_t	|d|jd�|_
|j
j�td
d|j
d�|_t|dd|jd�|_t|dd|jd�|_t|d|jd�|_|jddddtd�|j
jddddttddgd�|jjddddttd�|jjdddd�|jjdddd�dS)N�
)ZpaddingrZnews)�column�row�sticky�)Zweight�w�left)�anchor�justify�text�)r�textvariableZ
TkCaptionFontT)�name�exists�root� �red)r-�
foreground�fontZOKZactive)r-�default�commandZCancel)r-r8��)r%r&�
columnspan�padxr')r%r&r;r<r'�padyr�c)r%r&r<)r	�frame�gridZgrid_columnconfigurerrrrZentryvarr�entry�	focus_setrr�
error_font�entry_errorr
rZ	button_okrZ
button_cancelrr)r!r?Z
entrylabelr"r"r#r Ws.

zQuery.create_widgetsNcCsd||p|jd<dS)NzERROR: r-)rD)r!rZwidgetr"r"r#�	showerrorsszQuery.showerrorcCs.d|jd<|jj�j�}|s*|jd�dS|S)zReturn non-blank entry or None.rr-zblank line.N)rDrA�get�striprE)r!rAr"r"r#�entry_okws

zQuery.entry_okcCs.|j�}|dk	r ||_|j�n
|jj�dS)z�If entry is valid, bind it to 'result' and destroy tk widget.

        Otherwise leave dialog open for user to correct entry or cancel.
        N)rH�result�destroyrArB)r!�eventrAr"r"r#r�s

zQuery.okcCsd|_|j�dS)z0Set dialog result to None and destroy tk widget.N)rIrJ)r!rKr"r"r#r�szQuery.cancelcs|j�t�j�dS)N)Zgrab_release�superrJ)r!)�	__class__r"r#rJ�sz
Query.destroy)N)N)N)�__name__�
__module__�__qualname__�__doc__rr rErHrrrJ�
__classcell__r"r")rMr#r s1
	

rcs0eZdZdZddd��fdd�
Zdd�Z�ZS)�SectionNamez*Get a name for a config file section name.F)rrcst�j||||||d�dS)N)rrr)rLr)r!rrrrrr)rMr"r#r�szSectionName.__init__cCs`d|jd<|jj�j�}|s*|jd�dSt|�dkrD|jd�dS||jkr\|jd�dS|S)z2Return sensible ConfigParser section name or None.rr-zno name specified.Nr.z"name is longer than 30 characters.zname is already in use.)rDrArFrGrE�lenr)r!r0r"r"r#rH�s




zSectionName.entry_ok)rNrOrPrQrrHrRr"r")rMr#rS�srScs0eZdZdZddd��fdd�
Zdd�Z�ZS)�
ModuleNamez-Get a module name for Open Module menu entry.F)rrcst�j||||||d�dS)N)rrr)rLr)r!rrrrrr)rMr"r#r�szModuleName.__init__cCs�d|jd<|jj�j�}|s*|jd�dSytjj|�}Wn2tt	fk
rl}z|jt
|��dSd}~XnX|dkr�|jd�dSt|jtj
j�s�|jd�dSy|jj|�}Wn"tk
r�|jd|d�dSX|S)	z0Return entered module name as file path or None.rr-zno name specified.Nzmodule not foundznot a source-based modulez$loader does not support get_filename)r)rDrArFrGrE�	importlib�util�	find_spec�
ValueError�ImportError�str�
isinstance�loader�abc�SourceLoader�get_filename�AttributeError)r!r0�spec�msgZ	file_pathr"r"r#rH�s.



zModuleName.entry_ok)rNrOrPrQrrHrRr"r")rMr#rU�srUcs`eZdZdZddiddd��fdd�
Z�fdd�Zd	d
�Zdd�Zej	Z
d
d�Zdd�Z	�ZS)�
HelpSourcez,Get menu name and help source for Help menu.rF)�menuitem�filepathrrrc		s(||_d}t�j|||||||d�dS)z�Get menu entry and url/local file for Additional Help.

        User enters a name for the Help resource and a web url or file
        name. The user can browse for the file.
        zName for item on Help menu:)rrrrN)rfrLr)	r!rrrerfrrrr)rMr"r#r�s
zHelpSource.__init__cs�t�j�|j}t|dddd�}t||j�|_t||jdd�|_t	|dd|j
d	�}t|d
d|jd�|_|j
d
ddddd
gtd�|jj
d
dddttdd
gd�|j
dddttd�|jj
d
dddttd�dS)Nr)r*z,Help File Path: Enter URL or browse for file)r+r,r-�()r/rZBrowse�)r-rr8r3r4)r-r5r6rr$r9r:)r%r&r;r<r=r'�r)r%r&r;r<r'r=)r%r&r<r'�)r%r&r;r<r')rLr r?rrrf�pathvarr�pathr
�browse_filerC�
path_errorr@rrr)r!r?Z	pathlabelZbrowse)rMr"r#r �s"

zHelpSource.create_widgetscCstj||d�j||d�S)N)r�	filetypes)Z
initialdirZinitialfile)r
ZOpenZshow)r!roZinitdirZinitfiler"r"r#�askfilename�szHelpSource.askfilenamecCs�dddddg}|jj�}|r.tjj|�\}}nHd}tdd�d
krntjjtjjt�d�}tjj	|�svtj
�}ntj
�}|j|||�}|r�|jj|�dS)N�
HTML Files�*.htm *.html�TEXT�	PDF Files�*.pdf�Windows Help Files�*.chm�
Text Files�*.txt�	All Files�*r9�winZDoc)rqrrrs)rtrurs)rvrw)rxryrs)rzr{)
rkrF�osrl�splitr�join�dirnamer�isdir�getcwdrp�set)r!rorl�dir�base�filer"r"r#rms"

zHelpSource.browse_filecCs||jj�j�}|s$|jd|j�dS|jd
�sx|dd�dkrJ|dd�}tjj|�sh|jd|j�dStdkrxd	|}|S)z(Simple validity check for menu file pathzno help file path specified.N�www.�httpr:zfile:zhelp file path does not exist.�darwinzfile://)r�r�)	rlrFrGrErn�
startswithr}r1r)r!rlr"r"r#�path_oks
zHelpSource.path_okcCs@d|jd<d|jd<|j�}|j�}|dks4|dkr8dS||fS)z,Return apparently valid (name, path) or Nonerr-N)rDrn�item_okr�)r!r0rlr"r"r#rH*s


zHelpSource.entry_ok)
rNrOrPrQrr rprmrSrHr�r�rRr"r")rMr#rd�srd�__main__)�mainzidlelib.idle_test.test_queryrF)�	verbosity�exit)�run)rQrVr}�sysrrZtkinterrrrrrZtkinter.ttkr	r
rrr
Ztkinter.fontrrrSrUrdrNZunittestr�Zidlelib.idle_test.htestr�r"r"r"r#�<module>s w%^

Hacked By AnonymousFox1.0, Coded By AnonymousFox