Grupos de Google ya no admite publicaciones ni suscripciones nuevas de Usenet. El contenido anterior sigue visible.

[Tcl/Tk] another window beside my gui - how to avoid it?

102 vistas
Ir al primer mensaje no leído

Guy

no leída,
22 jun 2011, 9:09:08 a.m.22/6/2011
para
Hi,

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

APN

no leída,
22 jun 2011, 9:26:19 a.m.22/6/2011
para

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

Guy

no leída,
22 jun 2011, 9:58:09 a.m.22/6/2011
para
Thank you very much!
the "wm withdraw ." works just fine...

Robert Heller

no leída,
22 jun 2011, 10:39:08 a.m.22/6/2011
para

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



CARLO KOKOTH

no leída,
22 jun 2011, 10:45:45 a.m.22/6/2011
para
On Jun 22, 3:58 pm, Guy <gelimel...@gmail.com> wrote:
> Thank you very much!
> the "wm withdraw ." works just fine...

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>).

Guy

no leída,
23 jun 2011, 3:25:37 a.m.23/6/2011
para
actually, this is how i start my gui:

#############################
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

Arjen Markus

no leída,
23 jun 2011, 6:58:43 a.m.23/6/2011
para
On 23 jun, 09:25, Guy <gelimel...@gmail.com> wrote:
>
> 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

Richard Owlett

no leída,
24 jun 2011, 1:44:30 p.m.24/6/2011
para

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


Robert Heller

no leída,
24 jun 2011, 2:11:23 p.m.24/6/2011
para

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

Gerald W. Lester

no leída,
24 jun 2011, 3:37:35 p.m.24/6/2011
para Robert Heller

Instead of exit, you really should use: destroy .

--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

Robert Heller

no leída,
24 jun 2011, 3:58:24 p.m.24/6/2011
para

Does this really make a difference?

Gerald W. Lester

no leída,
24 jun 2011, 4:38:55 p.m.24/6/2011
para

Yes, if you have outstanding events -- destroy . processes those before
shutting down, exit does not.

Richard Owlett

no leída,
24 jun 2011, 5:49:55 p.m.24/6/2011
para
Thank you.
0 mensajes nuevos