Grabbing a number from Entry and doing calculations using Tkinter
Question: I'm working on my final project for my Intro to Programming classes and I'm
having the hardest time working with Tkinter and Python.

Here is my task: Have a user enter their income from their paycheck. The
program will then do the following calculations: What is 60% of their income
for expenses, what is 10% for BOTH short-term and long-term savings and what
is 20% of their paycheck for guilt-free spending?

Once the program has completed the calculations, it will then display each of
these calculations so the user can make the appropriate transfers with their
accounts.

**Here is the code I currently have:**

    
    
    from tkinter import *
    from tkinter import ttk
    
    def calculate(*args):
        try:
            value = float(income.get())
            expenses.set(value * .60)
            shortSavings.set(value * .10)
            longSavings.set(value * .10)
            guiltFree.set(value * .20)
    
        except ValueError:
            pass
    
    root = Tk()
    root.title("Monthly Finance Calculater")
    
    mainframe = ttk.Frame(root, padding="3 3 12 12")
    mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
    mainframe.columnconfigure(0, weight=1)
    mainframe.rowconfigure(0, weight=1)
    
    income = StringVar()
    expenses = StringVar()
    shortSavings = StringVar()
    longSavings = StringVar()
    guiltFree = StringVar()
    
    income_entry = ttk.Entry(mainframe, width=7, textvariable=income)
    income_entry.grid(column=2, row=1, sticky=(W, E))
    
    expenses = ttk.Entry(mainframe, width=7, textvariable=expenses)
    expenses.grid(column=2, row=1, sticky=(W, E))
    
    ttk.Label(mainframe, textvariable=income).grid(column=2, row=2, sticky=(W, E))
    ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W)
    
    income_entry.focus()
    root.bind('<Return>', calculate)
    
    root.mainloop()
    

I've been searching for days and I'm completely stuck. I don't want this done
for me, but could really use some guidance and advice on how to make this work
in a GUI using Tkinter.


Answer: One Problem was mentioned by Max already. The second problem is this one:

    
    
    except ValueError:
        pass
    

It's clear why you don't get anything if you pass an exception. Use at least a
print so you will get the errors shown in the console:

    
    
    except Exception as ex:
        print(ex)
    

The last real problem that i see is that you use the variable `expenses` two
times! First time as a `StringVar()` and the second time as a `Entry`. In the
end you don't have a StringVar because you overwrite it. Also consider to
label your entrys, because the user don't know what he is entering there yet.
Furthermore learn how to use the debugger in eclipse, it's much easier than
you think. So you can find the bugs yourself. I wish you good luck with your
project.

