Package Gnumed :: Package timelinelib :: Package wxgui :: Module setup
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.wxgui.setup

 1  # Copyright (C) 2009, 2010, 2011  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  from sys import version as python_version 
20  import platform 
21  import sys 
22  import traceback 
23   
24  import wx 
25   
26  from timelinelib.meta.version import get_version 
27  from timelinelib.wxgui.dialogs.mainframe import MainFrame 
28  from timelinelib.wxgui.dialogs.textdisplay import TextDisplayDialog 
29   
30   
31 -def start_wx_application(application_arguments, before_main_loop_hook=None):
32 app = wx.PySimpleApp() 33 main_frame = MainFrame(application_arguments) 34 main_frame.Show() 35 sys.excepthook = unhandled_exception_hook 36 if before_main_loop_hook: 37 before_main_loop_hook() 38 app.MainLoop()
39 40
41 -def unhandled_exception_hook(type, value, tb):
42 title = "Unexpected Error" 43 text = create_error_message(type, value, tb) 44 dialog = TextDisplayDialog(title, text) 45 dialog.ShowModal() 46 dialog.Destroy()
47 48
49 -def create_error_message(type, value, tb):
50 intro = create_intro_message() 51 exception = ("".join(traceback.format_exception(type, value, tb))).strip() 52 versions = create_versions_message() 53 return "%s\n\n%s\n\n%s" % (intro, exception, versions)
54 55
56 -def create_intro_message():
57 intro1 = ("An unexpected error has occurred. Please report this by copying " 58 "this error message and sending it to " 59 "thetimelineproj-user@lists.sourceforge.net.") 60 intro2 = ("It would also be useful if you can describe what you did just " 61 "before the error occurred.") 62 return "%s\n\n%s" % (intro1, intro2)
63 64
65 -def create_versions_message():
66 return "\n".join([ 67 "Timeline version: %s" % get_version(), 68 "System version: %s" % ", ".join(platform.uname()), 69 "Python version: %s" % python_version.replace("\n", ""), 70 "wxPython version: %s" % wx.version(), 71 ])
72