txmbox is an attempt to provide a general purpose informational dialog tool to replace tk_messageBox. txmbox adheres to all the tk_messageBox options, improving on many of them. Also, txmbox adds so many additional features that you may never need to build another informational dialog box. txmbox is a pseudo widget. The only exception to compatibility with tk_messageBox; the default for -icon is to not display an icon.

Here's a list of most of the features included in this package:

  • Uses Tile widgets if the Tile package is already loaded so your dialogs will look like the rest of your interfaces.
  • Keeps the event loop running. Doesn't hang your program.
  • Dialogs can time out after a predefined period AND you can optionally choose to show the remaining time in the dialog's title bar.
  • Dialog buttons can be pressed programmatically.
  • Dialog button labels can be changed after the dialog has been displayed.
  • txmbox is written in Tcl so you can easily extend its capability.
  • Dialogs can be made to wait for the user to respond or not. If the dialog is instructed to wait then, after the user clicks a button, the button label of the pressed button is returned. If the dialog is instructed not to wait then the call to the dialog returns the dialog windows path, e.g.; .txmboxXYZ.
  • The message widget is a text widget so its text can easily be copied and pasted into other applications or emails. In fact, I'm looking at adding printing capability via a button 3 popup dialog. There's already a b3 popup that allows you to select all text and copy it to the cut buffer. Also, the text widget is disabled so the user can't mess with the message text.
  • You can have multiple instances of txmbox on the screen at one time.
  • New text can be added dynamically to existing dialogs AND you can set the foreground and background colors as you add new text.
  • Each dialog can be associated with a callback routine.
  • You may specify the complete geometry of the dialog or just its size or position.
  • The dialog's position can be queried and saved so it can be repositioned according to the user's desire the next time it's presented.
  • Includes a built-in "Don't show this dialog again" function.
  • Includes an optional text formatting function.
  • Can wait for a known process ID to terminate.
  • Can be displayed without a titlebar.
  • Dialogs can be resized.
  • Can have a confirm subdialog. You know the old "Are you sure you want to do this?" Bill Gates really likes these.
  • Add an image or icon to the left side of the message. Uses the standard bitmap icons available in Tcl or you can supply your own images.
  • Can make a sound when dialog pops up.
  • Can be centered or otherwise positioned.
  • Can have custom button names OR use predefined button sets.
  • Dialog's information is retained after dialog is closed so it can be processed post dialog. Used memory can be recovered via the cleanMsgBox command.
  • Cross platform compliant. Works on Windows, Linux, and UNIX. It hasn't been tested on a Mac platform so I have no idea whether it will work there but I sure would like to get some feedback.
  • Extensive error checking.
  • The package also includes some useful routines that can be accessed separately from the messageBox.

You can get a copy of it here [L1 ]. View the documentation here [L2 ]. View the change log here [L3 ].

I hope you find it useful and please let me know if you have any feature request or find any bugs.

Enjoy, Robert Joy

MG I tried to test this briefly on Windows, but it failed because I don't have twapi installed. Since the code works fine on Linux, is TWAPI really needed on Windows? Could it be made optional (assuming it just provides some extra features otherwise not available)?

Robert Joy - txmbox relies on twapi to detect running processes that are to be monitored for completion. I could possibly make it optionally based on use of that feature. I'll check into it.

Synic 2006-09-10 - On Mac OS X, txmbox 1.0 never enables the Ok button. This does seem to be a good project though. An additional suggestion: see if you can use the colour images tk_messageBox uses on MS Windows for icons. The old style one-colour bitmaps look very dated these days.

Robert Joy - Thanks Synic for checking this out on a Mac and for the suggestion with the icons. I'm a bit baffled as to why the button never enables as I never disable any buttons. Might have something to do with the Grab Stack mechanism I created for ensuring windows sit on top of their parent but I would really need to get my hands on a Mac (I don't have one but might have a friend that could help me out) to fix this issue. As for the bitmaps that should be doable. I debated about this and came to the conclusion that as a first pass it would be ok. I'll add that to the todo list.

Robert Joy 2006-09-10 (5PM PST): I just had another thought about why the buttons on a Mac are not enabling; I'm using BWidget buttons for this interface. Anybody know if these work on a Mac?

RLH BWidgets is installed with the ActiveTcl distro so I would say "yes".

Synic 2006-09-11 - It's possible what's really happening is that the Ok box isn't in -state disabled but also isn't able to accept a focus or click because some other part of the dialog has been grabbed or has focus. The Mac platform is odd like that. (For example, the Tile package's ttk::combobox widget is unusable on the platform because the combobox grabs and pushes the rest of the dialog into a background state. You're forced by practicality to fork code so that anything using comboboxes on any other platform uses ttk::menubuttons and menus on OS X.)

Robert Joy 2006-09-11 (5:58am) PST - Interesting! In txmbox the dialog toplevel has the grab and (initially, the default button has the focus. When you run your mouse over the message area it then takes the focus. But none of these should effect whether the button works. Very odd.

Also, I did some poking around on the internet and found a site ([L4 ] see the BWidget 1.7 Fixes entry) that gave the following statement button.tcl: The primary change I made is to add a handler for the "Activate" event. On the Mac, an activate event is generated every time you leave the wish application, utilize another app, then return to wish. If this event isn't handled, then the button states aren't updated properly. Not sure if this would affect the enable/disable behavior but it might. So this may be something that will work better in BWidgets 1.8.

Robert Joy 2006-10-08 (9:23am) PST - Bugs fixes and documentation changes. Latest version is 1.0.8. This version represents a more stable release. I found a few problems that were largely issues that should be resolved by Tk. The windows are much more solid as they popup. Overall a much cleaner presentation.

HaO 2011-09-20 Within the source code, the sequence:

if { [ regexp {Tile} [info loaded] ] } {

is used to detect themed widget. This will not work from tcl 8.5 on, as ttk is not a loadable dll any more with the name 'tile'.