Several things:
Try to give Tkinter and Calendar a namespace, so you know where the functions come from.
Give variables names that don't confuse, like 'l1' looks a lot like '11' in many editors, switching to 'lb1' helps readability.
Please use the [code=python] and [/code] tag pair to enclose your python code.
Here is my suggestion:
# display a monthly calendar in Tkinter
import Tkinter as tk
import calendar as cd
class MyApp(object):
def __init__(self, root, m, y):
self.m = m
self.y = y
self.frame1 = tk.Frame(root)
self.frame1.pack()
str1 = cd.month(self.y, self.m)
font1 = ('courier',14,'bold')
self.lb2 = tk.Label(self.frame1, text=str1, font=font1, bg='yellow')
self.lb2.pack()
self.b1 = tk.Button(self.frame1,text=' - ', bg="green")
self.b1.pack(side=tk.LEFT, padx=3, pady=3)
self.b2 = tk.Button(self.frame1,text=' + ',bg="red")
self.b2.pack(side=tk.RIGHT, padx=3, pady=3)
self.b1.bind("<Button-1>", self.decrease)
self.b2.bind("<Button-1>", self.increase)
root.mainloop()
def increase(self, e):
if self.m == 12:
self.m = 1
self.y = self.y + 1
else:
self.m = self.m + 1
self.lb2['text'] = cd.month(self.y, self.m)
def decrease(self, e):
if self.m == 1:
self.m = 12
self.y = self.y - 1
else:
self.m = self.m - 1
self.lb2['text'] = cd.month(self.y, self.m)
if __name__ == '__main__':
y = 2007
m = 1
root = tk.Tk()
root.title("monthly calendar")
myapp = MyApp(root, m, y)