473,805 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

On Thu, Aug 28, 2008 at 10:29 AM, <du**********@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
Aug 28 '08 #1
0 1777

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4167
by: Irmen de Jong | last post by:
Hi, I'm having trouble with the code below. It's just a regular Tk text widget in which you can type and select text as expected, however the call to tkFileDialog.askopenfilename() seems to screw things up. After the file dialog, I can no longer use the Text widget (typing, selecting, it doesn't work anymore!) What am I doing wrong? TIA, --Irmen de Jong
1
2276
by: Club-B42 | last post by:
when i start opt_newlogin.py directly it works fine(outputs '1 1 1 1'), but if i start it from options.py there is an error(outputs ''). ======== opt_newlogin.py ======== from config import * from Tkinter import * from opt_newlogin import newlogin
5
3010
by: max(01)* | last post by:
hello. i wrote a very simple tkinter demo program that uses menus, buttons, labels, entries, frames and secondary toplevels. it is a python version of a java program made by a colleague. the user can create ("Scrivi") a record with his second name, first name and date of birth, save ("Salva") the record to a file or read in ("Leggi") a previously created file. "Annulla" is to cancel. "Chiudi" is
6
5740
by: Peter Kleiweg | last post by:
I have an application written in Tkinter. There is a menu item 'quit' that calls the function 'quit'. If 'quit' is called, it first checks if there is unsaved data. If there is, it won't let the application exit unless you confirm to disregard the changes. So far, so good. I want the program to behave identical if the 'close' button of the application window is clicked. I tried the code below,
3
27682
by: Glen | last post by:
Is it possible to to detect a Tkinter top-level window being closed with the close icon/button (top right), for example to call a function before the window actually closes? Python 2.4 / Linux (2.6 kernel) if that makes any difference. Any info would be greatly appreciated. Thanks Glen
0
2366
by: Stewart Midwinter | last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item that does nothing more than fetch a directory listing and display it in a Toplevel window (I'd use a tkMessageBox showinfo widget, but for some reason the text is invisible on cygwin). After I close the Toplevel widget, all of the menus in my app behave as though they have no contents to them, i..e I can press on the File menu button, and see it depress, but the Exit...
6
13923
by: marcoberi | last post by:
Hi everybody. I have this code snippet that shows a window without a titlebar (using overrideredirect) and two buttons on it: one quits and the other one brings up a simple tkMessageBox. On Windows (any flavour) the tkMessagebox brings up over the underlying window. On Linux (apparently any flavour) the tkMessagebox brings up under the underlying window. You can drag the popup window near the main window to discover if it's
0
1408
by: dudeja.rajat | last post by:
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):
0
285
by: dudeja.rajat | last post by:
On Thu, Aug 28, 2008 at 3:54 PM, Guilherme Polo <ggpolo@gmail.comwrote: Thanks Guilherme, your suggestion helped solve the problem. -- Regards, Rajat
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10360
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9185
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5542
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.