0
from tkinter import *
import tkinter.font

class App:

    def __init__(self, master):
        self.master = master
        self.frame = Frame(master)
        self.frame.grid()

        labell = Label(self.frame, text="min: ")
        labell.grid()

        self.min = Scale(self.frame, from_=1, to=10, orient=HORIZONTAL,
                     command=self.updateMax)
        self.min.grid(row=0, column=1, columnspan=2)

This is where the error supposedly is:

    def updateMax(self,value):
        self.max.config(from_=int(value)+1)
        self.max.config(to=int(value)+11)

    def compute(self):
        lower = self.min.get()
        upper = self.max.get()+1
        self.list.delete(0,END)
        for x in range(lower,upper):
            str = "{0:2d} {1:3d} {2:4d}".format(x,x*x,x*x*x)
            self.list.insert(END,str)

root = Tk()
app = App(root)
root.mainloop()

ERROR!!

AttributeError: 'App' object has no attribute 'max'

What am I doing wrong here? Please answer asap. Thanks.

3
  • The code you gave never defines a self.max. All I see is a self.min. Is this all of the code? Commented Nov 21, 2013 at 18:19
  • Where exactly have you defined self.max? I can't see it. (Thus, the error?!) Commented Nov 21, 2013 at 18:19
  • @iCodez and Ashish, this is all the code. I have to define max? I assumed that was what updateMax was doing? Commented Nov 21, 2013 at 18:58

1 Answer 1

2

If that is all of the code, then the problem is simple: you never defined self.max yet you try to use it here:

def updateMax(self,value):
    self.max.config(from_=int(value)+1)
    self.max.config(to=int(value)+11)

Perhaps you meant to use self.min, which you did define:

def updateMax(self,value):
    self.min.config(from_=int(value)+1)
    self.min.config(to=int(value)+11)

If not, then you need to define self.max before you use it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.