• File: query.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/query.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 12.51 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Nj2:@s dZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
mZmZm
Z
ddlmZmZmZmZmZddlmZddlmZGdd	d	eZGd
ddeZGdd
d
eZGdddeZGdddeZGdddeZedkrddlmZeddddddl m!Z!e!eeedS)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)
executableplatform)Toplevel	StringVar
BooleanVarWES)FrameButtonEntryLabelCheckbutton)
filedialog)FontcsleZdZdZdidddddZddd	Zd
dZdd
dZddZdddZ	dddZ
fddZZS)QueryzoBase class for getting verified answer from a user.

    For this base class, accept any non-blank string.
    F)text0
used_names_htest_utestc	CsX||_||_||_||_t||||||||	|j
dd}|dkry|j
dd|jddWnYnX|
d|j|
d	|j|d
|j|
d|j|
d|j|||d
||d|d||s$|d|dndf|jddd|sT||dS)aCreate 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
        tkwindowingsystemZaquaz!::tk::unsupported::MacWindowStyleZstyleZ
moveableModalrz<Command-.>z<Key-Escape>ZWM_DELETE_WINDOWz<Key-Return>z
<KP_Enter>z+%d+%dF)ZheightwidthN)parentmessagerrr__init__ZwithdrawtitleZ	transientZgrab_setrZcallZ_wZbindcancelZprotocolokcreate_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	resizableZ	deiconifyZwait_window)	selfrrrrrrrrr$2/opt/alt/python37/lib64/python3.7/idlelib/query.pyr%sB


*zQuery.__init__OKcCs6t|dd|_}|jdddd|jdddt|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|jjdddddS)zCreate entry (rows, extras, buttons.

        Entry stuff on rows 0-2, spanning cols 0-2.
        Buttons on row 99, cols 1, 2.
        
)ZpaddingrZnews)columnrowsticky)Zweightwleft)anchorjustifytext)rtextvariableZ
TkCaptionFontT)nameexistsroot red)r0
foregroundfont)r(r)
columnspanpadxr*)r(r)r<r=r*padyrZactive)r0defaultcommandZCancel)r0r@c)r(r)r=N)r
framegridZgrid_columnconfigurer
rrrZentryvarrentry	focus_setrr
error_fontentry_errorrrcreate_extrarr!Z	button_okr Z
button_cancel)r#Zok_textrBZ
entrylabelr$r$r%r"[s0

zQuery.create_widgetscCsdS)Nr$)r#r$r$r%rHzQuery.create_extraNcCsd||p|jd<dS)NzERROR: r0)rG)r#rZwidgetr$r$r%	showerrorszQuery.showerrorcCs$|j}|s |ddS|S)zReturn non-blank entry or None.zblank line.N)rDgetstriprJ)r#rDr$r$r%entry_oks

zQuery.entry_okcCs8d|jd<|}|dk	r*||_|n
|jdS)zIf entry is valid, bind it to 'result' and destroy tk widget.

        Otherwise leave dialog open for user to correct entry or cancel.
        rr0N)rGrMresultdestroyrDrE)r#eventrDr$r$r%r!s

zQuery.okcCsd|_|dS)z0Set dialog result to None and destroy tk widget.N)rNrO)r#rPr$r$r%r szQuery.cancelcs|tdS)N)Zgrab_releasesuperrO)r#)	__class__r$r%rOsz
Query.destroy)r&)N)N)N)
__name__
__module____qualname____doc__rr"rHrJrMr!r rO
__classcell__r$r$)rRr%r s5
%


rcs0eZdZdZdddfdd
ZddZZS)SectionNamez*Get a name for a config file section name.F)rrcstj||||||ddS)N)rrr)rQr)r#rrrrrr)rRr$r%rszSectionName.__init__cCsV|j}|s |ddSt|dkr:|ddS||jkrR|ddS|S)z2Return sensible ConfigParser section name or None.zno name specified.Nr1z"name is longer than 30 characters.zname is already in use.)rDrKrLrJlenr)r#r3r$r$r%rMs



zSectionName.entry_ok)rSrTrUrVrrMrWr$r$)rRr%rXsrXcs0eZdZdZdddfdd
ZddZZS)
ModuleNamez-Get a module name for Open Module menu entry.F)rrcstj||||||ddS)N)rrr)rQr)r#rrrrrr)rRr$r%rszModuleName.__init__c
Cs|j}|s |ddSytj|}Wn4ttfk
rd}z|t	|dSd}~XYnX|dkr||ddSt
|jtjj
s|ddSy|j|}Wn"tk
r|jd|ddSX|S)z0Return entered module name as file path or None.zno name specified.Nzmodule not foundznot a source-based modulez$loader does not support get_filename)r)rDrKrLrJ	importlibutil	find_spec
ValueErrorImportErrorstr
isinstanceloaderabcSourceLoaderget_filenameAttributeError)r#r3specmsgZ	file_pathr$r$r%rMs,


