ó
Ñ%�Tc           @   sS   d  Z  d d l m Z m Z m Z m Z m Z d d l Z d d „ Z	 d „  Z
 d S(   se   Create a select map dialog box, similar to Coot's show_select_map_dialog(), but allow for a callback.iÿÿÿÿ(   t   molecule_namet   graphics_n_moleculest   is_valid_map_moleculet   imol_refinement_mapt   set_imol_refinement_mapNc         C   s‹  g  } x3 t  t ƒ  ƒ D]" } t | ƒ r | j | ƒ q q Wt | ƒ d k r– t j d t j d t j d d ƒ } | j	 d ƒ | j
 ƒ  | j ƒ  nñt j d d d t j t j f ƒ } t j t t ƒ } x5 | D]- } | j | t | ƒ d	 t | ƒ g ƒ qÓ Wt j | ƒ } t j ƒ  } | j | t ƒ | j | d
 d ƒ t ƒ  } | d k ryt | d d ƒ | j d ƒ n3 g  | D] }	 |	 d ^ q€j | ƒ }
 | j |
 ƒ | j d t ƒ t j d ƒ } t j ƒ  } t j  t! d ƒ } | j" | ƒ | j | t! t! d ƒ | j | t! t! d ƒ | j# j | t! t! d ƒ | j# j$ ƒ  |  d k	 rsd „  } | j d | |  ƒ n  | j
 ƒ  | j ƒ  d S(   s©   Display a GUI for selecting the refinement map.
    
    OPTIONAL ARGUMENTS:
        callback - a function to call when the user clicks OK
    RETURNS:
        None
    i    t   typet   buttonst   message_formats&   Please load a map before using RCrane.s   RCrane Errort   titles   Select Map for Fittingt    t   texti   iÿÿÿÿt   changeds   Choose a Map:i   c         S   s   | t  j k r | ƒ  n  d  S(   N(   t   gtkt   RESPONSE_OK(   t   dialogt
   responseIDt   callback(    (    s]   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/coot/rcrane/selectMapDialog.pyt   checkResponseV   s     t   responseN(&   t   xrangeR   R   t   appendt   lenR   t   MessageDialogt   MESSAGE_ERRORt
   BUTTONS_OKt	   set_titlet   runt   destroyt   Dialogt   STOCK_OKR   t	   ListStoret   intt   strR    t   ComboBoxt   CellRendererTextt
   pack_startt   Truet   add_attributeR   R   t
   set_activet   indext   connectt   __changeMapt   Labelt   Framet   VBoxt   Falset   addt   vboxt   show_allt   None(   R   t   mapListt   imolt   warningMessageR   t   mapListStoret   mapCombot	   mapRendert
   currentMapt   it
   comboIndext   chooseLabelt   framet   frameBoxR   (    (    s]   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/coot/rcrane/selectMapDialog.pyt   selectMapDialog   sJ    
$
$+	&	
c         C   s8   |  j  ƒ  } |  j ƒ  } | j | d ƒ } t | ƒ d S(   sÚ   Respond to the user selecting a map
        
    ARGUMENTS:
        mapCombo - the ComboBox object for map selection
    RETURNS:
        None
    EFFECTS:
        sets the refinement map to the newly selected map
    i    N(   t	   get_modelt   get_active_itert	   get_valueR   (   R6   R5   t   selectedMapItert   selectedImol(    (    s]   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/coot/rcrane/selectMapDialog.pyR)   _   s    (   t   __doc__t   cootR    R   R   R   R   R   R1   R>   R)   (    (    (    s]   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/coot/rcrane/selectMapDialog.pyt   <module>   s   (I