dabo Commit
Revision 7205
Date: 2012-07-12 14:40:42 -0700 (Thu, 12 Jul 2012)
Author: Nate
Trac: http://trac.dabodev.com/changeset/7205

Changed:
U   trunk/dabo/ui/uiwx/dDatePicker.py

Log:
Modified the dDatePicker to better handle null values.  Since there was no 
formal way of setting null values, I bound the delete/backspace keys to do 
that.  It seemed like the best way to do it so far.  I am open to making the 
binding settable via property.

Diff:
Modified: trunk/dabo/ui/uiwx/dDatePicker.py
===================================================================
--- trunk/dabo/ui/uiwx/dDatePicker.py   2012-07-11 14:20:03 UTC (rev 7204)
+++ trunk/dabo/ui/uiwx/dDatePicker.py   2012-07-12 21:40:42 UTC (rev 7205)
@@ -70,6 +70,9 @@
                        properties, attProperties, *args, **kwargs)
                self._bindKeys()
 
+               if self.AllowNullDate:
+                       self.SetValue(None) # Need this for the datetime not to 
display the current date when Null.
+
        def _initEvents(self):
                super(dDatePicker, self)._initEvents()
                self.Bind(wx.EVT_DATE_CHANGED, self._onWxHit)
@@ -164,6 +167,8 @@
                        self.setToYearDay("Last")
                elif key == 100:        # d
                        self._setCustomDate()
+               elif key in (dabo.ui.dKeys.key_Delete, dabo.ui.dKeys.key_Back):
+                       self.Value = None
                else:
                        print key
 
@@ -189,7 +194,17 @@
                self.bindKey("y", self._processKey)
                self.bindKey("r", self._processKey)
                self.bindKey("=", self._processKey)
+               self.bindKey("backspace", self._processKey)
+               self.bindKey("delete", self._processKey)
 
+       # def __onWxKeyChar(self, evt):
+       #       self.raiseEvent(dEvents.KeyChar, evt)
+       #       dabo.ui.dCallAfterInterval(100, self.__checkNoneValue())
+       #
+       # def __checkNoneValue(self):
+       #       if super(dDatePicker, self).GetValue() == 'INVALID DateTime':
+       #               self.SetValue(None)
+
        def _getPyValue(self, val):
                if self._lastWasNone:
                        val = None
@@ -204,6 +219,8 @@
                                                self._timePart[3]
                                        )
                                )
+               print "Value after py val is '%s'" % val
+
                return val
 
        def _getWxValue(self, val):
@@ -323,7 +340,6 @@
                        raise ValueError(_("The only allowed values are: 
'Date', 'Timestamp'."))
 
        # Property definitions:
-
        AllowNullDate = property(_getAllowNullDate, _setAllowNullDate, None,
                _("""If True enable Null vale in date. 
(bool)(Default=False)"""))
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to