On 06/05/2013 at 12:52, xxxxxxxx wrote:
I'm using the DATETIME GUI within a res file and it shows ok.
However, is there a standard way to get/set the DATETIME GUI, like self.SetDateTime / self.GetDateTime?
At this moment I use the following code to init and read the DATETIME GUI.
I have the feeling it is not the optimal / best way?
RES file:
DATETIME SOLAR_DATE_TIME {NOW_BUTTON;}
INIT:
def Init(self, node) :
tag = node
data = tag.GetDataInstance()
dtr = data[SOLAR_DATE_TIME]
td=datetime.strptime('01.01.2010 00:00:00',"%d.%m.%Y %H:%M:%S")
dtd=DateTimeData()
dtd.SetDateTime(td)
data.SetData(SOLAR_DATE_TIME,dtd)
return True
GETTING THE INPUT:
def Execute(self, tag, doc, op, bt, priority, flags) :
data = tag.GetDataInstance() #get GUI data
dtr = data[SOLAR_DATE_TIME]
datetime = dtr.GetDateTime ()
print datetime
.....
Note: It is a TagPlugin
Note: I had to add "import time", else strptime gave me an error.