Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Question for and Intermediate Programmer ?

Status
Not open for further replies.

richardiontton

Technical User
Feb 21, 2005
2
GB
I have a few pieces of code here, the first piece is not written by myself and is taken from another program, basically I cannot reference the entry widgets in the standard fashion(second piece of code, ie. def newHost(self)). When the style of writing is that of the code below, How do you reference the Entry widget? :

iframe2 = Frame(frame, bd=2, relief=RIDGE)
Label(iframe2, text='Hostname widget:').pack(side=LEFT, padx=5)
hn_var = StringVar()
Entry(iframe2, textvariable=hn_var, bg='white').pack(side=RIGHT, padx=5)
hn_var.set('Entry widget')
iframe2.pack(expand=1, fill=X, pady=10, padx=5)

def newHost(self):
'Clear the fields in the window(except the listbox)'
self.hn_var.delete(0, END)

Here is the error message :

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "C:\mynewapp.py", line 228, in newHost
self.hn_var.delete(0, END)
AttributeError: App instance has no attribute 'hn_var'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top