When you do this:

butCol.ks2=Entry(...).grid(...)

.... you are setting butCol to None, because .grid(...) returns None.
Separate the widget creation and widget layout into two distinct steps so
that butCol.ks2 has an actual value:

butCol.ks2 = Entry(...)
butCol.ks2.grid(...)

This should then allow the bind to work.


On Tue, Jan 14, 2014 at 10:04 PM, Guido van Rossum <gu...@python.org> wrote:

> Hey Rob,
>
> The place to get help with Tkinter is tkinter-discuss@python.org. I've
> CC'ed that list for you.
>
> --Guido
>
> On Tue, Jan 14, 2014 at 4:53 PM, Rob Ward <rl.w...@bigpond.com> wrote:
> > I apologise if I have come to the wrong place here, but 12hrs searching,
> > plus experimenting,  on the WWW for advice on it has not yielded any
> > successful advice to resolve the issue.
> >
> > I am am having trouble binding an Entry widget to <Return>
> >
> > Here is the snippet (butCol is a Frame widget to put buttons,labels and
> text
> > entry down LHS)
> >
> > KS1=StringVar()
> > KS1.set("Key is ??")
> > butCol.ks1
> > =Label(butCol,textvariable=KS1).grid(column=0,row=18,sticky=(N,W))
> >
> > myKey = [0,2,4,5,7,9,11] #Begin in the key of C
> > KS2       =StringVar()
> > KS2.set("C")
> > butCol.ks2
> >
> =Entry(butCol,width=20,textvariable=KS2).grid(column=0,row=19,sticky=(N,W))
> >
> > The above lines all render correctly, but will not trigger off "entry" of
> > data at all on <Return>
> >
> > Adding the following line just crashes.
> >
> > butCol.ks2.bind("<Return>",chooseKey)
> >
> > I downloaded the Python 3 package from the recommended site last week to
> > begin this project (it was previously working OK in Skulptor, but I was
> not
> > prepared to develop it any further in that environment, though it was an
> > excellent starting environment).  So I believe the Python language
> installed
> > is up todate.  I have not previously installed Python so it should be
> > "clean".
> >
> > If you could give any direct advice I would be very grateful or if you
> can
> > direct me to your best "forum" site maybe I could use that.
> >
> > One overall observation that has frustrated me is how toi search for
> > information that relates to Python3 and the latest tkinter modules.  I
> kept
> > finding old python or old Tkinter or combinations of both.  Wrorking my
> way
> > through this was very time consuming and rarely productive.  Is there any
> > advice on how to get the "latest" information off the WWW?
> >
> >
> >
> > Cheers, Rob Ward
> >
> > PS In my state of eternal optimism I have attached the whole file :-)
> >
> > PPS I have done some OOP in the past but not keen to jump in at the
> moment.
> >
> >
> > _______________________________________________
> > Python-Dev mailing list
> > python-...@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> > https://mail.python.org/mailman/options/python-dev/guido%40python.org
> >
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to