%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/query.cpython-38.pyc

U

qa:@s4dZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZddlmZmZmZmZmZddl	mZddlmZddlmZGd	d
d
e
ZGdddeZGd
ddeZGdddeZGdddeZGdddeZ e!dkr0ddl"m#Z#e#ddddddl$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)
executableplatform)Toplevel	StringVar
BooleanVarWES)FrameButtonEntryLabelCheckbutton)
filedialog)Font)
_setup_dialogcsleZdZdZdidddddZddd	Zd
dZdd
dZddZdddZ	dddZ
fddZZS)QueryzoBase class for getting verified answer from a user.

    For this base class, accept any non-blank string.
    Ftext0
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)
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
        Zaquaz<Command-.>z<Key-Escape>ZWM_DELETE_WINDOWz<Key-Return>z
<KP_Enter>z+%d+%dF)ZheightwidthN)parentmessagerrr__init__ZwithdrawtitleZ	transientZgrab_setrZ_windowingsystembindcancelprotocolokcreate_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ	resizableZ	deiconifyZwait_window)selfrrrrrrrr&)/usr/local/lib/python3.8/idlelib/query.pyr&sF


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)ZweightwleftZanchorZjustifytext)rtextvariableZ
TkCaptionFontT)nameexistsroot redr1Z
foregroundZfontr*r+
columnspanpadxr,r*r+r=r>r,padyrZactive)r1defaultcommandZCancel)r1rBc)r*r+r>N)r
framegridZgrid_columnconfigurer
rrrZentryvarrentry	focus_setrr
error_fontentry_errorrrcreate_extrarr#Z	button_okr!Z
button_cancel)r%Zok_textrDZ
entrylabelr&r&r'r$XsJ
zQuery.create_widgetscCsdSNr&r%r&r&r'rJ}zQuery.create_extraNcCsd||p|jd<dS)NzERROR: r1)rI)r%rZwidgetr&r&r'	showerrorszQuery.showerrorcCs$|j}|s |ddS|S)zReturn non-blank entry or None.zblank line.N)rFgetstriprN)r%rFr&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.
        rr1N)rIrQresultdestroyrFrG)r%eventrFr&r&r'r#s

zQuery.okcCsd|_|dS)z0Set dialog result to None and destroy tk widget.N)rRrS)r%rTr&r&r'r!szQuery.cancelcs|tdSrK)Zgrab_releasesuperrSrL	__class__r&r'rSsz
Query.destroy)r()N)N)N)
__name__
__module____qualname____doc__rr$rJrNrQr#r!rS
__classcell__r&r&rVr'r!s2
%


rcs0eZdZdZdddfdd
ZddZZS)SectionNamez*Get a name for a config file section name.Frrcstj||||||ddS)N)rrrrUr)r%rrrrrrrVr&r'rszSectionName.__init__cCsV|j}|s |ddSt|dkr:|ddS||jkrR|ddS|S)z2Return sensible ConfigParser section name or None.no name specified.Nr2z"name is longer than 30 characters.zname is already in use.)rFrOrPrNlenr)r%r4r&r&r'rQs



zSectionName.entry_okrXrYrZr[rrQr\r&r&rVr'r]s
r]cs0eZdZdZdddfdd
ZddZZS)
ModuleNamez-Get a module name for Open Module menu entry.Fr^cstj||||||ddS)Nrrrr_)r%rrrrrrrVr&r'rszModuleName.__init__cCs|j}|s |ddSztj|}Wn:ttfk
rj}z|t	|WYdSd}~XYnX|dkr|ddSt
|jtjj
s|ddSz|j|}Wnhtk
r|dYdStk
rz|j}Wn$tk
r|dYYdSXYnX|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.)rFrOrPrN	importlibutil	find_spec
ValueErrorImportErrorstr
isinstanceloaderabcSourceLoaderget_filenameAttributeError	TypeError)r%r4specmsgZ	file_pathr&r&r'rQs6




zModuleName.entry_okrbr&r&rVr'rcs
rcc@seZdZdZddZdS)Gotoz1Get a positive line number for editor Go To Line.cCsNzt|j}Wn tk
r2|dYdSX|dkrJ|ddS|S)Nznot a base 10 integer.rznot a positive integer.)intrFrOrhrN)r%linenor&r&r'rQs

z
Goto.entry_okN)rXrYrZr[rQr&r&r&r'rtsrtcs\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:rN)ryrUr)	r%rrrxryrrrrrVr&r'rszHelpSource.__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 filer0()r3rZBrowse)r1rrBr7r8r9rr)r:r;)r*r+r=r>r@r,rr?)r*r+r>r,r<N)rDr
rrypathvarrpathrbrowse_filerH
path_errorrErrr	)r%rDZ	pathlabelZbrowser&r&r'rJs,zHelpSource.create_extracCstj||dj||dS)N)r	filetypes)Z
initialdirZinitialfile)rZOpenZshow)r%rZinitdirZinitfiler&r&r'askfilenameszHelpSource.askfilenamecCsdddddg}|j}|r.tj|\}}nHd}tdddkrntjtjtd}tj	|svt
}nt
}||||}|r|j|dS)	N)z
HTML Filesz*.htm *.htmlTEXT)z	PDF Filesz*.pdfr)zWindows Help Filesz*.chm)z
Text Filesz*.txtr)z	All Files*r:winZDoc)
r~rOosrsplitrjoindirnamerisdirgetcwdrset)r%rrdirbasefiler&r&r'r!s$

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://)	rrOrPrNr
startswithrr5r)r%rr&r&r'path_ok9s
zHelpSource.path_okcCs6d|jd<|}|}|dks*|dkr.dS||fS)z,Return apparently valid (name, path) or Nonerr1N)ritem_okr)r%r4rr&r&r'rQJs
zHelpSource.entry_ok)
rXrYrZr[rrJrrr]rQrrr\r&r&rVr'rws
rwcsBeZdZdZgdddfdd
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:rdNr_)r%rrrrrrrVr&r'rYszCustomRun.__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)variableZonvalueZoffvaluer1r7r8r9rr)r:r;r.r<r}ZweN)rDr
restartvarrr
rHZ
args_errorrE)r%rDrestartr&r&r'rJes
zCustomRun.create_extrac
Cs\|j}ztj|dd}Wn6tk
rV}z|t|WYdSd}~XYnX|S)z6Validity check and parsing for command line arguments.T)posixN)rFrOrPshlexrrhrNrj)r%Z
cli_stringrerrr&r&r'cli_args_okrszCustomRun.cli_args_okcCs&|}|j}|dkrdS||fS)z4Return apparently valid (cli_args, restart) or None.N)rrrO)r%rrr&r&r'rQ|s
zCustomRun.entry_ok)	rXrYrZr[rrJrrQr\r&r&rVr'rQs

r__main__)mainzidlelib.idle_test.test_queryrF)	verbosityexit)run)&r[importlib.utilre
importlib.abcrrsysrrtkinterrrrrrr	Ztkinter.ttkr
rrr
rrZtkinter.fontrZtkinter.simpledialogrrr]rcrtrwrrXZunittestrZidlelib.idle_test.htestrr&r&r&r'<module>s* *\2


Zerion Mini Shell 1.0