Przeglądaj źródła

wxGUI: reusable about dialog, not translatable

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57138 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 11 lat temu
rodzic
commit
83d69cc747

+ 2 - 12
gui/wxpython/gmodeler/frame.py

@@ -23,7 +23,6 @@ import os
 import sys
 import time
 import stat
-import textwrap
 import tempfile
 import copy
 import re
@@ -41,6 +40,7 @@ from gui_core.goutput     import GConsoleWindow
 from core.debug           import Debug
 from core.gcmd            import GMessage, GException, GWarning, GError, RunCommand
 from gui_core.dialogs     import GetImageHandlers
+from gui_core.ghelp       import ShowAboutDialog
 from gui_core.preferences import PreferencesBaseDialog
 from core.settings        import UserSettings
 from gui_core.menu        import Menu
@@ -720,17 +720,7 @@ class ModelFrame(wx.Frame):
 
     def OnAbout(self, event):
         """!Display About window"""
-        info = wx.AboutDialogInfo()
-
-        info.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
-        info.SetName(_('wxGUI Graphical Modeler'))
-        info.SetWebSite('http://grass.osgeo.org')
-        year = grass.version()['date']
-        info.SetDescription(_('(C) 2010-%s by the GRASS Development Team\n\n') % year + 
-                            '\n'.join(textwrap.wrap(_('This program is free software under the GNU General Public License'
-                                                      '(>=v2). Read the file COPYING that comes with GRASS for details.'), 75)))
-        
-        wx.AboutBox(info)
+        ShowAboutDialog(prgName=_('wxGUI Graphical Modeler'), startYear='2010')
         
     def GetOptData(self, dcmd, layer, params, propwin):
         """!Process action data"""

+ 19 - 0
gui/wxpython/gui_core/ghelp.py

@@ -21,6 +21,7 @@ import os
 import codecs
 import platform
 import re
+import textwrap
 
 import wx
 from wx.html import HtmlWindow
@@ -773,3 +774,21 @@ class HelpPanel(wx.Panel):
         self.OnHistory()
         
         event.Skip()
+
+def ShowAboutDialog(prgName, startYear):
+    """!Displays About window.
+
+    @param prgName name of the program
+    @param startYear the first year of existence of the program
+    """
+    info = wx.AboutDialogInfo()
+    
+    info.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
+    info.SetName(prgName)
+    info.SetWebSite('http://grass.osgeo.org')
+    year = grass.version()['date']
+    info.SetDescription('(C) %(start)s-%(end)s by the GRASS Development Team\n\n' % {'start': startYear, 'end': year} +
+                        '\n'.join(textwrap.wrap('This program is free software under the GNU General Public License'
+                                                '(>=v2). Read the file COPYING that comes with GRASS for details.', 75)))
+    
+    wx.AboutBox(info)

+ 2 - 11
gui/wxpython/psmap/frame.py

@@ -17,7 +17,6 @@ This program is free software under the GNU General Public License
 
 import os
 import sys
-import textwrap
 import Queue
 from math import sin, cos, pi, sqrt
 
@@ -38,6 +37,7 @@ from core.gcmd          import RunCommand, GError, GMessage
 from core.settings      import UserSettings
 from gui_core.forms     import GUI
 from gui_core.dialogs   import HyperlinkDialog
+from gui_core.ghelp     import ShowAboutDialog
 from psmap.menudata     import PsMapMenuData
 
 from psmap.dialogs      import *
@@ -1062,16 +1062,7 @@ class PsMapFrame(wx.Frame):
         
     def OnAbout(self, event):
         """!Display About window"""
-        info = wx.AboutDialogInfo()
-        
-        info.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
-        info.SetName(_('wxGUI Cartographic Composer'))
-        info.SetWebSite('http://grass.osgeo.org')
-        info.SetDescription(_('(C) 2011 by the GRASS Development Team\n\n') + 
-                            '\n'.join(textwrap.wrap(_('This program is free software under the GNU General Public License'
-                                                      '(>=v2). Read the file COPYING that comes with GRASS for details.'), 75)))
-        
-        wx.AboutBox(info)
+        ShowAboutDialog(prgName=_('wxGUI Cartographic Composer'), startYear='2011')
 
     def OnCloseWindow(self, event):
         """!Close window"""