Re: Tkinter tkMessageBox problem - message box is displayed with anadditional window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dudeja.rajat@gmail.com

    Re: Tkinter tkMessageBox problem - message box is displayed with anadditional window

    On Thu, Aug 28, 2008 at 3:54 PM, Guilherme Polo <ggpolo@gmail.c omwrote:
    On Thu, Aug 28, 2008 at 10:29 AM, <dudeja.rajat@g mail.comwrote:
    >Hi,
    >I'm working on Windows Platform
    >>
    >I'm facing some problem with the tkMessageBox. My code is as below:
    >>
    >import tkMessageBox
    >import Tix
    >from Tkinter import *
    >>
    >if len(installedLi bPath) != len(listOfLibra ries):
    > if tkMessageBox.as kyesno("Questio n", \
    > type='yesno', icon='warning', \
    > message="Some of the libraries are
    >not installed. Do you wish to continue with the remaining?"):
    > myRoot = Tix.Tk()
    > myAppGUIObject = myAppGUI(myRoot ) #Class for my GUI
    > myRoot.mainloop ()
    >else:
    > sys.exit(0)
    >>
    >
    It is good to post a short code sample that demonstrates the problem,
    but it has to run by itself at least.
    >
    >>
    >The Message Box is called before the Tix.Tk mainloop(). The problems
    >are as under :
    >>
    >1. Since the message box is displayed before the mainloop() is
    >started, the message box is displayed with another window that is
    >blank. This should not be displayed.
    >>
    >2. As a results of this messagebox (called before the mainloop) the
    >original Gui started by mainloop doesnot work as desired. Some of the
    >checkbuttons are displayed as unset (i.e un-ticked). These
    >checkbuttons used to be set at initialization before I stared using
    >this messagebox.
    >
    tkMessageBox blocks till you finish it, maybe that is what is causing
    your problem but it is hard to tell what you are doing wrong in that
    myAppGui without seeing it (preferably reduced code demonstrating the
    problem).
    >
    Now.. an attempt to solve your problem. Tk always has a root window
    going on, so that "another window" is inevitable, but you can hide and
    show it again when needed. You could do something like this:
    >
    import tkMessageBox
    import Tkinter
    >
    class App(object):
    def __init__(self, master):
    self.master = master
    print "tkMessageB ox is gone now"
    >
    root = Tkinter.Tk()
    root.withdraw()
    tkMessageBox.as kyesno("Questio n", message="Do you use Python?",
    type='yesno', icon='warning', master=root)
    root.deiconify( )
    >
    app = App(root)
    root.mainloop()
    >
    >>
    >>
    >Please help.
    >>
    >Thanks and regards,
    >Rajat
    >--
    >Regrads,
    >Rajat
    >--
    >http://mail.python.org/mailman/listinfo/python-list
    >>
    >
    >
    >
    --
    -- Guilherme H. Polo Goncalves
    >
    Thanks Guilherme, your suggestion helped solve the problem.

    --
    Regards,
    Rajat
Working...