B—
Operating System Differences
Perl was originally written for Unix systems. The Tk module was meant for use with the X Window System, which is the graphical user interface associated with Unix. Since then, Perl has been ported for use on many other platforms, including Macintosh and Microsoft Windows (both 95 and NT). The same is true of the Tk module, although the ports for it followed along a bit more slowly. So now we have Perl available on all platforms and Perl/Tk available for both the X Window System (which can be emulated or run on many different platforms) and Microsoft Windows.
There are very few differences between how Perl/Tk operates on the Unix X Window System and how it operates on Microsoft Windows. Most of the differences come about because Microsoft Windows doesn't have all of the different functions that the X Windows System has. Throughout this book, you may have seen references to a method that didn't work on Windows 95 or that worked differently on Windows 95. I won't be covering all those minor differences again. One big difference between Unix and Windows is how to specify fonts. Appendix C, Fonts, covers font specifications in detail; see that appendix for information for both Unix and Windows.
Unix
All of the methods listed in this book should work well under Unix systems. There might be subtle differences between the different flavors of Unix (such as what type of value you get back on a Solaris machine compared to the values you get back on a Linux machine), but nothing that will cause your program to crash.
All of the screen shots for this book, except where noted, were taken from a Linux system running the X Window System with Motif-style windows. The window
manager I used specifically was fuwm, but the style of windows is similar to mwm. I don't cover the differences between window managers and how they change the style of the window. There are many other books available that discuss the X Window System and the window managers it uses.
Windows NT and 95
When you create a Perl/Tk window for Windows NT or Windows 95, the window comes up looking just like all your other windows do for those operating systems. For instance, it will have a small x in the upper-right corner that will kill the application. Just to the left of that x will be a small button that maximizes the window. To the left of the Maximize button is a small bar that will iconify the application. In the upper-left of the application is a small ''Tk" that, if clicked, will display a menu that gives options to minimize, maximize, or close the application. These are all standard features of an MS Windows window. The same functionality is present in the X Window System version of a Tk application; it just looks a little different (see Figure B-1).
0332-01.gif
Figure B-1.
A Win32 window and an X Windows window
Windows 95 Problems
I used both a Windows 95 machine and a Windows NT 4.0 (Service Pack 3) machine to test the code in this book. I did find some minor problems running applications under Windows 95. Windows NT did not seem to have the same problems, so if I had a choice between 95 and NT, I would develop and run Perl/Tk on Windows NT. Here is a list of some of the problems I ran into while I was testing Perl/Tk applications under Windows 95 (note that these are not necessarily reproducible 100% of the time; I just wanted you to be aware that I did run into some minor problems):
• I created a Main Window with one button, resized the window, and couldn't click on the Exit button.
• The same scenario as the preceding item; clicking anywhere in the window after it was resized caused the button to be pressed.
• When I tabbed between applications, clicked in another application, and then went back to the Tk app, it didn't recognize the mouse. Clicking on the app icon in the start bar seems to fix this. (There doesn't seem to be any solid reproducible cause and effect for loss of mouse recognition.)
• The -underline option doesn't seem to work properly when I attempted to underline a letter in a menu option, so the corresponding key could be used as a keyboard shortcut.
• Some methods (most of which you wouldn't use because they are obscure) didn't return a reasonable value. These were noted throughout the book as they were discussed.
• When I clicked in a text widget to give it the keyboard focus and then clicked elsewhere, the text widget didn't give up the focus. You can use Shift-Tab to switch between widgets within the window once text has the focus, but it still doesn't seem to want to give up the focus (the cursor stays as an I bar cursor, and won't interact with the button at all).
• When I tried to display a photo as an image in a button (by using the -image option), the photo looked garbled.
Other than these minor problems, most of which probably wouldn't apply to a run-of-the-mill application, everything worked well.
Selections
In the X Window System, the user can select text by simply highlighting it. In Microsoft Windows, you have to highlight the text and put it in the clipboard by typing CTRL-C (for Copy), pasting it back with CTRL-V or the equivalent for the application you're running. Perl/Tk does not interact with the clipboard like this. There are several widgets that have an -exportselection option (such as listbox and text) and still work as indicated; if they are set to zero, however, they won't copy the selected text to the clipboard.