How to keep a Tkinter-Dialog on top of all other windows?

Thomas Nücker thomas.nuecker at
Wed Jul 2 14:35:12 CEST 2003


I am creating a dialog-box within my application, using tkinter. The
problem is the following: After the dialogbox is started, the main
application window comes again to top and the dialogbox is covered by
the window of the main application and must be "fetched" again via the
taskbar to continue. Is there a way to "force" the dialogbox on top of
all other windows? (I'm using MSWindows and Python22)

The source of my dialogbox-class is the following:

class NumberEntry:
	def __init__(self):
		import Tkinter
		from Tkconstants import RIDGE
		from Tkconstants import BOTH
		from Tkconstants import BOTTOM
		from Tkconstants import ACTIVE
		from Tkconstants import LEFT
		from Tkconstants import W
		from Tkconstants import E = Tkinter.Tk()"My Dialog")
		frame = Tkinter.Frame(, borderwidth=2)
		label=Tkinter.Label(frame, text="Telefonnummer:")
		self.entry = Tkinter.Entry(frame, name="entry")
		box = Tkinter.Frame()
		w = Tkinter.Button(box, text="OK", width = 10, command=self.OnOk,
default = ACTIVE)
		w.pack(side=LEFT, padx=5, pady=5)
		w = Tkinter.Button(box, text="Cancel", width=10,
		w.pack(side=LEFT, padx=5, pady=5)
                # try to keep focus on current dialog box
	def OnOk(self):
		self.result = self.entry.get()
	def OnCancel(self):
	result = ""

More information about the Python-list mailing list