0

I'm training with Python, learning how to build GUIs.

I made a simple calculator made by 4 functions (+,-,*,/):

def sum(a, b):
    c = a + b
    return c

def sub(a, b):
    c = a - b
    return c

def mlt(a, b):
    c = a * b
    return c

def div(a, b):
    c = a / b
    return c

My program's CLI is now made like this:

def calc(foo):
        try:
            if foo == '1':
                print('You chose addition. Input the two numbers:')
                a = int(input('First: '))
                b = int(input('Second: '))
                return print('Result is:', sum(a, b))
        except:
            print('ERROR: Invalid Input')

Full if chain for the CLI is very clumsy and long, and I want to semplify that to my user. Would you give me an example on how I could give this program a GUI using Tkinter?

  • You've got a couple problems here... [Why is Button parameter “command” executed when declared?](https://stackoverflow.com/q/8269096/953482) addresses one of them – Kevin May 24 '19 at 17:58
  • 1
    "outputs incorrect stuff" is a bit too vague. Please try to be a bit more specific. – Bryan Oakley May 24 '19 at 18:38
  • It outputs floats. They are related to my input, but i cant understand what the code does. 6 and 6 outputs 13. 10 and 10 20. I don't know how to explain, i can provide you with what i wrote –  May 25 '19 at 14:28

0 Answers0