Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.

  How can I keep my toplevel on top?
 There are two methods for keeping your toplevel on top.  Make your
choice depending on your needs:

The first method is for modal dialogs, where you want to ensure that the
dialog does not get obscured by its associated toplevel window.  It is
assumed that you already have done a local `grab` on the dialog to make
it modal.  All you have to do then is call `wm transient .dialog
.master` to ensure that the dialog will remain on top.  This is somewhat
window manager dependent, but works in general.

The second method is more forceful, for when you want a window to not be
obscured at all.  To create this effect, do the following:

bind .toplevel  {
    if {[string match %W .toplevel] &&
	[string compare %s VisibilityUnobscured]} {
	raise %W

Windows doesn`t handle `` like Unix, but it does handle
transient well.  However, if you really want something forceful, then
the following is it.  It is a proc which just calls raise on your
toplevel and reschedules itself:

proc keep_raised toplevel {
    if {[winfo exists $toplevel]} {
	raise $toplevel
	after 1000 [info level 0]

Tim Wilson points out a way on Windows to effectively raise the toplevel
above all other windows (including dialogs), with the help of Robin
Becker`s DLL caller extension at