zModuleName.entry_ok)rSrTrUrVrrMrWr$r$)rRr%rZsrZc@seZdZdZddZdS)Gotoz1Get a positive line number for editor Go To Line.cCsLyt|j}Wntk
r0|ddSX|dkrH|ddS|S)Nznot a base 10 integer.rznot a positive integer.)intrDrKr^rJ)r#linenor$r$r%rMs

z
Goto.entry_okN)rSrTrUrVrMr$r$r$r%risrics\eZdZdZddidddfdd
ZddZd	d
ZddZej	Z
d
dZddZ	ZS)
HelpSourcez,Get menu name and help source for Help menu.rF)menuitemfilepathrrrc		s(||_d}tj|||||||ddS)zGet 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)rnrQr)	r#rrrmrnrrrr)rRr$r%rs
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
ddS)zAdd path widjets to rows 10-12.r,r-z,Help File Path: Enter URL or browse for file)r.r/r0()r2rZBrowse)r0rr@r6r7)r0r8r9rr'r:r;)r(r)r<r=r>r*r)r(r)r<r=r*r>)r(r)r=r*)r(r)r<r=r*N)rBr
rrnpathvarrpathrbrowse_filerF
path_errorrCrrr	)r#rBZ	pathlabelZbrowser$r$r%rHs 
zHelpSource.create_extracCstj||dj||dS)N)r	filetypes)Z
initialdirZinitialfile)rZOpenZshow)r#rwZinitdirZinitfiler$r$r%askfilenameszHelpSource.askfilenamecCsdddddg}|j}|r.tj|\}}nHd}tdddkrntjtjtd}tj	|svt
}nt
}||||}|r|j|dS)	N)z
HTML Filesz*.htm *.htmlTEXT)z	PDF Filesz*.pdfry)zWindows Help Filesz*.chm)z
Text Filesz*.txtry)z	All Files*r:winZDoc)
rsrKosrtsplitrjoindirnamerisdirgetcwdrxset)r#rwrtdirbasefiler$r$r%rus"

zHelpSource.browse_filecCs||j}|s$|d|jdS|dsx|dddkrJ|dd}tj|sh|d|jdStdkrxd|}|S)	z(Simple validity check for menu file pathzno help file path specified.N)zwww.Zhttpr;zfile:zhelp file path does not exist.darwinzfile://)	rtrKrLrJrv
startswithr|r4r)r#rtr$r$r%path_ok6s
zHelpSource.path_okcCs6d|jd<|}|}|dks*|dkr.dS||fS)z,Return apparently valid (name, path) or Nonerr0N)rvitem_okr)r#r3rtr$r$r%rMGs
zHelpSource.entry_ok)
rSrTrUrVrrHrxrurXrMrrrWr$r$)rRr%rlsrlcsBeZdZdZgdddfdd
ZddZdd	Zd
dZZS)	CustomRunzGet 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}tj||||||ddS)zcli_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:)rrrN)rQr)r#rrrrrr)rRr$r%rVszCustomRun.__init__cCsj|j}t|dd|_t||jdddd}t|dd|jd|_|jd	d
ddd
d|jjd	ddddddS)zAdd run mode on rows 10-12.T)valueFz
Restart shell)ZvariableZonvalueZoffvaluer0r6r7)r0r8r9rr'r:r;r,)r(r)r<r=r*rrZweN)rBr
restartvarrr
rFZ
args_errorrC)r#rBrestartr$r$r%rHbs

zCustomRun.create_extrac
CsV|j}ytj|dd}Wn0tk
rP}z|t|dSd}~XYnX|S)z6Validity check and parsing for command line arguments.T)posixN)rDrKrLshlexr}r^rJr`)r#Z
cli_stringrerrr$r$r%cli_args_okoszCustomRun.cli_args_okcCs&|}|j}|dkrdS||fS)z3Return apparently valid (cli_args, restart) or NoneN)rrrK)r#rrr$r$r%rMys
zCustomRun.entry_ok)	rSrTrUrVrrHrrMrWr$r$)rRr%rNs

r__main__)mainzidlelib.idle_test.test_queryrF)	verbosityexit)run)"rVr[r|rsysrrZtkinterrrrrrr	Ztkinter.ttkr
rrr
rrZtkinter.fontrrrXrZrirlrrSZunittestrZidlelib.idle_test.htestrr$r$r$r%<module>s( $\2