Win32 Tcl/Tk GUIs on UNIX apps on Windows NT
by Stephen Walli Stephen Walli is vice-president of R&D at Softway Systems and author of Go Solo: How to Implement and Go Solo with the Single UNIX Specification (1995). He has been USENIX's Standards Report Editor and Institutional Rep to the IEEE POSIX committees. I hope that this article will expand the boundaries of discussion with respect to how UNIX systems and Windows NT coexist. At Softway Systems Inc., we develop OpenNT, an environment subsystem for Windows NT that provides the programming and runtime environment found on UNIX systems for Windows NT with complete UNIX semantics. The original Microsoft POSIX subsystem demonstrated the concept of alternative environment subsystems running concurrently on Windows NT. But that subsystem was restricted in functionality to POSIX.1 and ANSI C, and there was little developmental support. The OpenNT subsystem goes beyond the POSIX subsystem and is well integrated with the Win32 subsystem, providing
This sort of integration is used all over the product itself. Once we could exec a Win32 binary, the lp command became a simple shell script wrapping PRINT.EXE that could reach any printer on the network, rather than needing to build a lot of specialized printer driver functionality. useradd and userdel were written as simple shell script wrappers around NET.EXE to add hundreds of users in batch command line mode. When we needed to write a tool to manipulate the tape drives because some tapes from some UNIX vendors don't play well in this space), we wrote a simple Win32-based mt tool using Win32 interfaces that is run from the OpenNT ksh command line prior to running tar or cpio. There is one thing, however, that one cannot do with OpenNT today in the Windows NT world. One cannot create a single application program that mixes UNIX system calls and Win32 system calls in the same executable. Essentially, one cannot have an application calling more than one subsystem as its client. What would the process tree look like if one used fork() and CreateProcess() in the same application, or what happens when one tries to use both UNIX signals and Win32 exceptions? There are two places this causes grief today. There is a set of third-party libraries for database access (Oracle and Sybase are the typical requests) that, although provided on Windows NT as Win32 DLLs, are not useful to an OpenNT process as porting tools for the application code being ported from a UNIX system. The other request typically made is a customer wants to somehow put a Win32 GUI on the UNIX application being ported to Windows NT. So we had a contest in-house to see how many ways one could do this without breaking the portability of the UNIX application source by embedding Win32 GUI calls within it. Several examples were forthcoming:
The first two entries are interesting because the Win32 client ends can easily be remoted to Win95 machines, but the Tcl/Tk entries started to push the envelope of what can be done on Windows NT while protecting the long-term investment in the entire application. One entry was a trivial Tcl wrapper around ps that displayed the running OpenNT processes one per line and, when a process item was double-clicked, invoked kill appropriately to kill the process. The ps and kill commands are running as OpenNT processes invoked from a Win32 Tcl program displaying with the Win32 Tk widgets, so everything has a Win32 look and feel. Now comes some of the weird part. The OpenNT X11 server is a Win32-based X11R6 server that displays individual X11 clients in individual windows on the Win95 desktop. These windows are decorated with Win32 decorations for window control, but the widgets within the application are controlled via the window manager (typically via the default one in the server). OpenNT X11 clients (that are OpenNT subsystem clients), both local and remote, can run with the OpenNT server as one would expect, as well as other X11 clients running on other non-Win32 platforms. The X11 application appears and behaves exactly as one would expect. The OpenNT X11 server allows other window managers to be run, and these window managers run as OpenNT subsystem clients. Currently, mwm and twm are shipped with different products in the OpenNT family. So by running another window manager, one gets a different look and feel of the X11 client app on the desktop. (The OpenNT X11 server also supports controlling the root window menu from another window manager, so one can use one's .mwmrc to pop up a Motif root menu on a Win95 desktop, then run MS Word from the menu.) One of the early things ported to Windows NT with OpenNT was Tcl and the Tk widget set. So as well as running the Tcl app with a Win32-based wish80 (from a desktop icon or OpenNT ksh), using Win32 Tk widgets, wrapping tools like ps and kill running on the OpenNT subsystem, we could now run the exact same app using the OpenNT Tcl, with the X11-based Tk widget set to give the app a proper X11 look and feel all on the same desktop. It's a little confusing. But that's actually the point. There are no real boundaries here. One can define and control the look and feel of one's graphic applications to be exactly what one needs and expects. And portability between Windows NT and traditional UNIX systems can take on new meanings with Tcl/Tk that completely protects the entire application's source code investment. The best entry in our internal contest was a graphic file browser wrapped around find, lc, and ls, with a small "UNIX" tool written to support certain actions. It can be found on the OpenNT tool warehouse on the OpenNT Web site. I am not a GUI programmer (which was why I chose Tcl/Tk to quickly start building graphic apps on Win32), but I would be very interested in finding out about others' experiences in this space with Tcl/Tk on Windows NT. For more information about Tcl/Tk on Windows NT, please see <http://sunscript.sun.com/>. For more information on OpenNT for Windows NT, please see "Telnetd and Inetd on Windows NT with OpenNT" in this issue or visit: <http://www.OpenNT.com>.
|
|
First posted: 3rd December 1997 efc Last changed: 3rd December 1997 efc |
|