tkSimpleDialog focus problem
John Lull
lull at acm.org
Thu Dec 30 00:38:53 EST 1999
I'm trying to write a very simple app using Tkinter, and have gotten
as far as showing a simple dialog box derived from tkSimpleDialog, as
shown in listing 1 below. The dialog box looks as I expected,
except....
When I run this (under Win98), it displays the main window on *top* of
the dialog box, even though the dialog box has the focus. I can type
into the edit field, even when it's obscured behind the main window.
If I <alt<tab>> to the program, the main window seems to get the
focus, but now moves *behind* the dialog box. I can click on the
dialog box title bar & bring it to the front, and have it retain or
get the focus.
Clearly, I'm doing something wrong. Any hints?
Regards,
John
Listing 1:
# file test.py
from Tkinter import *
import tkSimpleDialog
# ===================================================================
class TestDialog(tkSimpleDialog.Dialog):
# ----------------------------------------------------------------
def body(self, master):
# Add label + entry field
Label(master, text="A").grid(row=0)
e = Entry(master)
e.insert(0, 1)
e.grid(row=0, column=1, sticky=E+W)
# Set initial focus to entry field
return e
# ===================================================================
def t():
m=Tk()
d=TestDialog(m, "testing, testing...")
print d.result
t()
More information about the Python-list
mailing list