My first script... does not work

I am trying to set the Date (immediate) of a Calendar object when a window is first opened. So I create a script on the internalFrameOpened event of the window. I first tried the Set property ta\b. This got me the path to the property but there was no way to get the date. So, I wrote this scropt myself after playing with the Script Playground:

import datetime system.gui.getParentWindow(event).getComponentForPath('Root Container.Calendar').date = datetime.datetime.now().date()

The script fires at the correct time but I get a java error:

TypeError: can't convert datetime.date(2015, 1, 22) to java.util.Date

This seems like a basic question but I have never used Python or Java so I am really stuck.

Thanks,

You can just bind now() to the date in the calendar object.

now()

You can also do dateArithmetic like so.

dateArithmetic(now(0), -1, "day")

Cheers,
Chris

Binding now() causes the calendar to revert back to now after another date is picked. I am looking to set the date when the project first loads.

I ended up running a database query with polling mode off. In MySQL:

SELECT curdate()

You can use

now(0)

0 is the pollrate

I used the Set Property tab. It generated this sctript:

value = u'now(0)' system.gui.getParentWindow(event).getComponentForPath('Root Container.Calendar').date = value
When I run the app I get this error:

TypeError: can't convert u'now(0)' to java.util.Date
I am just trying to set the current date of the calendar component to today. What am I doing wrong?

Thanks,

You want to bind the now(0) expression to the Date Property of the Calendar Component.
Like so…


Cheers,
Chris

That worked. What I am really trying to get to is setting the calendar to midnight Monday of the current week. Until I have time to muck around with the scripting some more I will use this. I did format the result of now(0) to just the date so I am getting midnight as my date. Thanks.