SunQuest
           Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 5th, 2004, 09:31 AM
mistersmith mistersmith is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 mistersmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Tkinter AttributeError: Entry has no __call__ method

This has got me stumped for the last 2 days, someone please help!!
I am creating a GUI interface and I keep getting this error when I press the
"New" button (self.buttonNew)
AttributeError: Entry has no __call__ method

here's the code, can anyone help?

Code:
#!/usr/bin/python

from Tkinter import *

class MAINGUI(Frame):
def __init__ (self, parent):

#########################################
# Compose Frames and Subframes #
#########################################

self.myParent = parent

self.mainFrame = Frame(parent)
self.mainFrame.pack(expand=NO, fill=BOTH)

self.subFrame1 = Frame(self.mainFrame, bg=frame1_bg)
self.subFrame1.pack(expand=YES, fill=BOTH)

self.subFrame2 = Frame(self.mainFrame, relief=RIDGE, borderwidth=3, bg=frame2_bg)
self.subFrame2.pack(expand=YES, fill=BOTH)

#########################################
# Buttons #
#########################################

self.buttonNew = Button(self.subFrame1, text='New', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, state=NORMAL, command=self.clickNew)
self.buttonNew.grid(column=0, row=0, ipadx=button_ipadx, pady=button_pady)

self.buttonSave = Button(self.subFrame1, text='Save', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, state=DISABLED)
self.buttonSave.grid(column=1, row=0, ipadx=button_ipadx, pady=button_pady)

self.buttonSearch = Button(self.subFrame1, text='Search', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, state=NORMAL)
self.buttonSearch.grid(column=2, row=0, ipadx=button_ipadx, pady=button_pady)

self.buttonEdit = Button(self.subFrame1, text='Edit', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, state=DISABLED)
self.buttonEdit.grid(column=3, row=0, ipadx=button_ipadx, pady=button_pady)

self.buttonCalc = Button(self.subFrame1, text='Calculate', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, state=DISABLED, command=self.clickCalc)
self.buttonCalc.grid(column=4, row=0, ipadx=button_ipadx, pady=button_pady)

self.buttonPrint = Button(self.subFrame1, text='Print', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, state=DISABLED, command=self.clickPrint)
self.buttonPrint.grid(column=5, row=0, ipadx=button_ipadx, pady=button_pady)

self.buttonQuit = Button(self.subFrame1, text='Quit', height=button_height, width=button_width, \
bg=button_bg, fg=button_fg, command=self.clickQuit)
self.buttonQuit.grid(column=6, row=0, ipadx=button_ipadx, pady=button_pady)


#################################################
# Source Analysis Labels and Entry's #
#################################################

self.labelSourcenumber = Label(self.subFrame2, text="Source Number", bg=label_bg, fg=label_fg)
self.labelSourcenumber.grid(column=0, row=0, sticky=W, pady=label_pady)

self.entrySourcenumber = Entry(self.subFrame2, width=entry_width, state=DISABLED)
self.entrySourcenumber.grid(column=1, row=0, pady=entry_pady)

self.labelChecksource = Label(self.subFrame2, text="Check Source", bg=label_bg, fg=label_fg)
self.labelChecksource.grid(column=0, row=1, sticky=W, pady=label_pady)

self.entryChecksource = Entry(self.subFrame2, width=entry_width, state=DISABLED)
self.entryChecksource.grid(column=1, row=1, pady=entry_pady)

self.labelBkgcount = Label(self.subFrame2, text="Background Count", bg=label_bg, fg=label_fg)
self.labelBkgcount.grid(column=2, row=1, sticky=W, pady=label_pady)

self.entryBkgcount = Entry(self.subFrame2, width=entry_width, state=DISABLED)
self.entryBkgcount.grid(column=3, row=1, pady=entry_pady)

self.labelWipecount = Label(self.subFrame2, text="Wipe Count", bg=label_bg, fg=label_fg)
self.labelWipecount.grid(column=4, row=1, sticky=W, pady=label_pady)

self.entryWipecount = Entry(self.subFrame2, width=entry_width, state=DISABLED)
self.entryWipecount.grid(column=5, row=1, pady=entry_pady)

self.labelResult = Label(self.subFrame2, text="Result", bg=label_bg, fg=label_fg)
self.labelResult.grid(column=6, row=1, sticky=W, pady=label_pady)

