source: trunk/gui/scripts/bugreport.tcl @ 640

Last change on this file since 640 was 640, checked in by mmc, 18 years ago

Enhanced the <loader> to support upload/download for multiple inputs.
Also, added upload/download options to the right-mouse button menu
for <string> inputs. <string> inputs now accept binary data, so you
can use them to upload binary files.

File size: 4.8 KB
Line 
1# ----------------------------------------------------------------------
2#  UTILITY: bugreport
3#
4#  This redefines the usual Tcl bgerror command to install a nicer
5#  looking bug handler.
6# ======================================================================
7#  AUTHOR:  Michael McLennan, Purdue University
8#  Copyright (c) 2004-2006  Purdue Research Foundation
9#
10#  See the file "license.terms" for information on usage and
11#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12# ======================================================================
13
14option add *BugReport*banner*foreground white startupFile
15option add *BugReport*banner*background #a9a9a9 startupFile
16option add *BugReport*banner*highlightBackground #a9a9a9 startupFile
17option add *BugReport*banner*font \
18    -*-helvetica-bold-r-normal-*-*-180-* startupFile
19option add *BugReport*expl.font \
20    -*-helvetica-medium-r-normal-*-*-120-* startupFile
21option add *BugReport*expl.wrapLength 3i startupFile
22
23namespace eval Rappture::bugreport { # forward declaration }
24
25# ----------------------------------------------------------------------
26# USAGE: install
27#
28# Called once in the main program to install this bug reporting
29# facility.  Any unexpected errors after this call will be handled
30# by this mechanism.
31# ----------------------------------------------------------------------
32proc Rappture::bugreport::install {} {
33    proc ::bgerror {err} { ::Rappture::bugreport::activate $err }
34}
35
36# ----------------------------------------------------------------------
37# USAGE: activate <error>
38#
39# Used internally to pop up the bug handler whenver a bug is
40# encountered.  Tells the user that there is a bug and logs the
41# problem, so it can be fixed.
42# ----------------------------------------------------------------------
43proc Rappture::bugreport::activate {err} {
44    global errorInfo
45
46    set w [winfo reqwidth .bugreport]
47    set h [winfo reqheight .bugreport]
48    set x [expr {([winfo screenwidth .bugreport]-$w)/2}]
49    set y [expr {([winfo screenheight .bugreport]-$w)/2}]
50
51    wm geometry .bugreport +$x+$y
52    wm deiconify .bugreport
53    raise .bugreport
54
55    .bugreport.details.text configure -state normal
56    .bugreport.details.text delete 1.0 end
57    .bugreport.details.text insert end "$err\n-----\n$errorInfo"
58    .bugreport.details.text configure -state disabled
59    # should log the error someday too...
60
61    catch {grab set .bugreport}
62}
63
64# ----------------------------------------------------------------------
65# USAGE: deactivate
66#
67# Used internally to take down the bug handler dialog.
68# ----------------------------------------------------------------------
69proc Rappture::bugreport::deactivate {} {
70    grab release .bugreport
71    wm withdraw .bugreport
72
73    # reset the grab in case it's hosed
74    Rappture::grab::reset
75}
76
77# ----------------------------------------------------------------------
78# Build the bug reporting dialog
79# ----------------------------------------------------------------------
80toplevel .bugreport -class BugReport -borderwidth 1 -relief solid
81wm overrideredirect .bugreport 1
82wm withdraw .bugreport
83
84frame .bugreport.banner -background #a9a9a9
85pack .bugreport.banner -side top -fill x
86label .bugreport.banner.icon -image [Rappture::icon alert]
87pack .bugreport.banner.icon -side left -padx 2 -pady 2
88label .bugreport.banner.title -text "Oops! Unexpected Error"
89pack .bugreport.banner.title -side left -padx {0 8} -pady 2
90
91button .bugreport.ok -text "OK" -command Rappture::bugreport::deactivate
92pack .bugreport.ok -side bottom -pady {0 8}
93
94label .bugreport.expl -text "You've found a bug in this application.\n\nIf it's not a serious bug, you may be able to continue using the tool.  But if the tool doesn't seem to behave properly after this, please close this session and start the tool again.\n\nYou can help us improve nanoHUB by reporting this error.  Click on the \"Report Problems\" link in the web page containing this tool session, and tell us what you were doing when the error occurred." -justify left
95pack .bugreport.expl -padx 8 -pady 8
96
97bind .bugreport.expl <Control-1><Control-1><Control-3><Control-3> {
98    pack forget .bugreport.expl
99    pack .bugreport.details -after .bugreport.ok \
100        -expand yes -fill both -padx 8 -pady 8
101}
102
103bind .bugreport.expl <Control-1><Control-1><Control-Shift-1><Control-Shift-1> {
104    pack forget .bugreport.expl
105    pack .bugreport.details -after .bugreport.ok \
106        -expand yes -fill both -padx 8 -pady 8
107}
108
109Rappture::Scroller .bugreport.details -xscrollmode auto -yscrollmode auto
110text .bugreport.details.text -wrap none
111.bugreport.details contents .bugreport.details.text
112
113# this binding keeps the bugreport window on top
114bind BugReportOnTop <ButtonPress> {
115    wm deiconify %W
116    raise %W
117}
118set btags [bindtags .bugreport]
119bindtags .bugreport [linsert $btags 0 BugReportOnTop]
Note: See TracBrowser for help on using the repository browser.