0

I am attempting to create a calculator app in Python.

I am using a Jupyter notebook, and this is the error I run into:

AttributeError: 'Calc' object has no attribute 'clear_Entry'

And this is the code that causes this error:

btnClear = Button(
    innerFrame,
    text='C',
    width=6,
    height=2,
    font=('arial',18,'bold'),
    bd=7,
    bg='gainsboro',
    command=added_value.clear_Entry)

Here is the clear_Entry method I defined:

        def clear_Entry(self):
            self.result=False
            self.current='0'
            self.input_value= True
            self.display(0)
guychouk
  • 671
  • 1
  • 8
  • 28
  • I need help from an Professional. – Zafeer Ahmed Jul 19 '20 at 14:43
  • 1
    Hey there Zafeer, if you need help, please be sure to properly format your question and please include a minimal reproducible example of your problem _that led you to the error you posted_. Tell us a bit more about your environment as well. – guychouk Jul 19 '20 at 14:46
  • I am trying to make a calculater – Zafeer Ahmed Jul 19 '20 at 14:48
  • I am doing this in the environment of Anaconda jupyter notebook – Zafeer Ahmed Jul 19 '20 at 14:49
  • Now we're getting somewhere, can you please post here a link to your notebook? Or perhaps just the problematic chunk of code that's causing this error? By the looks of it, you are attempting to access a property called `clear_Entry` on a `Calc` object, which is missing. Please check that you don't have a typo in `clear_Entry` or something of that sort. – guychouk Jul 19 '20 at 14:54
  • I have check it many times but every time the results were same – Zafeer Ahmed Jul 19 '20 at 15:00
  • The notebook you posted is running on your local machine, not a public Jupyter notebook, so a link won't work here - you can remove it and your comment. Please take a look at my answer for more information on your situation. – guychouk Jul 19 '20 at 15:07

1 Answers1

0

Please take a look at this StackOverflow question, more specifically, this answer.

You are attempting to pass a method of the Calc object as an argument to the Button class constructor, and for some reason the added_value variable which contains a Calc object does not have the clear_Entry method on it - this is the meaning of the missing attribute error you're seeing.

Try to run a check before accessing this property that it does exist, and please look at the question I added for more information.

Also, make sure that you don't have an error, and that the clear_Entry method is defined inside the Calc class.

guychouk
  • 671
  • 1
  • 8
  • 28
  • It is giving AttributeError: 'Calc' object has no attribute 'clear_Entry' error regards to this line of code command= added_value.clear_Entry) – Zafeer Ahmed Jul 19 '20 at 15:52