Popup Calendar

import clr
clr.AddReference('System.Windows.Forms')

from System.Windows.Forms import Form, MonthCalendar

#create a calendar
calendar = MonthCalendar()

#define what to do with the selected date
def onPickDate(sender,eventArgs):
selectedDate = calendar.SelectionRange.Start.ToShortDateString()
print selectedDate
Document.Properties["selectedDate"] = selectedDate

calendar.DateSelected += onPickDate

#put calendar in a form and show it
form = Form()
form.Text = "Select a date and close the form when done"
form.Controls.Add(calendar)
form.ShowDialog()

5 comments:

Anonymous said...

hi, I have used Popup calendar code in spotfire and its working fine at spotfire end. However I am getting error on webplayer for that calendar code. Kindly let me know how can I get rid of error.
I am getting following error.
"Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."

Leviaguirre said...

Yes, it only works on the client, but will work on a javascript version that should be cross browser compatible soon

Anonymous said...

Thanks for your kind help

Leviaguirre said...

Today I published a webplayer compatible popup calendar!

Mithun Mathews said...

Hi , Please can you let me know how you were able to publish the webplayer compatible version??.. I am using 6.0 but System.Windows.Forms is not supported in it i think??- any guidance is very much appreciated.