473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

global name 'fetchone' is not defined (GUI TKINTER PYTHON)

I was given this question to solve from my Intro to Python professor.

Tkinter: (Create an investment-value calculator) Write a program that calculates the future value of an investment at a given interest rate for a specified number of years. The formula for the calculation is as follows:
futureValue = investmentAmount * (1 + monthlyInterestRate) ^ years * 12
Use text fields for users to enter the investment amount, years, and interest rate. Display the future amount in a text field when the user clicks the Calculate button.

So far I have:

from Tkinter import *

fields = ('Investment Amount', 'Years', 'Interest Rate', 'Future Value')

def future_value(entries):

# period rate:

r = float(int(entries['Investment Amount'].get())*(1+int(entries['Interest Rate'].get()))^int(entries['Years'].get())*12)

entries['Future Value'].delete(0,END)

entries['Future Value'].insert(0, r)

def makeform(root, fields):

entries = {}

for field in fields:

row = Frame(root)

lab = Label(row, width=22, text=field+": ", anchor='w')

ent = Entry(row)

ent.insert(0,"0")

row.pack(side=TOP, fill=X, padx=5, pady=5)

lab.pack(side=LEFT)

ent.pack(side=RIGHT, expand=YES, fill=X)

entries[field] = ent

return entries

if __name__ == '__main__':

root = Tk()

ents = makeform(root, fields)

root.bind('<Return>', (lambda event, e=ents: fetchone(e)))

b1 = Button(root, text='Calculate',

command=(lambda e=ents: future_value(e)))

b1.pack(side=LEFT, padx=5, pady=5)

b3 = Button(root, text='Quit', command=root.quit)

b3.pack(side=LEFT, padx=5, pady=5)

root.mainloop()



but I get this error: global name 'fetchone' is not defined

The professor has us coding with Pycharm which is 2.6 I believe
Nov 9 '17 #1
0 2634

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Lord Jester | last post by:
Looking for any suggestions for a GUI for python under linux. Right now I'm just starting out but latter on I want to get into building programs that have GUIs. Any suggestions?
8
by: marco | last post by:
this week, i've seen a little GUI for python/win32 .. a little library which can use simple dialog (openfile, opendir, messagebox, progressbar ... and that's all) ... it worked only on win32...
5
by: NetKev | last post by:
I added a function 'warn_Admin' and defined it just before another function 'process_log'. 'process_log' calls this warn_Admin' function. However, when it gets called i get the following error...
2
by: a | last post by:
def fn(): for i in range(l) global count count= .... how do i declare count to be global if it is an array subsequently i should access or define count as an array error:
5
by: koutoo | last post by:
I am new to python as I have been a VB programmer. I am used to the GUI interface, and was wondering if I had to choose between a GUI for Python, which one should I go with? Thanks. Kou
3
by: barronmo | last post by:
I'm getting an error msg I don't understand, "global name EMR_globals is not defined", and could use some help. I've separated the application I'm building into several modules. One of the...
2
by: yorlina007 | last post by:
Hi I need to design a tkinter widget where i should have a browse option button as you see in all windows application to select a file from my machine. Also i need to select an integer from...
2
by: fatihmert95 | last post by:
Hi guys, I am devoloping with Pillow and (Tkinter,BmpImagePlugin,cStringIO,subprocess,ctypes,re .. n) modules I am using this way when if this situation show me AttributeError from PIL...
2
by: Dlerln | last post by:
Hello, first of all I want to say that this is new for me and maybe this question/error for others can be ridiculos. So, I have the script tinfoleak 1.5 and after some obstacles, I have filled up...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.