TKMessageBox, and TKINTER console?

Kevin Cazabon kcazabon at home.com
Mon Apr 17 23:44:52 EDT 2000


Hey Benjamin;

I think your problem is that the TKMESSAGEBOX is not meant to be a main
window, but a child of a parent window.  So, when you invoke the "Frame" for
it, it creates a Toplevel widget to go along with it.

Normally, your 'root' application is a Tkinter.Tk() widget, which you pack
all your other things into.  The "popup" would be a child of that window,
and both would be displayed on the screen.

If you create a non-toplevel style widget on it's own, such as a "Frame", it
will automatically create the Toplevel as a second window.  This is your
problem.

If you don't want the "parent" to be displayed, create it, but 'withdraw' it
before the mainloop() is called.  do this by calling x.withdraw()

However, if you're using the "Message" widget, just pack it in the parent Tk
window, as follows, instead of having it as a separate Frame.

########################
import Tkinter

a = Tkinter.Tk()

b = Tkinter.Message(a, text = "Hello, this is a Message Widget")
        # the first argument above specifies the 'parent' to pack it in.
b.pack()

a.mainloop()

########################
"Benjamin Schollnick" <junkster at nospam.rochester.rr.com> wrote in message
news:rNHvjEdhm5Pp-pn2-Y8HWP45V5PG0 at d185d18f2.rochester.rr.com...
> Folks,
>
> Crazy Question..... I'm starting to mess around with Tkinter, and
> for now at least, just trying to display "pop-up" dialogs.  I found
> the
> TKMESSAGEBOX unit, in the lib-tk directory, and that works great for
> my purposes.
>
> Except, for a small "appearance" problem.  I call the TKmessagebox
> routines, and their are TWO windows.  One is the pop-up I've called,
> and the
> other is the Tkinter "Console" (??).  Or at least that's the nickname,
> I've given it.
>
> I've tried a variety of different things to get rid of it...For
> example, calling
> junk= TK.tk() to a variable, and passing it as "master=junk", or as
> "parent=junk"
> in the code...
>
> I'm not sure if there is anyway to get rid of that darn console.
>
> Anyone got some suggestions for a really confused first time
> Tkinter'er?
>
> - Benjamin
> ====================================================
>           (Remove "NoSpam" to Email me)
> ====================================================
> Please feel free to copy any and or all of this sig.
> A little something for spam bots:
>
> root at localhost postmaster at localhost admin at localhost
> abuse at localhost postmaster at 127.0.0.1
>
> Chairman William Kennard: bkennard at fcc.gov
> Commissioner Susan Ness: sness at fcc.gov
> Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov
> Commissioner Michael Powell: mpowell at fcc.gov
> Commissioner Gloria Tristani: gtristan at fcc.gov
> consumerline at ftc.gov
> fccinfo at fcc.gov
> ssegal at fcc.gov
>





More information about the Python-list mailing list