MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/3/root/usr/lib/python2.4/Demo/tkinter/guido/ss1.pyc
m
=5Dc@sdZdkZdkZdkZdkZdkZdklZdddf\ZZ	Z
dZdZdZ
hee<e	e<e
e
<Zhed	<e	d
<e
d<Zhd	e<d
e	<de
<Zhed<e	d
<e
d
<ZdZdfdYZdfdYZdfdYZdefdYZdefdYZdefdYZdZdZdZdZdkZdfd YZd!Z d"Z!e"d#joe!ndS($sSS1 -- a spreadsheet.N(sexpattLEFTtCENTERtRIGHTcCs
|i|S(N(txtljusttn(RR((t,/usr/lib/python2.4/Demo/tkinter/guido/ss1.pyRscCs
|i|S(N(RtcenterR(RR((RRscCs
|i|S(N(RtrjustR(RR((RRstleftRtrighttwtecCs6d}x)|D]!}|dj	o||7}q
q
W|S(Ni(ttotaltseqRtNone(RRR
((Rtsums
tSheetcBstZdZdZdZdZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZdZdZdZdZdZdZdZdZdZRS(NcCsOh|_ti|_|iid}|i|_|i|_t	|_	dS(Nt__main__(
tselftcellstrexectRExect
add_moduletmt	cellvaluetcelltmulticellvalueR(RR((Rt__init__"s	cCs>|i||}t|do|i|iSn|SdS(Ntrecalc(RtgetcellRtyRthasattrRR(RRRR((RR*scCs||jo||}}n||jo||}}ng}xRt||dD]=}x4t||dD]}|i|i
||qpWqVW|S(Ni(tx1tx2ty1ty2RtrangeRRtappendRR(RR!R#R"R$RRR((RR1s

!cCs|ii||fS(N(RRtgetRR(RRR((RR<scCsO|djo
|djptt|tpt||i||f<dS(Ni(RRtAssertionErrort
isinstanceRtBaseCellRR(RRRR((Rtsetcell?s!cCs.y|i||f=Wntj
onXdS(N(RRRRtKeyError(RRR((Rt	clearcellDscCs1x*|i||||D]}|i|=qWdS(N(RtselectcellsR!R#R"R$txyR(RR!R#R"R$R/((Rt
clearcellsJscCs|id|ti|dS(Ni(RR0R#tsystmaxintR$(RR#R$((Rt	clearrowsNscCs|i|d|tidS(Ni(RR0R!R"R1R2(RR!R"((RtclearcolumnsQscCs||jo||}}n||jo||}}ng}|iD]Y\}}||jo
|jno/||jo
|jno|||fqJqJ~S(N(	R!R"R#R$t_[1]RRRR(RR!R#R"R$RR5R((RR.Ts


cCs]|djo|djodSn||jo||}}n||jo||}}n||djo||djpth}
x|i	D]\}}|i	||f}	t
|	do"|	i||||||}	n||jo
|jno6||jo
|jno||7}||7}n|	|
||f<qW|
|_	dS(Nitrenumber(tdxtdyR!R"R#R$R(tnewRRRRRR R6(RR!R#R"R$R7R8RRRR9((Rt	movecells\s$

)
"<
cCs:|djpt|id|titid|dS(Ni(RR(RR:RR1R2(RRR((Rt
insertrowsoscCs`||jo||}}n|i|||id|dtitid||ddS(Nii(R#R$RR3R:R1R2(RR#R$((Rt
deleterowsss
cCs:|djpt|i|dtiti|ddS(Ni(RR(RR:RR1R2(RRR((Rt
insertcolumnsyscCs`||jo||}}n|i|||i|ddtiti||dddS(Nii(R!R"RR0R:R1R2(RR!R"((Rt
deletecolumns}s
cCsLd}}x5|iD]*\}}t||}t||}qW||fS(Ni(tmaxxtmaxyRRRRtmax(RR?R@RR((Rtgetsizes

cCs<x5|iiD]$}t|do|iqqWdS(Ntreset(RRt
itervaluesRR RC(RR((RRCscCsL|ix;|iiD]*}t|do|i|iqqWdS(NR(RRCRRDRR RR(RR((RRs

cCs
|i\}}|d|d}}dg|}	h}
xZtd|D]I}
t
|
tf|
|
df<\}}t|	|
t||	|
<qJWxZtd|D]I}t|tf|
d|f<\}}t|	dt||	d<qWx!|iiD]\\}
}}|
djp
|djoqnt|do|i|int|doJ|i\}}t|tpt|tttfjptn-t|}t|to
t}nt}||f|
|
|f<t|	|
t||	|
<qWd}x;t|D]-}
|o|d7}n|d|	|
7}q+Wxt|D]}d}xrt|D]d}
|
i|
|fp
dtf\}}t |||	|
}|o|d7}n||7}qW|GH|djo	|GHqiqiWdS(	NiiRtformattt+t-t|(!RRBR?R@twidththeighttcolwidthtfullR%Rtcolnum2nameRttextt	alignmentRAtlenRtstrRt	iteritemsRR RRRER)R(RRtseptlineR'talign2action(RRTRORKRPR?R@RRJRLRMRURR((Rtdisplays^
&!&!!
!


(
cCsdg}xp|iiD]_\\}}}t|do|i}ndt
i|}|id|||fqW|iddi
|S(Ns
<spreadsheet>txmls<value>%s</value>s%<cell row="%s" col="%s">
  %s
</cell>s</spreadsheet>s
(toutRRRSRRRR RXtcellxmltcgitescapeR&tjoin(RRZRRRRY((RRXs	
cCs_|i}t|d}|i||o"|ido|idn|idS(NRs
(	RRXROtopentfilenametftwritetendswithtclose(RR_ROR`((Rtsaves
cCs0t|d}t|i||idS(Ntr(R^R_R`tSheetParserRt	parsefileRc(RR_R`((Rtloads(t__name__t
__module__RRRRR+R-R0R3R4R.R:R;R<R=R>RBRCRRWRXRdRh(((RR s,																			2		RfcBstZdZdZdZdZdZdZdZeZ	dZ
d	Zd
ZdZ
dZd
ZdZdZRS(NcCs
||_dS(N(tsheetR(RRk((RRscCsAti}|i|_|i|_|i|_	|i
|dS(N(texpattParserCreatetparserRtstartelementtStartElementHandlert
endelementtEndElementHandlertdatatCharacterDataHandlert	ParseFileR`(RR`Rn((RRgs
cCset|d|d}|o;x*|iD]\}}t	|||<q*W||ng|_
dS(Ntstart_(tgetattrRttagRtmethodtattrsRStkeytvalueRRttexts(RRxRzR|R{Ry((RRos
cCs t|}|ii|dS(N(RRRORR}R&(RRO((RRsscCs;t|d|d}|o|di|indS(Ntend_RF(RwRRxRRyR]R}(RRxRy((RRqscCs4t|id|_t|id|_dS(Ntrowtcol(tintRzR'RRR(RRz((Rt
start_cellscCs1|id|_ti|id|_dS(NREtalign(RzR'Rtfmtt	xml2alignRP(RRz((Rtstart_valuescCs*yt||_Wnd|_nXdS(N(RRORR|R(RRO((Rtend_intscCs*yt||_Wnd|_nXdS(N(tlongRORR|R(RRO((Rtend_long
scCs*yt||_Wnd|_nXdS(N(tfloatRORR|R(RRO((Rt
end_doublescCs*yt||_Wnd|_nXdS(N(tcomplexRORR|R(RRO((Rtend_complexscCs$y
||_Wnd|_nXdS(N(RORR|R(RRO((Rt
end_strings
cCst|ito|i|_npt|ito0t|i|ipd|ipt	|_n-t
|i|ipd|ipt|_dS(Ns%s(R)RR|R*RRRt
StringCellRRPRtNumericCellR(RRO((Rt	end_value%s	
	
cCs-t||ipd|ipt|_dS(Ns%s(tFormulaCellRORRRPRR(RRO((Rtend_formula1s
cCs#|ii|i|i|idS(N(RRkR+RRR(RRO((Rtend_cell6s(RiRjRRgRoRsRqRRt
start_formulaRRRRRRRR(((RRfs 														R*cBstZdZRS(N(RiRjRR(((RR*9sRcBsVtZdedZdZdZdZdZdZdZ	d	Z
RS(
Ns%scCs_t|ttttfpt|tt	t
fjpt||_||_||_dS(N(
R)R|RRRRR(RPRRRRR(RR|RRP((RRGs
#		cCs|iS(N(RR|(RR((RRNscCs:y|i|i}Wnt|i}nX||ifS(N(RRR|RORRRP(RRO((RREQs
cCs=t|dt|ii}dt|i|i|fS(Nt_xml_s(<value align="%s" format="%s">%s</value>(	RwRttypeR|RiRyt	align2xmlRPR(RRy((RRXXscCsGdd|ijoddjnod|iSn|iSdS(Niis
<int>%s</int>(RR|t	_xml_long(R((Rt_xml_int_s*cCsd|iS(Ns<long>%s</long>(RR|(R((RRescCsdt|iS(Ns<double>%s</double>(treprRR|(R((Rt
_xml_floathscCsdt|iS(Ns<complex>%s</double>(RRR|(R((Rt_xml_complexks(RiRjRRRRERXRRRR(((RREs						RcBs2tZdedZdZdZdZRS(Ns%scCsYt|ttfpt|tttfjpt||_||_
||_dS(N(R)RORRtunicodeR(RPRRRRR(RRORRP((RRps
		cCs|iS(N(RRO(RR((RRwscCs|i|ifS(N(RRORP(R((RREzscCs-d}|t|i|iti|ifS(Ns9<value align="%s" format="%s"><string>%s</string></value>(tsRRRPRR[R\RO(RR((RRX}s(RiRjRRRRERX(((RRns		RcBsDtZdedZdZdZdZdZdZRS(Ns%scCsX|tttfjpt||_t|i|_||_	||_|i
dS(N(RPRRRR(tformulaRt	translatet
translatedRRC(RRRRP((RRs			cCs
d|_dS(N(RRR|(R((RRCscCs|idjoy4|iddt|i|id|_Wqti	d}t|do|i|_qt
||_qXn|iS(Ns from __future__ import division
s__value__ = eval(%s)t	__value__iRi(RR|RRtr_execRRtr_evalR1texc_infotexcR RiRR(RRR((RRscCs:y|i|i}Wnt|i}nX||ifS(N(RRR|RORRRP(RRO((RREs
cCsdt|i|i|ifS(Ns,<formula align="%s" format="%s">%s</formula>(RRRPRR(R((RRXscCsg}
xtid|iD]}
tid|
}|dj	o|i	\}	}t|	}t|}||jo
|jno9||jo
|jnot||||}
qn|
i|
qWtdi|
|i|iS(Ns(\w+)s^([A-Z]+)([1-9][0-9]*)$RF(RYtretsplitRRtparttmatchRRtgroupstsxtsytcolname2numRRRR!R"R#R$tcellnameR7R8R&RR]RRP(RR!R#R"R$R7R8RRRRRRRY((RR6s
<(	RiRjRRRCRRERXR6(((RRs				c	Csg}xtid|D]}tid|}|djo|i|q|i	\}}}}t|}|djod||f}n#t|}d||||f}|i|qWdi|S(sTranslate a formula containing fancy cell names to valid Python code.

    Examples:
        B4 -> cell(2, 4)
        B4:Z100 -> cells(2, 4, 26, 100)
    s(\w+(?::\w+)?)s2^([A-Z]+)([1-9][0-9]*)(?::([A-Z]+)([1-9][0-9]*))?$scell(%s, %s)scells(%s, %s, %s, %s)RFN(RYRRRRRRRR&RR!R#R"R$RRR](	RR$RR"RRR#R!RY((RRs

cCs(|djptt|t|S(sETranslate a cell coordinate to a fancy cell name (e.g. (1, 1)->'A1').iN(RR(RNRRR(RR((RRscCsn|i}d}xU|D]M}d|jo
djnpt|dt|tdd}qW|S(sCTranslate a column name to number (e.g. 'A'->1, 'Z'->26, 'AA'->27).itAtZiiN(RtupperRtcR(tord(RRR((RRs%&cCs`|djptd}x?|o7t|dd\}}t|td|}qW|S(s6Translate a column number to name (e.g. 1->'A', etc.).iRFiiRN(RR(RtdivmodRtchrR(RRR((RRNstSheetGUIcBstZdZddddZdZdZdZdZd	Zd
Z	dZ
dZd
ZdZ
dZeZdZdZdZdZdZdZdZdZdZdZdZdZRS(s7Beginnings of a GUI for a spreadsheet.

    TO DO:
    - clear multiple cells
    - Insert, clear, remove rows or columns
    - Show new contents while typing
    - Scroll bars
    - Grow grid when window is grown
    - Proper menus
    - Undo, redo
    - Cut, copy and paste
    - Formatting and alignment
    s
sheet1.xmli
icCs,||_t|_tii|o|ii|n|ii\}}t||}t||}ti|_|iid|iti|idddd|_ti|i|_ti|iddd	|i|_ti|i|_|iid
ddd
dd|iid
d|iid
d|iid
ddd
dd|iid|i|iid|i|iid|i|iid|i|iid|i |iid|i!|i"||d|_$d|_%|i&d
d
|i'dS(slConstructor.

        Load the sheet from the filename argument.
        Set up the Tk widget tree.
        sSpreadsheet: %sROtA1tfontt	helveticaitboldtSavetcommandtsidetbottomtexpanditfilltbothR	R
Rs<Return>s<Shift-Return>s<Tab>s<Shift-Tab>s<Delete>s<Escape>N(RiR((R_RRRktostpathtisfileRhRBR?R@RAtrowstcolumnstTktroottwm_titletLabeltbeacontEntrytentrytButtonRdt
savebuttontFrametcellgridtpacktbindtreturn_eventtshift_return_eventt	tab_eventtshift_tab_eventtdelete_eventtescape_eventtmakegridRt	currentxytcornerxyt
setcurrenttsync(RR_RRR?R@((RRs>			cCsu|i|ijo.|idj	o|ii|i|in|ii|i|i|ii	dddS(Nitendtbreak(
RRRRRkR0R-RRtdelete(Rtevent((RR's#
cCs#|i\}}|i||dS(N(RRRRt
load_entry(RRRR((RR0scCs|ii||}|djo
d}n4t|t	od|i
}n|i\}}|i
idd|i
id||i
idddS(NRFt=iR(RRkRRRRRROR)RRRERPRRtinserttselection_range(RRRRORRP((RR4s

c
Cs||_||_h|_ti|idd}|idddddd|i	d|i
xtd	|d	D]}|ii
|d
dti|idt|dd}|id|dddd
||i|df<||_d|_|i	d|i|i	d|i|i	d|i|i	d|iqvWxtd	|d	D]}ti|idt|dd}|iddd|dd
||id|f<d|_||_|i	d|i|i	d|i|i	d|i|i	d|iq[Wxtd	|d	D]}xtd	|d	D]}ti|idddddd}|id|d|dd||i||f<||_||_|i	d|i|i	d|i|i	d|i|i	d|iqDWq*WdS(sHelper to create the grid of GUI cells.

        The edge (x==0 or y==0) is filled with labels; the rest is real cells.
        trelieftraisedtcolumniRtstickytNSWEs<ButtonPress-1>itminsizei@ROtWEs<B1-Motion>s<ButtonRelease-1>s<Shift-Button-1>tsunkentbgtwhitetfgtblackN(RRRt	gridcellsRRRRtgrid_configureRt	selectallR%Rtgrid_columnconfigureRNt_SheetGUI__xt_SheetGUI__ytselectcolumntextendcolumnRRRt	selectrowt	extendrowtpresstmotiontrelease(RRRRRR((RR@sX			$		$				cCs*|idd|ititidS(Ni(RRt	setcornerR1R2(RR((RRrscCs<|i|\}}|i|d|i|tidS(Ni(	RtwhichxyRRRRRR1R2(RRRR((RRvscCsT|i|\}}|djo.|i|idd|i|ti	ndS(Nii(
RRRRRRRRR1R2(RRRR((RR{s
cCs<|i|\}}|id||iti|dS(Ni(	RRRRRRRR1R2(RRRR((RRscCsT|i|\}}|djo.|id|id|iti	|ndS(Nii(
RRRRRRRRR1R2(RRRR((RRs
cCsG|i|\}}|djo!|djo|i||ndS(Ni(RRRRRR(RRRR((RRscCsG|i|\}}|djo!|djo|i||ndS(Ni(RRRRRR(RRRR((RRscCsm|ii|i|i}|dj	oAt|t	i
o.y|i|ifSWqit
j
oqiXndS(Ni(ii(RRtwinfo_containingRtx_rootty_rootRRR)RRRRtAttributeError(RRR((RRs 	cCs|ii|idS(N(RRkRdR_(R((RRdscCs|idj	o|in|it|||id<|i	|||i
i||f|_d|_|i
i|i}|dj	od|d<ndS(sMake (x, y) the current cell.ROtyellowRN(RRRtchange_cellt
clearfocusRRRRRRt	focus_setRRR'tgridcell(RRRR((RRs

	
c	Csu|idjp|i||fjo|i||dSn|i||f|_|i\}}|ip|i\}}||jo||}}n||jo||}}nxm|ii
D]\\\}}}||jo
|jno,||jo
|jnod|d<qqW|ii|i}|dj	od|d<n|i||||dS(Nt	lightBlueRR(RRRRRRR
RR!R#R"R$RRSRR'Rt	setbeacon(	RRRRR$RR"R#R!((RRs&&


<
cCs0||jo
djno+||jo
tijno
d}n||fdtifjo/||jod|}qd||f}n||fdtifjoA||jodt|}qdt|t|f}n/t|i
}t|i}d||f}||id<dS(Nit:s%ds%d:%ds%ss%s:%sRO(R!R#R"R$R1R2tnameRNRRRtname1Rtname2R(RR!R#R"R$RRR((RRs?


 cCs|idj	o|i\}}|ip|i\}}||jo||}}n||jo||}}nxq|ii	D]\\\}}}||jo
|jno,||jo
|jnod|d<qqWndS(NRR(
RRRR!R#RR"R$RRSRRR(RR$RRR"R#RR!((RR
s

<cCs1|i|i\}}|i||ddS(sCallback for the Return key.iRN(RR	RRRR(RRRR((RRs

cCs:|i|i\}}|i|td|ddS(s0Callback for the Return key with Shift modifier.iRN(RR	RRRRRA(RRRR((RRs

cCs1|i|i\}}|i|d|dS(sCallback for the Tab key.iRN(RR	RRRR(RRRR((RRs

cCs:|i|i\}}|itd|d|dS(s-Callback for the Tab key with Shift modifier.iRN(RR	RRRRRA(RRRR((RRs

cCs|i\}}|ii}d}|i	dot
|d}nHxDttt
tfD]0}y||}Wn
q[q[Xt|}Pq[W|djo|ot|}n|djo|ii||n|ii||||idS(s+Set the current cell from the entry widget.RiN(RRRRRR'RORRt
startswithRRRRRtclsR|RRRkR-R+R(RR|RORRRR((RR	s(
cCs|iix|iiD]\\}}}|djp
|djoqn|ii||}|djod|d<qt|do|i\}}nt|t}}||d<t||d<qWdS(s(Fill the GUI cells from the sheet cells.iRFROREtanchorN(RRkRRRSRRRRRRR RERORPRRRtalign2anchor(RRORRRPRR((RRs


(RiRjt__doc__RRRRRRRRRRRRRRRdRRRR
RRRRR	R(((RRs4-					2																			cCsdk}t}xtddD]}xtddD]}|djot|}nX|djot|}n;t|d}td|}d||f}t|}|i
|||q8Wq"W|i|iddS(sBasic non-gui self-test.Niis%s*%ss
sheet1.xml(RRtaR%RRRRRtc1tc2RRR+RWRd(RRRRRRRR((Rt
test_basic,s$		


cCsBtidotid}nd}t|}|iidS(s	GUI test.is
sheet1.xmlN(R1targvR_RtgRtmainloop(RR_((Rttest_guiBsR(#RRRR1R[Rtxml.parsersRlRRRRRRRVRRRRRRfR*RRRRRRRNtTkinterRRRRRi(RRRRlRRRR*RRRRRRRRNRRR[RVRR1RRRRfRRRRR((Rt?s@					
			!!!!	Y)6							C