summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2021-05-23 01:43:16 (GMT)
committerKevin Walzer <kw@codebykevin.com>2021-05-23 01:43:16 (GMT)
commita327016f886dab6a6fc066ead899d25c4234ff3f (patch)
tree86076511c955973aa8a1bf8cae720569b9199c65 /library
parent9527c3e096726a18167d4b2bc06aefed9424c1aa (diff)
downloadtk-a327016f886dab6a6fc066ead899d25c4234ff3f.zip
tk-a327016f886dab6a6fc066ead899d25c4234ff3f.tar.gz
tk-a327016f886dab6a6fc066ead899d25c4234ff3f.tar.bz2
Add print demo
Diffstat (limited to 'library')
-rw-r--r--library/demos/print.tcl47
1 files changed, 47 insertions, 0 deletions
diff --git a/library/demos/print.tcl b/library/demos/print.tcl
new file mode 100644
index 0000000..8ca4e37
--- /dev/null
+++ b/library/demos/print.tcl
@@ -0,0 +1,47 @@
+# print.tcl --
+#
+# This demonstration script showcases the tk print commands.
+#
+
+if {![info exists widgetDemo]} {
+ error "This script should be run from the \"widget\" demo."
+}
+
+set w .print
+destroy $w
+toplevel $w
+wm title $w "Printing Demonstration"
+positionWindow $w
+
+pack [label $w.l -text "This demonstration showcases
+ the tk print command. Clicking the buttons below
+ print the data from the canvas and text widgets
+ using platform-native dialogs."] -side top
+
+pack [frame $w.m] -fill both -expand yes -side top
+
+set c [canvas $w.m.c -bg white]
+pack $c -fill both -expand no -side left
+
+$c create rectangle 10 10 200 50 -fill blue -outline black
+$c create oval 10 60 200 110 -fill green
+$c create text 110 120 -anchor n -font {Helvetica 12} \
+ -text "A short demo of simple canvas elements."
+
+set txt {
+Tcl, or Tool Command Language, is an open-source multi-purpose C library which includes a powerful dynamic scripting language. Together they provide ideal cross-platform development environment for any programming project. It has served for decades as an essential system component in organizations ranging from NASA to Cisco Systems, is a must-know language in the fields of EDA, and powers companies such as FlightAware and F5 Networks.
+
+Tcl is fit for both the smallest and largest programming tasks, obviating the need to decide whether it is overkill for a given job or whether a system written in Tcl will scale up as needed. Wherever a shell script might be used Tcl is a better choice, and entire web ecosystems and mission-critical control and testing systems have also been written in Tcl. Tcl excels in all these roles due to the minimal syntax of the language, the unique programming paradigm exposed at the script level, and the careful engineering that has gone into the design of the Tcl internals.
+}
+
+set t [text $w.m.t -wrap word]
+pack $t -side right -fill both -expand no
+$t insert end $txt
+
+pack [frame $w.f] -side top -fill both -expand no
+pack [button $w.f.b -text "Print Canvas" -command [list tk print canvas $w.c]] -expand no
+pack [button $w.f.x -text "Print Text" -command [list tk print text $w.t]] -expand no
+
+## See Code / Dismiss buttons
+pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
+