
Rendering Tcl/Tk Windows as HTML Wilfred J. Hansen February 2003 COTS-Based Systems Initiative Since its initial release, this report has been revised to correct a few inaccuracies. This revision was released March 5, 2003. Unlimited distribution subject to the copyright. Technical Note CMU/SEI-2003-TN-002 The Software Engineering Institute is a federally funded research and development center sponsored by the U.S. Department of Defense. Copyright 2003 by Carnegie Mellon University. NO WARRANTY THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. Use of any trademarks in this report is not intended in any way to infringe on the rights of the trademark holder. Internal use. Permission to reproduce this document and to prepare derivative works from this document for internal use is granted, provided the copyright and “No Warranty” statements are included with all reproductions and derivative works. External use. Requests for permission to reproduce this document or prepare derivative works of this document for external and commercial use should be addressed to the SEI Licensing Agent. This work was created in the performance of Federal Government Contract Number F19628-00-C-0003 with Carnegie Mellon University for the operation of the Software Engineering Institute, a federally funded research and development center. The Government of the United States has a royalty-free government-purpose license to use, duplicate, or disclose the work, in whole or in part and in any manner, and to have or permit others to do so, for government purposes pursuant to the copyright license under the clause at 252.227-7013. For information about purchasing paper copies of SEI reports, please visit the publications portion of our Web site (http://www.sei.cmu.edu/publications/pubWeb.html). printed 3/5/2003 9:07 AM version number / editor’s initials Contents 1 Introduction....................................................................................................1 2 Example of the Approach..............................................................................3 3 Implementation ..............................................................................................6 4 What Has Been Demonstrated......................................................................7 5 Why a Full Conversion Will Be Harder .........................................................8 Conclusion.........................................................................................................10 References .........................................................................................................11 CMU/SEI-2003-TN-002 i ii CMU/SEI-2003-TN-002 List of Figures Figure 1: A Data Entry Form with Label and Field Widgets................................3 Figure 2: Tcl/Tk Code for the Data Entry Example..............................................4 Figure 3: The Image Displayed by a Browser.....................................................5 Figure 4: The HTML Generated by the Modified Tcl/Tk Processor......................5 CMU/SEI-2003-TN-002 iii iv CMU/SEI-2003-TN-002 Abstract Tool Control Language (Tcl) is a programming language having a Toolkit (Tk) library that provides a standard set of graphical user interface (GUI) widgets. Since these are aimed at direct presentation via a window manager, Tcl/Tk applications are not compatible with Web- based service delivery environments. Several tools provide some help, but do not provide a migration path for eventual full conversion to Web-based delivery. This note suggests a new approach. For the particular application prompting this note, the GUI consists almost entirely of Tk widgets, especially tables and buttons. Hypertext Markup Language (HTML) offers these same widgets, so it is natural to consider delivering Tk windows by expressing their contents in HTML. To demonstrate this possibility, the Tk library was altered to generate HTML. As described in the paper, this shows that the Tcl/Tk internal data structures are sufficient to generate appropriate HTML commands having the same user interface as that presented by the application. Consequently, it is possible to add to Tk a fourth GUI interface in parallel to the existing ones for Unix, Macintosh, and MS Windows. CMU/SEI-2003-TN-002 v vi CMU/SEI-2003-TN-002 1 Introduction One system recently reviewed by the Software Engineering Institute (SEISM) is a military accounting database. I will refer to it as SYS for purposes of discussion. One of its distinctive features is an implementation written entirely in Tool Control Language/Toolkit (Tcl/Tk) [Tcl/Tk 2002]. While this makes for succinct code, it has disadvantages: • Military users must access SYS through special approved hardware-software platforms and these must have an X Windows server installed. • The user interface is unlike emerging companion systems that are accessed through standard Web browsers. In answer to these disadvantages, users have created another tool—a browser-accessible tool—that handles an important subclass of SYS operations. Browser-accessible applications and SYS’s X Windows application both run the application on a remote computer that communicates to the user’s workstation. In the browser-accessible case, this communication is in the form of HTML data. In the X Windows case, communication is via a specialized data stream. Military and other secure systems usually allow communication via HTML, while restricting access via X Windows.1 Users’ systems come with ready-to-run browsers, but require some non-trivial setup to use X Windows. HTML will go through firewalls whereas X Windows often do not. The SYS windows generated by Tcl used primarily the Tk widgets for tables and buttons. These, it seemed to me, could be rendered into HTML and thus presented to the user through a Web browser. It seemed simple enough,2 so I was encouraged to create a proof-of-concept demonstration to show that it could indeed be done. It can. For the demonstration, I modified the Tcl/Tk processor so that each time it repaints the window it also writes a file containing the HTML that will generate an equivalent window. This shows that the necessary information is present within the Tcl/Tk implementation. A practical approach to using HTML would create a separate GUI interface in parallel with the existing interfaces for Unix, the Macintosh, and MS Windows. SM SEI is a service mark of Carnegie Mellon University. 1 More specifically, Web access is via HTTP and port 80 while X Windows uses its own transport protocol and port 6000. HTTP has been considered security-benign; usually it is. 2 It might even have turned out to be simple had I been familiar with Tcl/Tk and its implementation. As it was, the three-day exercise served mostly to remind me how bad C is as a programming tool. CMU/SEI-2003-TN-002 1 There are other alternatives for delivering Tcl applications through a browser.3 The Tcl Plug- in enables a Web page to incorporate Tcl code to be executed on the client’s machine [Demailly 2002]. For a database application like SYS this approach entails performance and security drawbacks. For instance, the code will take a long time to be sent, and detail records from the database will have to traverse the net for summation at the client machine. This problem is avoided by Proxy Tk [Roseman 2000]. In this system the Tcl application runs on the server and communicates to a Java plug-in running through a browser at the client end. A deeper option is to incorporate Web service into the application. This can be done with the TclHttpd Web server [Welch 2000] and AOLserver [Davidson 2000], among others. These other approaches do not offer a migration path away from Tcl/Tk into a Web-based application. 3 Helpful emails came from Michael Schlenker and Jeffrey Hobbs. 2 CMU/SEI-2003-TN-002 2 Example of the Approach The window in Figure 1 is generated by the Tcl/Tk code in Figure 2. When this code is processed by my modified version of Tcl/Tk it creates the HTML shown in Figure 4. The latter appears in a browser as shown in Figure 3. (I made no attempt to match borders. These can be added to the HTML to make it appear much closer to the Tcl/Tk generated image.) Figure 1: A Data Entry Form with Label and Field Widgets CMU/SEI-2003-TN-002 3 # A data entry form. # Eric Johnson 21-Feb-96 # adapted 9 August 2002, Fred Hansen # Set up grid layout (instead of packing). # Labels for the data entry fields. # left column # left column grid config .l_nm -column 0 -row 0 -sticky "e" label .l_nm -text "Full name: " grid config .l_titlw -column 0 -row 1 -sticky "e" label .l_titlw -text "Title: " grid config .l_addr -column 0 -row 2 -sticky "e" label .l_addr -text "Address: " grid config .l_ok -column 0 -row 3 -sticky "e" label .l_ok -text "Transmit? " grid config .e_nm -column 1 -row 0 -sticky "snew" # right column grid config .e_titlw -column 1 -row 1 -sticky "snew" label .l_user -text "User name: " grid config .e_addr -column 1 -row 2 -sticky "snew" label .l_email -text "Email: " grid config .e_ok -column 1 -row 3 -sticky "snew" label .l_ yes -text "Do you want email: " # right column # Data-entry fields. grid config .l_user -column 2 -row 0 -sticky "e" # left column grid config .l_email -column 2 -row 1 -sticky "e" entry .e_nm -width 20 grid config .l_ yes -column 2 -row 2 -sticky "e" entry .e_titlw -width 10 grid config .e_user -column 3 -row 0 -sticky "snew" entry .e_addr -width 20 grid config .e_email -column 3 -row 1 -sticky "snew" button .e_ok -text OK grid config .e_ yes -column 3 -row 2 -sticky "snew" # right column entry .e_user -width 12 # Set up grid for resizing. entry .e_email -width 20 grid columnconfigure . 1 -weight 1 checkbutton .e_yes -text "yes" -width 20 grid columnconfigure .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages21 Page
-
File Size-