Tkinter Callback question

Jack B. barfsky at
Mon Aug 12 22:04:13 CEST 2002

Perhaps someone can help me with the proper syntax using the
"command=" option while making a menu button.  Here's what I want to

for number in range(-4,1):
  temp = get_dates.dbdate(number)
  date_menu.add_command(label=temp, command=self.set_valid_date(temp)
menubar.add_cascade(label="Choose Date", menu=date_menu)

(get_dates.dbdate will return a correctly formatted date, given number
of days back or forward.  set_valid_date will set act on the date

This code will list dates from today back 4 days but I can't seem to
call the "command" part and pass any data.  The command executes
immediatly, and the buttons created do nothing.  Surely there is a way
to do this?  The only way I can execute a command is by NOT passing
any data, ie.. command=self.hello.


More information about the Python-list mailing list