470,619 Members | 1,746 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

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

On Thu, Aug 28, 2008 at 10:29 AM, <du**********@gmail.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(installedLibPath) != len(listOfLibraries):
if tkMessageBox.askyesno("Question", \
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 "tkMessageBox is gone now"

root = Tkinter.Tk()
root.withdraw()
tkMessageBox.askyesno("Question", 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
Aug 28 '08 #1
0 1592

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Irmen de Jong | last post: by
1 post views Thread by Club-B42 | last post: by
5 posts views Thread by max(01)* | last post: by
6 posts views Thread by Peter Kleiweg | last post: by
3 posts views Thread by Glen | last post: by
reply views Thread by Stewart Midwinter | last post: by
6 posts views Thread by marcoberi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.