Hey this bit of code is giving a lot of trouble. I am new to python and have no idea why I am getting an error like this :
Traceback (most recent call last):
File "D:/Python27/saved/digital_filter.py", line 83, in <module>
app=Application(root)
File "D:/Python27/saved/digital_filter.py", line 23, in __init__
self.create_widgets()
File "D:/Python27/saved/digital_filter.py", line 49, in create_widgets
self.display_order()
File "D:/Python27/saved/digital_filter.py", line 57, in display_order
fp=float(f1)
ValueError: could not convert string to float:
Please help. Thank you in advance
#Calculating coefficients of a digital filter
#Ishwar 03-02-2013
from Tkinter import *
pi=3.1416
#create root window
class Application(Frame):
"""A GUI app to calculate FIR filter coefficients"""
def __init__(self,master):
"""Initialize the frame"""
Frame.__init__(self,master)
self.grid()
self.create_widgets()
self.display_order()
def create_widgets(self):
"""To create all the widgets"""
#lower cutoff frequency
self.lf_lbl=Label(self,text="Enter the order Lower cutoff frequency")
self.lf_lbl.grid(row=1,column=0,columnspan=2)
self.lf_ent=Entry(self)
self.lf_ent.grid(row=1,column=3,columnspan=2)
#upper cutoff frequency
self.hf_lbl=Label(self,text="Enter the order Lower cutoff frequency")
self.hf_lbl.grid(row=3,column=0,columnspan=2)
self.hf_ent=Entry(self)
self.hf_ent.grid(row=3,column=3,columnspan=2)
def display_order(self):
f1=self.lf_ent.get()
f2=self.hf_ent.get()
fp=float(f1)
fs=float(f2)
dw=2*pi*(fs-fp)
if dw<=0:
self.ord_lbl=Label(self,text="invalid Cutoff frequencies")
else:
N=int(4*pi/dw)
self.ord_lbl=Label(self,text=("The order of the Filter is ",N))
self.ord_lbl.grid(row=4,col=0)
#main
root=Tk()
root.title("FIR Digital Filter")
root.geometry("640x480")
app=Application(root)
root.mainloop()