Author: Kevin Walzer <[email protected]> State: Draft Type: Project Created: 03-July-2021 Keywords: Tk, desktop integration Tcl-Version: 8.7 Tk-Branch: tk_print
Most GUI tookits provide an interface to send graphic and text output to a device such as a laser printer. Various extensions and command-line calls have allowed Tk to have rudimentary printing support, but there has never been a consistent API within Tk to offer printing. This TIP proposes to establish a consistent API in Tk to support printing with platform-native dialogs when possible, and with a Tk dialog to drive command-line configuration on other platforms.
Windows: GDI https://wiki.tcl-lang.org/page/GDI
X11: New development
Mac: Cocoaprint https://wiki.tcl-lang.org/page/cocoaprint
Existing code from the GDI and cocoaprint extension packages has been refactored and ported into Tk's core; the authors have granted permission to incorporate their code under Tk's BSD-style license. The X11 development will be a Tk dialog that will drive the "lpr" or "lp" commands.
The tk print commands will present a script-level public API implementing the proposed interface, outlined below.
tk print window
This command prints the contents of a canvas or text widget.
A full demonstration of these commands in action has been added to the Tk widget demo under the "Common Dialogs" section, "Printing from canvas and text widgets." Since the API is very simple, one can get a better understanding of the functionality by actually testing it in the demo.
A draft implementation is currently under development in the tk_print branch.
This document has been placed in the public domain.