diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2009-01-08 16:31:03 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2009-01-08 16:31:03 (GMT) |
commit | 37fc00153a9ac8302e97fd63fd746ae3038d6863 (patch) | |
tree | 94b8fd11fb8fb71c427fcff9c02385d0e621c4fb | |
parent | d03aad70ca68aa4c46be2ee07277dcf0f5cfe411 (diff) | |
download | tk-37fc00153a9ac8302e97fd63fd746ae3038d6863.zip tk-37fc00153a9ac8302e97fd63fd746ae3038d6863.tar.gz tk-37fc00153a9ac8302e97fd63fd746ae3038d6863.tar.bz2 |
Themed the bgerror dialog and make use of our PNG support to improve the icon.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | library/bgerror.tcl | 118 |
2 files changed, 82 insertions, 41 deletions
@@ -1,3 +1,8 @@ +2009-01-08 Pat Thoyts <patthoyts@users.sourceforge.net> + + * library/bgerror.tcl: Theme the bgerror dialog and make use of + our PNG support to improve the icon. + 2009-01-07 Pat Thoyts <patthoyts@users.sourceforge.net> * library/tkfbox.tcl: [Bug 2473120] mis-ordered messagebox args. diff --git a/library/bgerror.tcl b/library/bgerror.tcl index a169e8c..029f44c 100644 --- a/library/bgerror.tcl +++ b/library/bgerror.tcl @@ -9,9 +9,10 @@ # Copyright (c) 1998-2000 by Ajuba Solutions. # Copyright (c) 2007 by ActiveState Software Inc. # Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net> +# Copyright (c) 2009 Pat Thoyts <patthoyts@users.sourceforge.net> # -# RCS: @(#) $Id: bgerror.tcl,v 1.38 2007/12/13 15:26:26 dgp Exp $ -# $Id: bgerror.tcl,v 1.38 2007/12/13 15:26:26 dgp Exp $ +# RCS: @(#) $Id: bgerror.tcl,v 1.39 2009/01/08 16:31:03 patthoyts Exp $ +# namespace eval ::tk::dialog::error { namespace import -force ::tk::msgcat::* @@ -29,6 +30,46 @@ namespace eval ::tk::dialog::error { } } +image create photo ::tk::dialog::error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ABOA + ROssCDQABAB8AF6cYT2GrgKoMnO05W8cixAAjBjkxHcrthZYA4gAhAm4FwsI + ecBf1t8Bael4x3h6yMUAAAAASUVORK5CYII= +} + proc ::tk::dialog::error::Return {} { variable button @@ -56,19 +97,19 @@ proc ::tk::dialog::error::SaveToLog {text} { } else { set allFiles * } - set types [list \ - [list [mc "Log Files"] .log] \ - [list [mc "Text Files"] .txt] \ + set types [list \ + [list [mc "Log Files"] .log] \ + [list [mc "Text Files"] .txt] \ [list [mc "All Files"] $allFiles] \ ] set filename [tk_getSaveFile -title [mc "Select Log File"] \ -filetypes $types -defaultextension .log -parent .bgerrorDialog] - if {![string length $filename]} { - return + if {$filename ne {}} { + set f [open $filename w] + puts -nonewline $f $text + close $f } - set f [open $filename w] - puts -nonewline $f $text - close $f + return } proc ::tk::dialog::error::Destroy {w} { @@ -79,13 +120,15 @@ proc ::tk::dialog::error::Destroy {w} { } # ::tk::dialog::error::bgerror -- -# This is the default version of bgerror. -# It tries to execute tkerror, if that fails it posts a dialog box containing -# the error message and gives the user a chance to ask to see a stack -# trace. +# +# This is the default version of bgerror. +# It tries to execute tkerror, if that fails it posts a dialog box +# containing the error message and gives the user a chance to ask +# to see a stack trace. +# # Arguments: -# err - The error message. - +# err - The error message. +# proc ::tk::dialog::error::bgerror err { global errorInfo tcl_platform variable button @@ -133,8 +176,9 @@ proc ::tk::dialog::error::bgerror err { # and bottom parts. set dlg .bgerrorDialog + set bg [ttk::style lookup . -background] destroy $dlg - toplevel $dlg -class ErrorDialog + toplevel $dlg -class ErrorDialog -background $bg wm withdraw $dlg wm title $dlg $title wm iconname $dlg ErrorDialog @@ -144,23 +188,23 @@ proc ::tk::dialog::error::bgerror err { ::tk::unsupported::MacWindowStyle style $dlg moveableAlert {} } - frame $dlg.bot - frame $dlg.top + ttk::frame $dlg.bot + ttk::frame $dlg.top if {$windowingsystem eq "x11"} { - $dlg.bot configure -relief raised -bd 1 - $dlg.top configure -relief raised -bd 1 + #$dlg.bot configure -relief raised -border 1 + #$dlg.top configure -relief raised -border 1 } pack $dlg.bot -side bottom -fill both pack $dlg.top -side top -fill both -expand 1 - set W [frame $dlg.top.info] + set W [ttk::frame $dlg.top.info] text $W.text -setgrid true -height 10 -wrap char \ -yscrollcommand [list $W.scroll set] if {$windowingsystem ne "aqua"} { $W.text configure -width 40 } - scrollbar $W.scroll -command [list $W.text yview] + ttk::scrollbar $W.scroll -command [list $W.text yview] pack $W.scroll -side right -fill y pack $W.text -side left -expand yes -fill both $W.text insert 0.0 "$err\n$info" @@ -175,17 +219,9 @@ proc ::tk::dialog::error::bgerror err { # ...minus the width of the icon, padding and a fudge factor for # the window manager decorations and aesthetics. set wrapwidth [expr {$wrapwidth-60-[winfo pixels $dlg 9m]}] - label $dlg.msg -justify left -text $text -wraplength $wrapwidth - if {$windowingsystem eq "aqua"} { - # On the Macintosh, use the stop bitmap - label $dlg.bitmap -bitmap stop - } else { - # On other platforms, make the error icon - canvas $dlg.bitmap -width 32 -height 32 -highlightthickness 0 - $dlg.bitmap create oval 0 0 31 31 -fill red -outline black - $dlg.bitmap create line 9 9 23 23 -fill white -width 4 - $dlg.bitmap create line 9 23 23 9 -fill white -width 4 - } + ttk::label $dlg.msg -justify left -text $text -wraplength $wrapwidth + ttk::label $dlg.bitmap -image ::tk::dialog::error::image::stop + grid $dlg.bitmap $dlg.msg -in $dlg.top -row 0 -padx 3m -pady 3m grid configure $dlg.msg -sticky nsw -padx {0 3m} grid rowconfigure $dlg.top 1 -weight 1 @@ -195,7 +231,7 @@ proc ::tk::dialog::error::bgerror err { set i 0 foreach {name caption} $buttons { - button $dlg.$name -text $caption -default normal \ + ttk::button $dlg.$name -text $caption -default normal \ -command [namespace code [list set button $i]] grid $dlg.$name -in $dlg.bot -column $i -row 0 -sticky ew -padx 10 grid columnconfigure $dlg.bot $i -weight 1 @@ -219,7 +255,11 @@ proc ::tk::dialog::error::bgerror err { ::tk::PlaceWindow $dlg - # 7. Ensure that we are topmost. + # 7. Set a grab and claim the focus too. + + ::tk::SetFocusGrab $dlg $dlg.ok + + # 8. Ensure that we are topmost. raise $dlg if {$tcl_platform(platform) eq "windows"} { @@ -227,13 +267,9 @@ proc ::tk::dialog::error::bgerror err { # order to ensure that it's seen if {[lindex [wm stackorder .] end] ne "$dlg"} { wm attributes $dlg -topmost 1 - } + } } - # 8. Set a grab and claim the focus too. - - ::tk::SetFocusGrab $dlg $dlg.ok - # 9. Wait for the user to respond, then restore the focus and # return the index of the selected button. Restore the focus # before deleting the window, since otherwise the window manager |