Tkinter focus_set use with grid

Stan Cook sdcook55 at sbcglobal.net
Wed Jul 19 22:53:25 EDT 2006


A newbie to Tkinter here. . . . . .

I'm trying to set the focus on an Entry textbox with 
focus_set.  I am using the grid manager.  I created the same 
interface before using the  pack() method and the focus_set 
worked, but now it says

"AttributeError: 'NoneType' object has no attribute 'focus_set'"

Below is the section of the code:

#	CREATES THE GUI FOR DCN INPUT
def get_dcn():
	master = Tk()
	_dcn = StringVar()
	label1 = Label(text="Enter DCN:",width=10).grid(row=0)
	txtbox = Entry(relief=SUNKEN, width=20, takefocus=1, 
textvariable=_dcn).grid(row=0, column=1)
	txtbox.focus_set()
	btnOK= 
Button(text="OK",command=assign_dcn(_dcn)).grid(row=1, column=0)
	btnCancel = Button(text="Cancel", 
command=killer).grid(row=1, column=1)
	master.mainloop()
	return

Does anyone know where I went wrong?

Regards. . . .

__S Cook



More information about the Python-list mailing list