For an equalizer that is part of a bigger GUI,
I made a FOR loop to accommodate all the different scales. I would like to pass the 'freq' value during each function call.
# Frequencies to equalize
freq=['100','250','500','1000','2000','3000','4000','5000','6000','8000']
yval=0
for index, value in enumerate(freq):
# Freq (Hz)
yval=yval+1
xval=1
self.create_label(EQframe,xval,yval,value+' Hz')
# yval=yval
xval=2
# self.create_scale(Oliveframe,xval,yval,32,512,32,"vertical",128)
self.create_EQ_scale(EQframe,xval,yval,0.5,-0.5,0.1,"vertical",0,100,'Red',value,self.eq_coeff)
Therefore when the user changes the scale, i want to be able to save the adjusted scale data in a global variable for the corresponding 'freq'.
def create_EQ_scale(self,parent,xval,yval,start,end,resolution,orient,default,lng,clr,ch_no,cmdtrig):
OHAEQ_scale = tk.Scale(parent,resolution=resolution, from_=start, to=end, orient=orient,length=lng,fg=clr,command=lambda ch_no: cmdtrig(ch_no))
OHAEQ_scale.grid(row=xval, column=yval, sticky=tk.E + tk.W + tk.N + tk.S, padx=20, pady=4)
OHAEQ_scale.set(default)
In order to test the function , I wrote the following
def eq_coeff(self, ch_no):
print(ch_no)
The function gets called like i want it to. I was hoping it would print the 'freq' value based on which scale i adjusted, but it rather shows the actual value of the scale, i.e 0.1 or 0.2 rather than the freq value. I know its probably something simple, but i can't quite figure out what i have done wrong. :(