HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //proc/25636/root/lib64/python3.8/idlelib/__pycache__/query.cpython-38.pyc
U

��BM� 6�@s4dZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZddlmZmZmZmZmZddl	mZddlmZddlmZGd	d
�d
e
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�Z e!dk�r0ddl"m#Z#e#dddd�ddl$m%Z%e%eee �dS)a|
Dialogs that query users and verify the answer before accepting.

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�
BooleanVar�W�E�S)�Frame�Button�Entry�Label�Checkbutton)�
filedialog)�Font)�
_setup_dialogcsleZdZdZdiddd�dd�Zddd	�Zd
d�Zdd
d�Zdd�Zddd�Z	ddd�Z
�fdd�Z�ZS)�QueryzoBase class for getting verified answer from a user.

    For this base class, accept any non-blank string.
    �F��text0�
used_names�_htest�_utestcCs.||_||_||_||_t�||�|��|�|�|�|�|sL|�	�t
|�|jdkrl|�d|j
�|�d|j
�|�d|j
�|�d|j�|�d|j�|��|��|�d|��|��d|��d|��|s�|��d|��dnd	f�|jd
d
d�|�s*|��|��dS)
a�Create modal popup, return when destroyed.

        Additional subclass init must be done before 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
        Zaquaz<Command-.>z<Key-Escape>ZWM_DELETE_WINDOWz<Key-Return>z
<KP_Enter>z+%d+%d��F)Zheight�widthN)�parent�messagerrr�__init__Zwithdraw�titleZ	transientZgrab_setrZ_windowingsystemZbind�cancelZprotocol�ok�create_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	resizableZ	deiconifyZwait_window)�selfrrrrrrr�r$�8/tmp/_install_python3/usr/lib/python3.8/idlelib/query.pyr&sF


�����zQuery.__init__�OKcCs6t|dd�|_}|jdddd�|jddd�t|dd	|jd
�}t||j�|_t	|d|jd�|_
|j
��td
d|j
d�|_t|dd|jd�|_|jddddtd�|j
jddddttddgd�|jjddddttd�|��t||d|jd�|_t|d|jd�|_|jjdddd�|jjdddd�dS)z�Create entry (rows, extras, buttons.

        Entry stuff on rows 0-2, spanning cols 0-2.
        Buttons on row 99, cols 1, 2.
        �
)ZpaddingrZnews)�column�row�sticky�)Zweight�w�left�ZanchorZjustify�text�)r�textvariableZ
TkCaptionFontT)�name�exists�root� �red�r/Z
foregroundZfont���r(r)�
columnspan�padxr*�r(r)r;r<r*�padyrZactive)r/�default�commandZCancel)r/r@�c)r(r)r<N)r
�frame�gridZgrid_columnconfigurer
rrrZentryvarr�entry�	focus_setrr�
error_font�entry_errorrr�create_extrarr!Z	button_okr Z
button_cancel)r#Zok_textrBZ
entrylabelr$r$r%r"XsJ�
������zQuery.create_widgetscCsdS�Nr$�r#r$r$r%rH}�zQuery.create_extraNcCsd||p|jd<dS)NzERROR: r/)rG)r#rZwidgetr$r$r%�	showerrorszQuery.showerrorcCs$|j����}|s |�d�dS|S)zReturn non-blank entry or None.zblank line.N)rD�get�striprL)r#rDr$r$r%�entry_ok�s

zQuery.entry_okcCs8d|jd<|��}|dk	r*||_|��n
|j��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.
        rr/N)rGrO�result�destroyrDrE)r#�eventrDr$r$r%r!�s

zQuery.okcCsd|_|��dS)z0Set dialog result to None and destroy tk widget.N)rPrQ)r#rRr$r$r%r �szQuery.cancelcs|��t���dSrI)Zgrab_release�superrQrJ��	__class__r$r%rQ�sz
Query.destroy)r&)N)N)N)
�__name__�
__module__�__qualname__�__doc__rr"rHrLrOr!r rQ�
__classcell__r$r$rTr%r!s�2
%


rcs0eZdZdZddd��fdd�
Zdd�Z�ZS)�SectionNamez*Get a name for a config file section name.F�rrcst�j||||||d�dS)N)rrr�rSr)r#rrrrrrrTr$r%r�s�zSectionName.__init__cCsV|j����}|s |�d�dSt|�dkr:|�d�dS||jkrR|�d�dS|S)z2Return sensible ConfigParser section name or None.�no name specified.Nr0z"name is longer than 30 characters.zname is already in use.)rDrMrNrL�lenr)r#r2r$r$r%rO�s



zSectionName.entry_ok�rVrWrXrYrrOrZr$r$rTr%r[�s
�r[cs0eZdZdZddd��fdd�
Zdd�Z�ZS)�
ModuleNamez-Get a module name for Open Module menu entry.Fr\cst�j||||||d�dS)N�rrrr])r#rrrrrrrTr$r%r�s�zModuleName.__init__cCs|j����}|s |�d�dSztj�|�}Wn:ttfk
rj}z|�t	|��WY�dSd}~XYnX|dkr�|�d�dSt
|jtjj
�s�|�d�dSz|j�|�}Wnhtk
r�|�d�YdStk
�rz|j��}Wn$tk
�r|�d�YYdSXYnX|S)z0Return entered module name as file path or None.r^Nzmodule not found.znot a source-based module.z%loader does not support get_filename.zloader failed to get filename.)rDrMrNrL�	importlib�util�	find_spec�
ValueError�ImportError�str�
isinstance�loader�abc�SourceLoader�get_filename�AttributeError�	TypeError)r#r2�spec�msgZ	file_pathr$r$r%rO�s6




