summaryrefslogtreecommitdiffstats
path: root/library/demos/widget
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2021-08-17 01:26:57 (GMT)
committerKevin Walzer <kw@codebykevin.com>2021-08-17 01:26:57 (GMT)
commit5517a55841bc438a22c223c9939a82de2216ce90 (patch)
treeb4282e765deed55e2f454c54643d3d70c06edda9 /library/demos/widget
parente02bd57b0aed182ae341187acb8f95ed67c79710 (diff)
parentafebfdae93a386738cbe2bf3e1737349d4a73c24 (diff)
downloadtk-5517a55841bc438a22c223c9939a82de2216ce90.zip
tk-5517a55841bc438a22c223c9939a82de2216ce90.tar.gz
tk-5517a55841bc438a22c223c9939a82de2216ce90.tar.bz2
Merge trunk
Diffstat (limited to 'library/demos/widget')
-rw-r--r--library/demos/widget80
1 files changed, 5 insertions, 75 deletions
diff --git a/library/demos/widget b/library/demos/widget
index e56954d..354ac3f 100644
--- a/library/demos/widget
+++ b/library/demos/widget
@@ -388,6 +388,8 @@ addFormattedText {
@@demo fontchoose Font selection dialog
@@new
@@demo systray System tray icon and notification
+ @@new
+ @@demo print Printing from canvas and text widgets
@@subtitle Animation
@@demo anilabel Animated labels
@@ -643,80 +645,7 @@ proc showCode w {
# file - Name of the original file (implicitly for title)
proc printCode {w file} {
- set code [$w get 1.0 end-1c]
-
- set dir "."
- if {[info exists ::env(HOME)]} {
- set dir "$::env(HOME)"
- }
- if {[info exists ::env(TMP)]} {
- set dir $::env(TMP)
- }
- if {[info exists ::env(TEMP)]} {
- set dir $::env(TEMP)
- }
-
- set filename [file join $dir "tkdemo-$file"]
- set outfile [open $filename "w"]
- puts $outfile $code
- close $outfile
-
- switch -- $::tcl_platform(platform) {
- unix {
- if {[catch {exec lp -c $filename} msg]} {
- tk_messageBox -title "Print spooling failure" \
- -message "Print spooling probably failed: $msg"
- }
- }
- windows {
- if {[catch {PrintTextWin32 $filename} msg]} {
- tk_messageBox -title "Print spooling failure" \
- -message "Print spooling probably failed: $msg"
- }
- }
- default {
- tk_messageBox -title "Operation not Implemented" \
- -message "Wow! Unknown platform: $::tcl_platform(platform)"
- }
- }
-
- #
- # Be careful to throw away the temporary file in a gentle manner ...
- #
- if {[file exists $filename]} {
- catch {file delete $filename}
- }
-}
-
-# PrintTextWin32 --
-# Print a file under Windows using all the "intelligence" necessary
-#
-# Arguments:
-# filename - Name of the file
-#
-# Note:
-# Taken from the Wiki page by Keith Vetter, "Printing text files under
-# Windows".
-# Note:
-# Do not execute the command in the background: that way we can dispose of the
-# file smoothly.
-#
-proc PrintTextWin32 {filename} {
- package require registry
- set app [auto_execok notepad.exe]
- set pcmd "$app /p %1"
- catch {
- set app [registry get {HKEY_CLASSES_ROOT\.txt} {}]
- set pcmd [registry get \
- {HKEY_CLASSES_ROOT\\$app\\shell\\print\\command} {}]
- }
-
- regsub -all {%1} $pcmd $filename pcmd
- puts $pcmd
-
- regsub -all {\\} $pcmd {\\\\} pcmd
- set command "[auto_execok start] /min $pcmd"
- eval exec $command
+ tk print $w
}
# tkAboutDialog --
@@ -729,7 +658,8 @@ proc tkAboutDialog {} {
"[mc "Copyright © %s" {1996-1997 Sun Microsystems, Inc.}]
[mc "Copyright © %s" {1997-2000 Ajuba Solutions, Inc.}]
[mc "Copyright © %s" {2001-2009 Donal K. Fellows}]
-[mc "Copyright © %s" {2002-2007 Daniel A. Steffen}]"
+[mc "Copyright © %s" {2002-2007 Daniel A. Steffen}]
+[mc "Copyright © %s" {2021 Kevin Walzer}]"
}
# Local Variables: