
    ը	f                     8   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZmZ ddlmZ ddlZddlZddlZ	 ddlmc mc mZ  G d	 d
ej8                        Zd Zd ZddZ e!dk(  r ejD                   e               yy# e$ r dZY Fw xY w)a  
@package wxgui

@brief Main Python application for GRASS wxPython GUI

Classes:
 - wxgui::GMApp

(C) 2006-2015 by the GRASS Development Team

This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.

@author Michael Barton (Arizona State University)
@author Jachym Cepicky (Mendel University of Agriculture)
@author Martin Landa <landa.martin gmail.com>
@author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
    )print_functionN)Usage)set_raise_on_errorwarningerror)	globalvar)registerPidunregisterPid)UserSettingsc                   ,     e Zd ZddZd Z fdZ xZS )GMAppc                     || _         t        j                  j                  | d       t        j                  t        j
                        | _        y)zNMain GUI class.

        :param workspace: path to the workspace file
        F)languageN)workspaceFilewxApp__init__LocaleLANGUAGE_DEFAULTlocale)self	workspaces     &/usr/lib/grass83/gui/wxpython/wxgui.pyr   zGMApp.__init__2   s6    
 ' 	e$ii)<)<=    c                 P     j                  d        j                  d       t        j                  j	                  t
        j                  d      }t        j                  |t        j                        }|j                         }t        j                  j                  |t        j                  j                  t        j                  j                  z  ddt        j                         t        j                          j#                           fd}t        j$                  |       y)	zGInitialize all available image handlers

        :return: True
        z	GRASS GISzThe GRASS Development Teamzsplash_screen.pngi  N)bitmapsplashStylemillisecondsparentidc                     t        j                  ddd      } | rddlm} nddlm} 	  |d t
        j                  j                        }|j                          j                  |       y # t        $ r}g d}t        j                  |      s[t        |       t        t        d	j!                  t
        j"                  d
j%                  t'        t(        |                               n Y d }~y d }~ww xY w)N
appearancesingleWindowenabled)groupkeysubkeyr   )GMFrame)r   r    r   )      r   zHCurrent version of wxPython {} is lower than minimum required version {}.)r   Getmain_window.framer(   
lmgr.framer   ID_ANYr   ShowSetTopWindow	Exceptionr   CheckWxVersionr   r   _format__version__joinmapstr)singler(   	mainframeerrmin_required_wx_versionr   s        r   show_main_guiz#GMApp.OnInit.<locals>.show_main_guiU   s    !%%"yF 5.-#BII9K9K	&  !!),#  *3' //0GH#J::@& " #S2I)J K; 	s   #A/ /	C78A5C22C7T)
SetAppNameSetVendorNameospathr7   r   IMGDIRr   ImageBITMAP_TYPE_PNGConvertToBitmapadvSplashScreenSPLASH_CENTRE_ON_SCREENSPLASH_TIMEOUTr/   GetAppYield	CallAfter)r   introImagePath
introImageintroBmpr>   s   `    r   OnInitzGMApp.OnInit>   s     	$78 i&6&68KLXXnb.@.@A
--/
669N9NNyy 	 	
 				-@ 	]#r   c                 Z    t        t        j                                t        |          S )zClean up on exit)r
   rA   getpidsuperOnExit)r   	__class__s    r   rU   zGMApp.OnExity   s    biik"w~r   N)__name__
__module____qualname__r   rQ   rU   __classcell__)rV   s   @r   r   r   1   s    
>9v   r   r   c                  (   t        dt        j                         t        dt        j                         t        dt        j                  z  t        j                         t        dt        j                         t        j
                  d       y)zPrint program helpzUsage:filez python wxgui.py [options]z
%sOptions:z+ -w	--workspace file	Workspace file to load   N)printsysstderrrA   linesepexit r   r   	printHelprf      sP    	($	
&SZZ8	,
##**5	
9

KHHQKr   c                     d}| D ];  \  }}|dv rt                |dv s|dk7  rt        |      }+|j                  d      }= |S )zProcess command-line argumentsN)z-hz--help)z-wz--workspace r   )rf   r9   pop)optsargsr   oas        r   process_optrn      sV    M ,1  K''Bw #A $, r   c                 \   | t         j                  } 	 	 t        j                  | dd  dddg      \  }}	 t              }t        |      }t        j                         }t        d       t        t        j                                 |j#                          y # t        j                  $ r}t	        |      d }~ww xY w# t        $ rc}t        |j                  t         j                         t        t         j                  dt         j                         t                Y d }~d }~ww xY w)Nr_   zhw:helpr   r]   zfor help use --helpT)ra   argvgetoptr   r   r`   msgrb   rf   rn   r   r   LogNullr   r	   rA   rS   MainLoop)rq   rj   rk   rs   r<   r   appqs           r   mainrx      s    |xx	tABx8MNJD$  d+M

C 	

At 		LLN# || 	*	 cggCJJ'cjj/cjjAs0   B B<,B77B<<B? ?	D+AD&&D+__main__rW   )#__doc__
__future__r   rA   ra   rr   grass.exceptionsr   grass.script.corer   r   r   corer   
core.utilsr	   r
   core.settingsr   r   wx.advwx.htmlwx.lib.agw.advancedsplashlibagwadvancedsplashSCImportErrorr   r   rf   rn   rx   rX   rd   re   r   r   <module>r      s   & & 	 
  # @ @  1 & 	
  **
K BFF K \ 4 zCHHTV K  	Bs   B BB