I created a Tkinter window. In one frame, I use matplotlib to just plot some text (I use matplotlib because I need greek math charakters). I do have more than 10 variables and two buttons for each variable which change the value of it. So, now I thought instead of have 28 functions to change the values, I could write only two functions, which change the desired variable using exec(). But that does not work...
Previous attempt for variable a:
def ap():
    global a
    a+=10
    plot()
    canvas.draw()
def am():
    global a
    a-=10
    plot()
    canvas.draw()
button_ap = Tk.Button(configframe, text='a+', command=ap).grid(row=0,column=0)
button_am = Tk.Button(configframe, text='a-', command=am).grid(row=0,column=1)
This works. As soon as I press one of the buttons, the plot is updated with the new value of a.
New attempt:
def parp(var):
    exec('global '+var)
    exec(var+'+=10')
    plot()
    canvas.draw()
def parm(var):
    exec('global '+var)
    exec(var+'-=10')
    plot()
    canvas.draw()
button_ap = Tk.Button(configframe, text='a+', command=lambda: parp('a')).grid(row=0,column=0)
button_am = Tk.Button(configframe, text='a-', command=lambda: parm('a')).grid(row=0,column=1)
This does not work.  It actually does read the variable and executes 'var+=10', because if I print the variable afterwards, it is reduced by 10. But the plot() command does not update the plot.
Do you have any idea why? Thx.
 
    