[Tutor] A Simple Tkinter Control Program--Slight Problem

Wayne Watson sierra_mtnview at sbcglobal.net
Thu Mar 5 17:00:11 CET 2009


Here's what I think the author meant in discussing a control variable sample
program. <http://effbot.org/tkinterbook/entry.htm>
========================
from Tkinter import *

v=StringVar()

e = Entry(master, textvariable=v)
e.pack()
e.focus_set()

v.set("a default value")
s = v.get()

mainloop()

The problem is that Python objects with the msg:
    AttributeError: 'NoneType' object has no attribute 'tk'

What corrects this? The full sample program below it runs fine:
=======================
from Tkinter import *

master = Tk()

e = Entry(master)
e.pack()

e.focus_set()

def callback():
     print e.get()

b = Button(master, text="get", width=10, command=callback)
b.pack()

mainloop()
-- 
                                W. eWatson

              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
               Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

                     Web Page: <www.speckledwithstars.net/>





More information about the Tutor mailing list