the tkinter calculator doesn’t work when i import it

Although you are allowed to have more than one master/root window, you shouldn’t. It introduces problems, as you can see. It’s preferable to have one master/root. Because that’s how it’s treated.

Instead, use TopLevel() as acw1668 suggested. Effbot’s Documentation of TopLevel

Otherwise, the problem is with the Entry, not the buttons. The buttons set the stringvar appropriately, but the entry does not get updated with that new value.

A cheap terrible solution is to put

def updateEntry():
    entry.insert(0, equation.get())
equation.trace_add("write", lambda *_ : updateEntry())

after you make the entry. But this adds more problems when you run the calculator by itself. Don’t do it. Please.

I’m not sure what the other program does, but making it a toplevel is the best solution.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top