On Tuesday, April 26, 2011 10:01:29 am Paul McNett wrote:
> It could change between the two calls due to side-effects from the first
> call

Thanks for the response.

What I noted so far:

The dDateTextBox does not have a user notification (like a Dabo dialog) when a 
bad date is entered.  I have attempted to do something about that by creating 
a class that provides a dialog when the data entered is a  bad date.  But it 
only works when the data in the dDateTextBox is "<None>".  But the class does 
not provide a warning dialog when the user is attempting to change a previous 
entered good date with a bad date.  The data is reverted to the original date 
(IOW'S reverts the bad to the (original) good date).

Keeping with the principle that I should not change the framework I created a 
new class.  I even kept the old code (even thought I do not completely 
understand it).

The theory is if the data is not a datetime - then warn the user and revert.  
But it appears the actual data entered into the control is not present always 
(at my class level).  I've tried "self.Value" and "evt.EventObject.Value" and 
they do not appear to return the actual data typed by the user.  If the 
control contained a valid date that date is returned (as the value) and not 
the data the user entered.   I have  NOT determined what if anything has the 
actual value.  

If anyone has a suggestion I would appreciate the help.

class DateCheckDateTextBox(dabo.ui.dDateTextBox):

    def afterInit(self):
        self.super()
        self.bindEvent(dEvents.LostFocus, self.__myonLostFocus)

    def __myonLostFocus(self, evt):
        if not isinstance(evt.EventObject.Value, datetime.date):
            if isinstance(evt.EventObject.Value, basestring):
                if evt.EventObject.Value == '<None>':
                    return
                evt.EventObject.Value = 
dates.getDateFromString(evt.EventObject.Value)
                if not isinstance(evt.EventObject.Value, datetime.date):
                    #print 'in datetime check'
                    dabo.ui.dMessageBox.info(parent = self, message = 'Not a 
valid date')
                    return
        val = self.Value
        try:
            newVal = self.Value
            if newVal != val:
                self.Value = newVal
        except ValueError:
            pass

Thanks in advance,
Johnf
_______________________________________________
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/201104261035.25219.jo...@jfcomputer.com

Reply via email to