I have a script where I want to use a message box for the occasional interactive question

# python 3.1
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
answer = messagebox.askyesno(message="Are you thinking of the " + "data " + "?"
                             ,icon='question' ,title="My guess"

when I run this, I get the message box. I also get a blank tk window, which does not disappear when the message box is dismissed. Is there any way to avoid this?

Recommended Answers

Use root.withdraw [CODE]from tkinter import *

from tkinter import ttk

from tkinter import messagebox

root = Tk()
root.withdraw()
answer = messagebox.askyesno(message="Are you thinking of the " + "data " + "?"
,icon='question' ,title="My guess")
print(answer) [/CODE]

Jump to Post

All 3 Replies

Use root.withdraw

from tkinter import *
##from tkinter import ttk
from tkinter import messagebox

root = Tk()
root.withdraw()
answer = messagebox.askyesno(message="Are you thinking of the " + "data " + "?"
                             ,icon='question' ,title="My guess")
print(answer)

Thanks, that's great! How do you learn ttk properly?

Python31 includes the Tkinter Tile extension module ttk.

Ttk comes with 17 widgets, 11 of which already exist in Tkinter:
Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton,
PanedWindow, Radiobutton, Scale and Scrollbar

The 6 new widget classes are:
Combobox, Notebook, Progressbar, Separator, Sizegrip and Treeview

You have to do some detective work on file
C:/Python31/Lib/tkinter/test/test_ttk/test_widgets.py
to figure out how these widgets work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.