m
"4@c           @   s   d  Z  d k Td k Z d k Z d k Z d e i f d     YZ d e f d     YZ e d j o e d d	  Z	 e	 i
   n d S(
   s  
AppShell class provides a GUI application framework.
AppShell is from the excellent book "Python and Tkinter Programming"
by John E. Grayson.

This is a streamlined adaptation of GuiAppD.py, originally
created by Doug Hellmann (doughellmann@mindspring.com).

(   t   *Nt   AppShellc           B   sj  t  Z d Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
 Z d Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d  d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d    Z# d!   Z$ d  d"  Z% d#   Z& d$   Z' d  d  d%  Z( d&   Z) d'   Z* d(   Z+ d)   Z, RS(*   Ns   1.0s   Generic Application Frames0   Copyright YYYY Your Company. All Rights Reserveds	   Your Names   youremail@host.comi  i@  i   i    i   t   watchc         K   s3  d d t  i f d d t  i f d d t  i f d d t  i f d |  i t  i f f } |  i | |  t   |  _ |  i	 |  i  t  i
 |  i  |  i i |  i  |  i i d |  i |  i f  t  i i |  d |  i |  i   |  i   d  |  _ |  i i d	 t d
 t d t  |  i   |  i t  d  S(   Nt   padxi   t   padyt
   framewidtht   frameheightt   usecommandareas   %dx%dt   parentt   sidet   fillt   expand(   t   Pmwt   INITOPTt   selfR   t
   optiondefst   defineoptionst   kwt   Tkt   roott   initializeTkt
   initialiset   titlet   appnamet   geometryt
   frameWidtht   frameHeightt
   MegaWidgett   __init__t   appInitt   _AppShell__createInterfacet   Nonet   preBusyCursorst   _hullt   packt   TOPt   BOTHt   YESt	   focus_sett   initialiseoptionsR   (   R   R   R   (    (    t&   /home/fenn/3d/cadvas-0.2.2/AppShell.pyR   !   s    T 

	
c         C   s   d  S(   N(    (   R   (    (    R(   R   E   s    c         C   sS   t  i d j o |  i |  n/ t  i d j o |  i |  n |  i |  d  S(   Nt   mact   win32(   t   syst   platformR   t   _AppShell__initializeTk_macR   t   _AppShell__initializeTk_win32t   _AppShell__initializeTk_unix(   R   R   (    (    R(   R   I   s
    c         C   s   | i d d  | i d d  | i d d  | i d d  | i d d	  | i d
 d  | i d d  | i d d  d  S(   Ns   *backgroundt   greys   *foregroundt   blacks   *EntryField.Entry.backgroundt   whites   *Entry.backgrounds   *MessageBar.Entry.backgroundt   gray85s   *Listbox*backgrounds   *Listbox*selectBackgrounds   dark slate blues   *Listbox*selectForeground(   R   t
   option_add(   R   R   (    (    R(   t   __initializeTk_colors_commonR   s    c         C   s1   |  i |  | i d d  | i d d  d  S(   Ns   *EntryField.Entry.Fonts
   Courier 10s   *Listbox*Font(   R   t%   _AppShell__initializeTk_colors_commonR   R4   (   R   R   (    (    R(   t   __initializeTk_win32\   s    c         C   s   |  i |  d  S(   N(   R   R6   R   (   R   R   (    (    R(   t   __initializeTk_macb   s    c         C   s   |  i |  d  S(   N(   R   R6   R   (   R   R   (    (    R(   t   __initializeTk_unixe   s    c         C   sl   | p |  i } n h  } x9 |  i D]. } | d | | <| i d |  | i   q$ W| |  i f |  _ d  S(   Nt   cursor(	   t	   newcursorR   t
   busyCursort   newPreBusyCursorst   busyWidgetst	   componentt	   configuret   update_idletasksR    (   R   R;   R?   R=   (    (    R(   t	   busyStarth   s    
 c         C   s   |  i p d  Sn |  i d } |  i d |  _ xI |  i D]> } y | i d | |  Wn t j
 o n X| i   q9 Wd  S(   Ni    i   R:   (   R   R    t   oldPreBusyCursorsR>   R?   R@   t   KeyErrorRA   (   R   RC   R?   (    (    R(   t   busyEndr   s    

 c         C   sl   t  i |  i  t  i |  i  t  i d |  i |  i f  t  i	 |  i
 d |  i |  _ |  i i   d  S(   Ns-   For more information, contact:
 %s
 Email: %st   applicationname(   R   t   aboutversionR   t
   appversiont   aboutcopyrightt	   copyrightt   aboutcontactt   contactnamet   contactemailt   AboutDialogR!   R   t   aboutt   withdrawR   (   R   (    (    R(   t   __createAboutBox~   s    c         C   s   |  i i   |  i i   d  S(   N(   R   RO   t   showR&   (   R   (    (    R(   t	   showAbout   s    c         C   s>   |  i i   o |  i i d d  n |  i i d d  d  S(   Nt   statet   balloont   none(   R   t   toggleBalloonVart   gett   _AppShell__balloonR@   (   R   (    (    R(   t   toggleBalloon   s    c         C   s   |  i d f  d  t i |  i f d t d d d |  i   |  _ |  i i	 d t
  |  i i d d |  i d	 d
 |  i i d d  d  S(   Nt   menubart   hull_relieft   hull_borderwidthi   RU   R
   t   Helps   About %sR	   t   rightt   Files   File commands and Exit(   R   t   createcomponentR   R   t   MenuBarR!   t   RAISEDRU   t   menuBarR"   t   Xt   addmenuR   (   R   (    (    R(   t   __createMenuBar   s    	 c      
   C   s   |  i i d d d d d d |  i t   |  _ |  i i d  |  i i d d d d d	 d
 |  i d |  i |  i i d d d d d d |  i d  S(   NR^   t   commands   Get information on applicationt   labels   About...i   t   checkbuttons   Toggle balloon helps   Balloon helpt   variableR`   s   Quit this applicationt   Quit(	   R   Rd   t   addmenuitemRS   t   IntVarRW   t   setRZ   t   quit(   R   (    (    R(   t   createMenuBar   s    	c         C   s+   |  i d f  d  t i |  i f  |  _ d  S(   NRU   (   R   Ra   R   R   t   BalloonR!   RY   (   R   (    (    R(   t   __createBalloon   s    c         C   s   |  i S(   N(   R   RY   (   R   (    (    R(   RU      s    c         C   sg   |  i d f  d  t |  i f d t d d |  _ |  i i d t d t	 d t
 d |  d d	 |  d	  d  S(
   Nt   dataareat   relieft   bdi   R	   R
   R   R   R   (   R   Ra   R   t   FrameR!   t   GROOVEt   dataAreaR"   R#   R$   R%   (   R   (    (    R(   t   __createDataArea   s    	c         C   s   |  i d f  d  t |  i f d t d d |  _ |  i d f  d  t i |  i f d d d d |  _	 |  i	 i
 d	 t d
 t d t  |  d o7 |  i i
 d	 t d
 t d t d |  d d |  d  n d  S(   Nt   commandframeRu   Rv   i   t	   buttonboxR   i    R   R	   R   R
   R   (   R   Ra   R   Rw   R!   t   SUNKENt   _AppShell__commandFrameR   t	   ButtonBoxt   _AppShell__buttonBoxR"   R#   t   NORe   (   R   (    (    R(   t   __createCommandArea   s     		
c         C   sg  |  i d f  d  t |  i f d t } |  i d f  d  t | f  |  _ |  i i	 d t
 d t d t  |  i i d |  i  |  i i d |  i  |  i d	 f  d  t i | f d
 t d d d d  |  _ |  i i	 d t
 d t d t  |  i d f  d  t | f d d |  _ |  i i	 d t d t d t  | i	 d t d t d t  |  i i d |  i i  d  S(   Nt
   bottomtrayRu   t   entryR	   R   R
   s   <KeyPress-Return>s   <KeyPress-KP_Enter>t
   messagebart   entry_relieft   entry_bdi   t   labelpost
   unitslabelt   texts	   Units: mmt   statuscommand(   R   Ra   R   Rw   R!   R}   t   framet   EntryR   R"   t   LEFTR   t   NONEt   bindt   keybrdEntryR   t
   MessageBart   _AppShell__messageBarR%   Re   t   Labelt   unitsDisplayt   RIGHTt   BOTTOMRY   R@   t   helpmessage(   R   R   (    (    R(   t   __createMessageBar   s0    				c         C   s   |  i i |  d  S(   N(   R   R   R   R   (   R   R   (    (    R(   t   updateMessageBar   s    c         C   s   |  i S(   N(   R   R   (   R   (    (    R(   t
   messageBar   s    c         C   s,   |  i i   } |  i i d t |   d S(   s   Override this method in app.i    N(   R   R   RX   R   t   deletet   len(   R   t   eventR   (    (    R(   R      s     c         C   s   |  i i | | |  d  S(   N(   R   RY   R   t   childt   balloonHelpMsgt   statusHelpMsg(   R   R   R   R   (    (    R(   R     s    c         C   s   |  i S(   N(   R   Ry   (   R   (    (    R(   t   interior  s    c         C   s   |  i S(   N(   R   R   (   R   (    (    R(   t	   buttonBox  s    c         K   sA   |  i i |  } | i |  | o |  i | | |  n | S(   N(
   R   R   t   addt
   buttonNamet   newBtnR@   R   t   helpMessageR   t   statusMessage(   R   R   R   R   R   R   (    (    R(   t	   buttonAdd  s
    c         C   sc   |  i   |  i   |  i   |  i   |  i   |  i   |  i f |  _ |  i	   |  i
   d  S(   N(   R   t   _AppShell__createBalloont   _AppShell__createMenuBart   _AppShell__createDataAreat   _AppShell__createCommandAreat   _AppShell__createMessageBart   _AppShell__createAboutBoxR   R>   Rq   t   createInterface(   R   (    (    R(   t   __createInterface  s    






c         C   s   d  S(   N(    (   R   (    (    R(   R   '  s    c         C   s   |  i   |  i   d  S(   N(   R   R"   t   mainloop(   R   (    (    R(   t   main+  s    
c         C   s   |  i   d  S(   N(   R   R   (   R   (    (    R(   t   run0  s    (-   t   __name__t
   __module__RH   R   RJ   RL   RM   R   R   R   R   R   t   balloonhelpR<   R   R   R   R6   R.   R-   R/   R   RB   RE   R   RS   RZ   R   Rq   R   RU   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    R(   R      sT   	$				
			
									
		!									t   TestAppShellc           B   s)   t  Z d Z d   Z d   Z d   Z RS(   Ni   c         C   s&   |  i d d d d d d |  i d  S(   Nt   OkR   t   ExitR   Rh   (   R   R   Rp   (   R   (    (    R(   t   createButtons6  s    	c         C   sQ   |  i d f  d  t |  i   f d d |  _ |  i i   |  i |  i d  d  S(   NRi   R   s	   Data Areas   Space taker(   R   Ra   R   R   R   Ri   R"   R   (   R   (    (    R(   t
   createMain<  s    c         C   s%   t  i |   |  i   |  i   d  S(   N(   R   R   R   R   R   (   R   (    (    R(   R   D  s    
(   R   R   R   R   R   R   (    (    (    R(   R   3  s   		t   __main__t   balloon_statet   both(   t   __doc__t   TkinterR   R+   t   stringR   R   R   R   t   testR   (   R   R   R+   R   R   R   (    (    R(   t   ?   s   	 #
