When my script starts, beside the GUI i'v created in my script - there is another window that appears.
How can i avoid this other window?
Thanks,
Guy
Are you using toplevel to create your window? If so, you probably need
to do a "wm withdraw ." to withdraw the "." toplevel. Alternatively,
just build your widgets in "." instead of creating a new toplevel
/Ashok
Are you doing something like:
set mygui [toplevel .mygui]
and then building your gui in .mygui?
You don't need to create a new toplevel to build your gui in. You can
use the main toplevel created automatically. It is called '.' and you
can build your gui there.
Alternitively, you can include this line:
wm withdraw .
in your script, if there is some reason you cannot just build your main
GUI in the root window (.).
>
> Thanks,
> Guy
>
--
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
Be aware of the fact that the main window (the window called .) is
special in that the whole application is closed when the windows is
closed.
When you hide / withdraw the main (.) window, you have to take care to
call exit when ie. the last window is closed, otherwise the process
stays hanging in the background.
Conversely, you have to take care to catch close window request when
you use the . window and want the application to keep running (only
hide the . window) when user closes the window (wm protocol .
WM_DELETE_WINDOW <HANDLER_PROC>).
#############################
toplevel .reltop
wm title .reltop "Release Prep"
wm withdraw .
##############################
The "wm withdraw ." statement works just fine. it hides my "." window and when i exit the gui it leaves nothing running.
I didnt understand what this statement does...
(wm protocol .
WM_DELETE_WINDOW <HANDLER_PROC>)
Guy
That line causes your program to invoke the registered procedure
(whatever HANDLER_PROC
you specified) when the user presses the little x i the upper-right
corner. Otherwise
your program will simply stop (or even worse: the toplevel window
becomes invisible and
your program does not interact with the user anymore)
Regards,
Arjen
At the end of a script, how do I force a clean exit?
IE flush and close all open files and destroy any windows which
have been withdrawn.
I know I've seen a reference somewhere, but I don't know what to
search for.
TIA
The exit command will do that.
In the case of a GUI program, you don't want to just put 'exit' at the
end of the script. The program will exit *before* displaying the GUI!
Presumably your GUI has a 'quit' or 'close' or 'done' or 'finish'
button. What ever callback script you have bound to this button would
call exit as the last thing it does.
You can also (and probably *should* in the case of withdrawing . and
using another toplevel as your GUI window) include something like this:
wm protocol .mytoplevelgui WM_DELETE_WINDOW {MyExitProc}
proc MyExitProc {} {
# (optional) Confirm exit
if {![tk_messageBox -type yesno -icon question \
-message "Are you sure you want to exit?"]} {return}
# Do whatever application specific cleanup needed
exit
}
It is really *best* to put your main GUI in the mail (.) window and then
bind to its WM_DELETE_WINDOW some appropiate exit proeduure:
wm protocol . WM_DELETE_WINDOW {MyExitProc}
>
> TIA
Instead of exit, you really should use: destroy .
--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+
Does this really make a difference?
Yes, if you have outstanding events -- destroy . processes those before
shutting down, exit does not.