Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

BUG: changing StyledDateEditor to use sync_value() instead of on_trai…

…t_change(). Fix imports.
  • Loading branch information...
commit 28425805845588eb38779bb3f63b191a2e34ed1f 1 parent e25d365
@rkern rkern authored
8 integrationtests/
@@ -1,12 +1,12 @@
from datetime import date
-from enthought.etsconfig.api import ETSConfig
+from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
-from enthought.traits.api import Date, Dict, HasTraits, List, on_trait_change
-from enthought.traits.ui.api import View, Item, StyledDateEditor
-from enthought.traits.ui.editors.styled_date_editor import CellFormat
+from traits.api import Date, Dict, HasTraits, List, on_trait_change
+from traitsui.api import View, Item, StyledDateEditor
+from traitsui.editors.styled_date_editor import CellFormat
class Foo(HasTraits):
dates = Dict()
2  traitsui/editors/
@@ -1,5 +1,5 @@
-from ...api import Bool, List, Str
+from traits.api import Bool, List, Str
from .date_editor import DateEditor
class CellFormat(object):
27 traitsui/qt4/
@@ -1,6 +1,8 @@
-from PyQt4 import QtCore, QtGui
-from PyQt4.QtGui import QFont
+from pyface.qt import QtCore, QtGui
+from pyface.qt.QtGui import QFont
+from traits.api import Dict
# For a simple editor style, we just punt and use the same simple editor
# as in the default date_editor.
@@ -10,6 +12,10 @@
class CustomEditor(DateCustomEditor):
+ dates = Dict()
+ styles = Dict()
def init(self, parent):
self.control = QtGui.QCalendarWidget()
@@ -20,19 +26,14 @@ def init(self, parent):
if self.factory.dates_trait and self.factory.styles_trait:
- # Attach listeners to the factory
- self.object.on_trait_change(self._set_dates, self.factory.dates_trait)
- self.object.on_trait_change(self._update_dates, self.factory.dates_trait + "_items")
- self.object.on_trait_change(self._set_styles, self.factory.styles_trait)
- self.object.on_trait_change(self._update_styles, self.factory.styles_trait + "_items")
- self._set_styles(None, getattr(self.object, self.factory.styles_trait))
- self._set_dates(None, getattr(self.object, self.factory.dates_trait))
+ self.sync_value(self.factory.dates_trait, "dates", "from")
+ self.sync_value(self.factory.styles_trait, "styles", "from")
- def _set_dates(self, old, new):
+ def _dates_changed(self, old, new):
# Someone changed out the entire dict. The easiest, most robust
# way to handle this is to reset the text formats of all the dates
# in the old dict, and then set the dates in the new dict.
@@ -42,7 +43,7 @@ def _set_dates(self, old, new):
styles = getattr(self.object, self.factory.styles_trait, None)
self._apply_styles(styles, new)
- def _update_dates(self, event):
+ def _dates_items_changed(self, event):
# Handle the added and changed items
groups_to_set = event.added
@@ -52,7 +53,7 @@ def _update_dates(self, event):
# Handle the removed items by resetting them
[map(self._reset_formatting, dates) for dates in event.removed.values()]
- def _set_styles(self, old, new):
+ def _styles_changed(self, old, new):
groups = getattr(self.object, self.factory.dates_trait, {})
if not new:
# If no new styles, then reset all the dates to a default style
@@ -61,7 +62,7 @@ def _set_styles(self, old, new):
self._apply_styles(new, groups)
- def _update_styles(self, event):
+ def _styles_items_changed(self, event):
groups = getattr(self.object, self.factory.dates_trait)
styles = getattr(self.object, self.factory.styles_trait)

0 comments on commit 2842580

Please sign in to comment.
Something went wrong with that request. Please try again.