Fa@sdZddlZddlZdZdZdZdZddZGd d d Zddd d Z dd dZ e dkrej Z edddddeZeejeejdeejdeejeejdeejdee eejdejdeejde eddZeejdejdde eje dddeZejeje ddde jZejededjZejdeejdeejdS) z0.9NZnormalZromanboldZitaliccCstd|ddS)zFGiven the name of a tk named font, returns a Font representation. nameexistsT)Font)rr"/usr/lib/python3.5/tkinter/font.py nametofontsrc@seZdZdZejdZddZddZddZ d d d d d d Z d dZ ddZ ddZ ddZddZddZd d ddZddZddZeZd dd Zd!d"Zd S)#raRepresents a named font. Constructor options are: font -- font specifier (name, system font, or (family, size, style)-tuple) name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new named font if False, points to the existing font if True. Raises _tkinter.TclError if the assertion is false. the following are ignored if font is specified: family -- font 'family', e.g. Courier, Times, Helvetica size -- font size in points weight -- font thickness: NORMAL, BOLD slant -- font slant: ROMAN, ITALIC underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) cCsQg}x>|jD]0\}}|jd||jt|qWt|S)N-)itemsappendstrtuple)selfkwoptionskvrrr_set1s z Font._setcCs2g}x|D]}|jd|q Wt|S)Nr )r r)rargsrrrrr_get8s z Font._getcCsMi}x@tdt|dD]&}||d|||dds$z Font._mkdictNFcKs7|stj}t|d|}|rH|j|jdd|}n|j|}|svdtt|j}||_ |rd|_ |j |j|jddkrtj j d|j f|r|jdd|j |n"|jdd|j |d |_ ||_ |j|_|j|_dS) NtkfontactualFnamesz$named font %s does not already exist configureZcreateT)tkinter _default_rootgetattr splitlistcallrr nextcounterr delete_fontZ_tkinterZTclError_tk_split_call)rrootrrrrrrrr__init__Ds* !  $    z Font.__init__cCs|jS)N)r)rrrr__str__csz Font.__str__cCst|to|j|jkS)N) isinstancerr)rotherrrr__eq__fsz Font.__eq__cCs |j|S)N)cget)rkeyrrr __getitem__iszFont.__getitem__cCs|j||idS)N)r )rr3valuerrr __setitem__lszFont.__setitem__c Cs<y#|jr"|jdd|jWntk r7YnXdS)NrZdelete)r(r+r Exception)rrrr__del__os   z Font.__del__cCst|j|jS)z*Return a distinct copy of the current font)rr)r)rrrrcopyvsz Font.copycCswf}|rd|f}|rH|d|f}|jdd|j|S|j|j|jdd|j|SdS)zReturn actual font attributesz -displayofr rrN)r+rrr*)roption displayofrrrrrzs z Font.actualcCs|jdd|jd|S)zGet font attributerconfigr )r+r)rr:rrrr2sz Font.cgetcKsW|r+|jdd|j|j|n(|j|j|jdd|jSdS)zModify font attributesrr<N)r+rrrr*)rrrrrr<s z Font.configcCsC|f}|rd||f}|jj|jdd|j|S)zReturn text widthz -displayofrmeasure)r)getintr+r)rtextr;rrrrr=s z Font.measurecOsf}|jdd}|r*d|f}|rh||j|}|jj|jdd|j|S|j|jdd|j|}i}xLtdt|dD]2}|jj||d|||ddr+rr*rr)rrrrr;Zresrrrrr@s  $0z Font.metrics)__name__ __module__ __qualname____doc__ itertoolscountr'rrrr-r.r1r4r6r8r9rr2r<r r=r@rrrrrs$            rcCsI|stj}f}|r'd|f}|jj|jjdd|S)zGet font families (as a tuple)z -displayofrfamilies)r!r"rr$r%)r,r;rrrrrHs   rHcCs.|stj}|jj|jjddS)z'Get names of defined fonts (as a tuple)rr)r!r"rr$r%)r,rrrrs r__main__ZfamilytimessizeZweightZhelloZ linespacer;rCourierr?z Hello, worldzQuit!Zcommand)rMrNr) __version__rFr!ZNORMALZROMANZBOLDZITALICrrrHrrBZTkr,fprintrr<r2r=r@ZLabelwZpackZButtonZdestroyr9ZfbZmainlooprrrrs@       %