a
    If|#                     @   s   d Z ddlZddlZddlZddlmZmZ ddlmZm	Z	m
Z
mZmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlmZ e Zdd ZG d	d
 d
eZedkrddlmZ edddd ddlm Z  e e dS )zAbout Dialog for IDLE

    N)python_versionarchitecture)ToplevelFrameLabelButton
PhotoImage)
SUNKENTOPBOTTOMLEFTXBOTHWEWNSEWE)textviewc                   C   s2   t jdkrt jdkrdS dS t d dd S dS )zReturn bits for platform.darwinl        Z64Z32r   N   )sysplatformmaxsizer    r   r   #lib/python3.9/idlelib/help_about.py
build_bits   s    
r   c                   @   sv   e Zd ZdZddddddZdd Zd	d
 Zdd Zdd Zdd Z	dd Z
dd Zdd ZdddZdddZdS )AboutDialogz!Modal about dialog for idle

    NF)_htest_utestc                C   s   t | | | jdd | d| d | |s6dnd f  d| _d| _|   | j	ddd	 | 
|p~d
t dt  d | | |   | d| j || _| j  | d| j | d| j d| _|| _|s|   |   dS )a  Create popup, do not return until tk widget destroyed.

        parent - parent of this dialog
        title - string which is title of popup dialog
        _htest - bool, change box location when running htest
        _utest - bool, don't wait_window when running unittest
           )borderwidthz+%d+%d   d   z#bbbbbbz#000000F)heightwidthzAbout IDLE z (z bit)ZWM_DELETE_WINDOWz<Return>z<Escape>N)r   __init__Z	configureZgeometryZwinfo_rootxZwinfo_rootybgfgcreate_widgetsZ	resizabletitleversionr   Z	transientZgrab_setZprotocolokparent	button_okZ	focus_setbind_current_textviewr   Z	deiconifyZwait_window)selfr,   r)   r   r   r   r   r   r%      s2    


zAboutDialog.__init__c                    s  t | dtd}t | }|jttd |jtdtd t|d| jd| _	| j	jddd	 t || j
d
}|jdtd t|d| j| j
dd}|jddtddd | jdd}|dkrdnd}tjtjtjtdd| }t|  |d| _t|| j| j
d}|jddtdddd d}	t||	t| j| j
d}
|
jddtdddd t|d t| j| j
d}|jd!ddtddd" t|d#td td$  d%t| j| j
d  jd&ddtddd"  d' fd(d) t |d*td| j
d+jd,dtdddd t|d-t | j| j
d.}|jd/dtddd t|d0| | j| j
d.}|jd/d*tddd t || j
d
}|jdddt d1 t|d2d,| j
| j!d3| _"| j"jtddd4 t|d5d,| j
| j#d3| _$| j$jtddd4 t|d6d,| j
| j%d3| _&| j&jtddd4 t |d*td| j
d+jd7dtdddd t|d8t | j| j
d.}|jd9dtddd t || j
d
}|jd:ddt d1 t|d;d,| j
| j'd3| _(| j(jtddd4 t|d<d,| j
| j)d3| _*| j*jtddd4 t|d6d,| j
| j+d3| _,| j,jtddd4 d S )=Nr   )r    relief)sidefillT)r2   expandr3   ZClose)textcommandr   )padxpady)r&   )r4   r3   ZIDLE)Zcourier   Zbold)r5   r'   r&   Zfontr   
   )rowcolumnstickyr7   r8   infoZ
