It would be easier to remove and then just add the second OptionMenu
field after the month changes.
Like this:
...
thirtyMonthList = [4,6,9,11]
initialMonth = IntVar(self)
initialMonth.set(1)
initialDay = IntVar(self)
initialDay.set(1)
def removeDayOptionMenu():
self.om.destroy()
def setDayList(event):
removeDayOptionMenu()
if initialMonth.get() == 2:
addDayOptionMenu(range(1,29))
elif initialMonth.get() in thirtyMonthList:
addDayOptionMenu(range(1,31))
else:
addDayOptionMenu(range(1,32))
def addDayOptionMenu(dayList):
self.om = OptionMenu(self, initialDay, *dayList)
self.om.grid(row=1)
self.om2 = OptionMenu(self, initialMonth, *range(1,12), command = setDayList)
self.om2.grid(row=0)
self.om = OptionMenu(self, initialDay, *range(1,32))
self.om.grid(row=1)