self.entryResult = Entry(self.subFrame2, width=entry_width, state=DISABLED)
self.entryResult.grid(column=7, row=1, pady=entry_pady)

def clickQuit(self):
self.myParent.destroy()

def clickCalc(self):
self.buttonQuit.configure(state=DISABLED)

def clickPrint(self):
self.buttonQuit.configure(state=NORMAL)

def clickNew(self):
self.frame2Enable()

def frame2Disable2():
self.entrySourcenumber(state=DISABLED)
self.entryChecksource(state=DISABLED)
self.entryBkgcount(state=DISABLED)
self.entryWipecount(state=DISABLED)
self.entryResult(state=DISABLED)

def frame2Enable(self):
self.entrySourcenumber(state=NORMAL)
self.entryChecksource(state=NORMAL)
self.entryBkgcount(state=NORMAL)
self.entryWipecount(state=NORMAL)
self.Result(state=NORMAL)

root = Tk()
MainGUI = MAINGUI(root)
root.mainloop()

Last edited by netytan : February 5th, 2004 at 04:33 PM.

Reply With Quote
  #2  
Old February 5th, 2004, 04:46 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Hi smith,

the problem sees to be that self.clickNew isnt callable, because it doesnt exist anywhere in the code you posted

I dont know what happened to when you posted your code but adding [ CODE ]...[/ CODE ] tags didnt fix it. And Indentation being VERY important to Python its VERY important that you make sure the code you post is intended correctly

Take care,

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old February 5th, 2004, 04:57 PM
mistersmith mistersmith is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 mistersmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Updated indented code

Sorry for not using
Code:
...

Here's the indented code for easier reading.
Your right, I figured out that the code ISN'T callable, but how do you actually make the functions inside the class callable to inside class code or even outside the class code - what C++ would refer to as "private" or "public".

Code:
#!/usr/bin/python

from Tkinter import *

class MAINGUI(Frame):
 	def __init__ (self, parent):

		#########################################
		#	Compose Frames and Subframes	#
		#########################################

		self.myParent = parent

		self.mainFrame = Frame(parent)
		self.mainFrame.pack(expand=NO, fill=BOTH)

		self.subFrame1 = Frame(self.mainFrame, bg=frame1_bg)
		self.subFrame1.pack(expand=YES, fill=BOTH)

		self.subFrame2 = Frame(self.mainFrame, relief=RIDGE, borderwidth=3, bg=frame2_bg)
		self.subFrame2.pack(expand=YES, fill=BOTH)
	
		#########################################
		#	Buttons				#
		#########################################

		self.buttonNew = Button(self.subFrame1, text='New', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, state=NORMAL, command=self.clickNew)
		self.buttonNew.grid(column=0, row=0, ipadx=button_ipadx, pady=button_pady)

		self.buttonSave = Button(self.subFrame1, text='Save', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, state=DISABLED)
		self.buttonSave.grid(column=1, row=0, ipadx=button_ipadx, pady=button_pady)

		self.buttonSearch = Button(self.subFrame1, text='Search', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, state=NORMAL)
		self.buttonSearch.grid(column=2, row=0, ipadx=button_ipadx, pady=button_pady)

		self.buttonEdit = Button(self.subFrame1, text='Edit', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, state=DISABLED)
		self.buttonEdit.grid(column=3, row=0, ipadx=button_ipadx, pady=button_pady)

		self.buttonCalc = Button(self.subFrame1, text='Calculate', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, state=DISABLED, command=self.clickCalc)
		self.buttonCalc.grid(column=4, row=0, ipadx=button_ipadx, pady=button_pady)

		self.buttonPrint = Button(self.subFrame1, text='Print', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, state=DISABLED, command=self.clickPrint)
		self.buttonPrint.grid(column=5, row=0, ipadx=button_ipadx, pady=button_pady)

		self.buttonQuit = Button(self.subFrame1, text='Quit', height=button_height, width=button_width, \
					bg=button_bg, fg=button_fg, command=self.clickQuit)
		self.buttonQuit.grid(column=6, row=0, ipadx=button_ipadx, pady=button_pady)


		#################################################
		#	Source Analysis Labels and Entry's	#
		#################################################

		self.labelSourcenumber = Label(self.subFrame2, text="Source Number", bg=label_bg, fg=label_fg)
		self.labelSourcenumber.grid(column=0, row=0, sticky=W, pady=label_pady)
		
		self.entrySourcenumber = Entry(self.subFrame2, width=entry_width, state=DISABLED)
		self.entrySourcenumber.grid(column=1, row=0, pady=entry_pady)

		self.labelChecksource = Label(self.subFrame2, text="Check Source", bg=label_bg, fg=label_fg)
		self.labelChecksource.grid(column=0, row=1, sticky=W, pady=label_pady)
		
		self.entryChecksource = Entry(self.subFrame2, width=entry_width, state=DISABLED)
		self.entryChecksource.grid(column=1, row=1, pady=entry_pady)
		
		self.labelBkgcount = Label(self.subFrame2, text="Background Count", bg=label_bg, fg=label_fg)
		self.labelBkgcount.grid(column=2, row=1, sticky=W, pady=label_pady)
			
		self.entryBkgcount = Entry(self.subFrame2, width=entry_width, state=DISABLED)
		self.entryBkgcount.grid(column=3, row=1, pady=entry_pady)

		self.labelWipecount = Label(self.subFrame2, text="Wipe Count", bg=label_bg, fg=label_fg)
		self.labelWipecount.grid(column=4, row=1, sticky=W, pady=label_pady)
			
		self.entryWipecount = Entry(self.subFrame2, width=entry_width, state=DISABLED)
		self.entryWipecount.grid(column=5, row=1, pady=entry_pady)

		self.labelResult = Label(self.subFrame2, text="Result", bg=label_bg, fg=label_fg)
		self.labelResult.grid(column=6, row=1, sticky=W, pady=label_pady)
			
		self.entryResult = Entry(self.subFrame2, width=entry_width, state=DISABLED)
		self.entryResult.grid(column=7, row=1, pady=entry_pady)

	def clickQuit(self):
		self.myParent.destroy()	

	def clickCalc(self):
		self.buttonQuit.configure(state=DISABLED)

	def clickPrint(self):
		self.buttonQuit.configure(state=NORMAL)

	def clickNew(self):	
		self.frame2Enable()

	def frame2Disable2():
		self.entrySourcenumber(state=DISABLED)
		self.entryChecksource(state=DISABLED)
		self.entryBkgcount(state=DISABLED)
		self.entryWipecount(state=DISABLED)
		self.entryResult(state=DISABLED)

	def frame2Enable(self):
		self.entrySourcenumber(state=NORMAL)
		self.entryChecksource(state=NORMAL)
		self.entryBkgcount(state=NORMAL)
		self.entryWipecount(state=NORMAL)
		self.Result(state=NORMAL)