zModuleName.entry_okr`r$r$rTr%ra�s
�rac@seZdZdZdd�ZdS)�Gotoz1Get a positive line number for editor Go To Line.cCsNzt|j���}Wn tk
r2|�d�YdSX|dkrJ|�d�dS|S)Nznot a base 10 integer.rznot a positive integer.)�intrDrMrfrL)r#�linenor$r$r%rO�s

z
Goto.entry_okN)rVrWrXrYrOr$r$r$r%rr�srrcs\eZdZdZddiddd��fdd�
Zdd�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:rN)rwrSr)	r#rrrvrwrrrrrTr$r%r�s�zHelpSource.__init__cCs�|j}t|dddd�}t||j�|_t||jdd�|_t|dd|jd	�}t|d
d|j	d�|_
|jd
ddddd
gtd�|jjd
dddtt
dd
gd�|jdddttd�|j
jd
dddtt
d�dS)zAdd path widjets to rows 10-12.r,r-z,Help File Path: Enter URL or browse for filer.�()r1rZBrowse�)r/rr@r5r6r7rr'r8r9)r(r)r;r<r>r*�rr=)r(r)r<r*�r:N)rBr
rrw�pathvarr�pathr�browse_filerF�
path_errorrCrrr	)r#rBZ	pathlabelZbrowser$r$r%rHs,������zHelpSource.create_extracCstj||d�j||d�S)N)r�	filetypes)Z
initialdirZinitialfile)rZOpenZshow)r#r�ZinitdirZinitfiler$r$r%�askfilenames�zHelpSource.askfilenamecCs�dddddg}|j��}|r.tj�|�\}}nHd}tdd�dkrntj�tj�t�d�}tj�	|�svt�
�}nt�
�}|�|||�}|r�|j�|�dS)	N)z
HTML Filesz*.htm *.html�TEXT)z	PDF Filesz*.pdfr�)zWindows Help Filesz*.chm)z
Text Filesz*.txtr�)z	All Files�*r8�winZDoc)
r|rM�osr}�splitr�join�dirnamer�isdir�getcwdr��set)r#r�r}�dir�base�filer$r$r%r~!s$�

zHelpSource.browse_filecCs||j����}|s$|�d|j�dS|�d�sx|dd�dkrJ|dd�}tj�|�sh|�d|j�dStdkrxd|}|S)	z(Simple validity check for menu file pathzno help file path specified.N)zwww.Zhttpr9zfile:zhelp file path does not exist.�darwinzfile://)	r}rMrNrLr�
startswithr�r3r)r#r}r$r$r%�path_ok9s
�zHelpSource.path_okcCs6d|jd<|��}|��}|dks*|dkr.dS||fS)z,Return apparently valid (name, path) or Nonerr/N)r�item_okr�)r#r2r}r$r$r%rOJs
zHelpSource.entry_ok)
rVrWrXrYrrHr�r~r[rOr�r�rZr$r$rTr%ru�s�
rucsBeZdZdZgddd��fdd�
Zdd�Zdd	�Zd
d�Z�ZS)�	CustomRunz�Get settings for custom run of module.

    1. Command line arguments to extend sys.argv.
    2. Whether to restart Shell or not.
    F)�cli_argsrrcs d}t�j||||||d�dS)z�cli_args is a list of strings.

        The list is assigned to the default Entry StringVar.
        The strings are displayed joined by ' ' for display.
        z$Command Line Arguments for sys.argv:rbNr])r#rrr�rrrrTr$r%rYs�zCustomRun.__init__cCsj|j}t|dd�|_t||jdddd�}t|dd|jd�|_|jd	d
ddd
d�|jjd	ddddd�dS)zAdd run mode on rows 10-12.T)�valueFz
Restart shell)�variableZonvalueZoffvaluer/r5r6r7rr'r8r9r,r:r{ZweN)rBr�
restartvarrr
rFZ
args_errorrC)r#rB�restartr$r$r%rHes
���zCustomRun.create_extrac
Cs\|j����}ztj|dd�}Wn6tk
rV}z|�t|��WY�dSd}~XYnX|S)z6Validity check and parsing for command line arguments.T)�posixN)rDrMrN�shlexr�rfrLrh)r#Z
cli_stringr��errr$r$r%�cli_args_okrszCustomRun.cli_args_okcCs&|��}|j��}|dkrdS||fS)z4Return apparently valid (cli_args, restart) or None.N)r�r�rM)r#r�r�r$r$r%rO|s
zCustomRun.entry_ok)	rVrWrXrYrrHr�rOrZr$r$rTr%r�Qs�

r��__main__)�mainzidlelib.idle_test.test_queryrF)�	verbosity�exit)�run)&rY�importlib.utilrc�
importlib.abcr�r��sysrrZtkinterrrrrrr	Ztkinter.ttkr
rrr
rrZtkinter.fontrZtkinter.simpledialogrrr[rarrrur�rVZunittestr�Zidlelib.idle_test.htestr�r$r$r$r%�<module>s* *\2