patchlevelz8.6z.pngz.gifZIconsZidle_48)Zmasterfile)Zimager&   )r;   r<   r=   Zrowspanr7   r8   z=Python's Integrated Development
and Learning Environment




)r5   Zjustifyr'   r&      )r;   r<   r=   
columnspanr7   r8   zemail:  idle-dev@python.org   )r;   r<   rA   r=   r7   r8   zhttps://docs.python.org/.z/library/idle.html   z
<Button-1>c                    s   t  d S )Nr5   )
webbrowseropen)eventZdocsr   r   <lambda>b       z,AboutDialog.create_widgets.<locals>.<lambda>   )r    r1   r#   r&      zPython version:  )r5   r'   r&   	   zTk version:  )r;   r<   rA   r=   ZLicense)r5   r$   Zhighlightbackgroundr6   )r2   r7   r8   Z	CopyrightZCredits   zIDLE version:         ZREADMEZNEWS)-r   r	   Zpackr   r   r
   r   r   r+   r-   r&   r   r'   Zgridr   ZtkZcallospathjoinabspathdirname__file__r   _rootZ
icon_imager   r   r*   rindexr.   r   r   show_py_licenseZ
py_licenseshow_py_copyrightZpy_copyrightshow_py_creditsZ
py_creditsshow_readmeZreadmeshow_idle_newsZ	idle_newsshow_idle_creditsZidle_credits)r0   frameZframe_buttonsZframe_backgroundheaderZtk_patchlevelZextZiconZlogoZbyline_textZbylineZemailZpyverZtkverZ
py_buttonsZidleverZidle_buttonsr   rH   r   r(   ?   s    




zAboutDialog.create_widgetsc                 C   s   |  dt dS )zHandle License button event.zAbout - LicenseN)display_printer_textlicenser0   r   r   r   rY      s    zAboutDialog.show_py_licensec                 C   s   |  dt dS )zHandle Copyright button event.zAbout - CopyrightN)ra   	copyrightrc   r   r   r   rZ      s    zAboutDialog.show_py_copyrightc                 C   s   |  dt dS )z#Handle Python Credits button event.zAbout - Python CreditsN)ra   creditsrc   r   r   r   r[      s    zAboutDialog.show_py_creditsc                 C   s   |  ddd dS )z!Handle Idle Credits button event.zAbout - CreditszCREDITS.txtutf-8Ndisplay_file_textrc   r   r   r   r^      s    zAboutDialog.show_idle_creditsc                 C   s   |  ddd dS )zHandle Readme button event.zAbout - Readmez
README.txtasciiNrg   rc   r   r   r   r\      s    zAboutDialog.show_readmec                 C   s   |  ddd dS )zHandle News button event.zAbout - NEWSzNEWS.txtrf   Nrg   rc   r   r   r   r]      s    zAboutDialog.show_idle_newsc                 C   s.   |   d|j}tj| ||| jd| _dS )a  Create textview for built-in constants.

        Built-in constants have type _sitebuiltins._Printer.  The
        text is extracted from the built-in and then sent to a text
        viewer with self as the parent and title as the title of
        the popup.
        
r   N)_Printer__setuprS   _Printer__linesr   Z	view_textr   r/   )r0   r)   Zprinterr5   r   r   r   ra      s
    
z AboutDialog.display_printer_textc                 C   s:   t jt jt jt|}tj| |||| jd| _	dS )zCreate textview for filename.

        The filename needs to be in the current directory.  The path
        is sent to a text viewer with self as the parent, title as
        the title of the popup, and the file encoding.
        rk   N)
rQ   rR   rS   rT   rU   rV   r   Z	view_filer   r/   )r0   r)   filenameencodingfnr   r   r   rh      s    zAboutDialog.display_file_textc                 C   s   |    |   dS )zDismiss help_about dialog.N)Zgrab_releaseZdestroy)r0   rG   r   r   r   r+      s    zAboutDialog.ok)N)N)N)__name__
__module____qualname____doc__r%   r(   rY   rZ   r[   r^   r\   r]   ra   rh   r+   r   r   r   r   r      s   "W
r   __main__)mainz!idlelib.idle_test.test_help_aboutr   F)	verbosityexit)run)!rt   rQ   r   rE   r   r   r   Ztkinterr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   Zidlelibr   r*   r   r   rq   Zunittestrv   Zidlelib.idle_test.htestry   r   r   r   r   <module>   s    0 6