root = Tk()
MainGUI = MAINGUI(root)
root.mainloop()

Reply With Quote
  #4  
Old February 5th, 2004, 05:31 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Thanks, that helped alot!

Anyway i've managed to trace you're error back to the frame2Enable() method. And the reason for the error is that your trying to alter the arguments in your Entry() boxes after they've been called and assigned to variables i.e.

Code:
>>> class someclass:
...     def __init__(self, args): self.args = args
...     
>>> instance = someclass('argument')
>>> instance('altering')
Traceback (most recent call last):
  File "<input>", line 1, in ?
AttributeError: someclass instance has no __call__ method
>>>


Try changing this function to read. However i havnt tested this and to be honest i've never had to change a argument after calling. Bu then i'm not really a big GUI fan anyway

Code:
def frame2Enable(self):
		self.entrySourcenumber.state=NORMAL
		self.entryChecksource.state=NORMAL
		self.entryBkgcount.state=NORMAL
		self.entryWipecount.state=NORMAL
		self.Result.state=NORMAL


Mark.

Reply With Quote
  #5  
Old February 6th, 2004, 06:00 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
Hi mistersmith,

Normally you would call a widgets config method to change things.
So (untested ):
Code:
def frame2Enable(self):
   self.entrySourcenumber.config(state=NORMAL)
   self.entryChecksource.config(state=NORMAL)
   self.entryBkgcount.config(state=NORMAL)
   self.entryWipecount.config(state=NORMAL)
   self.Result.config(state=NORMAL)


You may also have to call self.mainFrame.update() to force the refresh.

Cheers,
Grim

Reply With Quote
  #6  
Old February 6th, 2004, 08:30 AM
mistersmith mistersmith is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 mistersmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Incredible.
So, this is what's been killing me for the last 3 days? The .config worked - many many thanks for replying and helping me out.

Cheers,
Jeff

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Tkinter AttributeError: Entry has no __call__ method


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway