[Tutor] You're gridded for life.
Jean Montambeault
jrm@videotron.ca
Tue, 11 Dec 2001 16:28:44 +0200
Remember my question about shortcuts to ".grid" ? Maybe not but look at
this :
Exemple1 : this doesn't work...
===================================
#! /usr/bin/env python
# Exemple1 for the tutor mailing list
from Tkinter import *
def here_I_am(event):
print "Yes, that's me!"
fen=Tk()
tom_dee_lee_dum=Entry(fen).grid(row=0, column=0)
tom_dee_lee_dum.bind("<Return>", here_I_am)
#fen.mainloop() (commented out for running inside IDLE)
##Traceback (most recent call last):
## File "C:/Python21/exemple1.pyw", line 13, in ?
## tom_dee_lee_dum.bind("<Return>", here_I_am)
##AttributeError: 'None' object has no attribute 'bind'
===================================
Exemple2 : ...but this does
===================================
#! /usr/bin/env python
# Exemple1 for the tutor mailing list
from Tkinter import *
def here_I_am(event):
print "Yes, that's me!"
fen=Tk()
tom_dee_lee_dum=Entry(fen)
tom_dee_lee_dum.grid(row=0, column=0)
tom_dee_lee_dum.bind("<Return>", here_I_am)
#fen.mainloop()
===================================
So my question : is the shortcut technique only good for the widgets that
aren't assigned to a variable ? This snag costed me two hours of my life and
some selected curses, these very graphical ; in no tutorial is "extreme
tolerance to frustration" ever mentionned among the qualities that make a
good programmer but it really should. The up side : it feels really good
when it stops. ;)
>From now on I'll stick to classical forms.
Jean M.