[Tkinter-discuss] Font control in tkMessageBox?

Jeff Epler jepler at unpythonic.net
Wed Apr 13 23:05:03 CEST 2005


You can force Tk to use the non-native dialogs on Windows, but in a
Tk-version-dependent fashion.

The following code is snipped from tk.tcl on my 8.3 installation:
    #----------------------------------------------------------------------
    # Define common dialogs on platforms where they are not implemented 
    # using compiled code.
    #----------------------------------------------------------------------

    if {[string equal [info commands tk_chooseColor] ""]} {
        proc tk_chooseColor {args} {
            return [eval tkColorDialog $args]
        }
    }
    # [and likewise for tk_getOpenFile, tk_getSaveFile, tk_messageBox,
    # tk_chooseDirectory]

If you know the version-specific code you can just remove the check for
the native version and directly evaluate something like this just after
creating your interpreter:
    catch { rename tk_chooseColor {} }
    proc tk_chooseColor {args} {
        return [eval tkColorDialog $args]
    }

I discourage actually doing this for a number of reasons.  Besides being
an implementation detail (one that changed between 8.3 and 8.4, iirc)
and not a public interface, there's the fact that you create the best
experience for your users by having an application that looks like the
others that run on the same system.  Except for pure turn-key systems,
this means looking like the other programs on the same platform.  You
should think twice before throwing away the fact that these native
dialogs are, well, native.  Lastly, the non-native file and directory
dialogs probably doesn't support drive letters so it's going to be
pretty useless on Windows machines.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20050413/a18a81d6/attachment.pgp


More information about the Tkinter-discuss mailing list