dabo Commit
Revision 2225
Date: 2006-06-20 05:42:34 -0700 (Tue, 20 Jun 2006)
Author: ed
Changed:
U trunk/dabo/ui/uiwx/dGrid.py
U trunk/dabo/ui/uiwx/dPemMixin.py
U trunk/dabo/ui/uiwx/dTextBox.py
Log:
Changed the default for drawBitmap() to be transparent. You can pass
transparent=False to get the old behavior.
Fixed a few more problems in dGrid that were caused by the recent addition of
sorting to refresh(). There is now an optional 'sort' parameter to refresh;
passing sort=False when you know the data and its order hasn't changed will
speed things up.
Began implementing support for Time data types into dTextBox. It is still under
development, and needs more testing, but at least it doesn't break any existing
functionality for any other data type.
Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2006-06-20 12:41:56 UTC (rev 2224)
+++ trunk/dabo/ui/uiwx/dGrid.py 2006-06-20 12:42:34 UTC (rev 2225)
@@ -781,7 +781,7 @@
if self._constructed():
self._gridColAttr.SetReadOnly(not val)
if self.Parent:
- self.Parent.refresh()
+ self.Parent.refresh(sort=False)
else:
self._properties["Editable"] = val
@@ -1205,7 +1205,7 @@
if idx >= 0:
# Change the size in the wx grid:
self.Parent.SetColSize(idx, val)
- self.Parent.refresh()
+ self.Parent.refresh(sort=False)
else:
self._properties["Width"] = val
@@ -2564,11 +2564,12 @@
return None
- def refresh(self):
- ref = self._refreshAfterSort
- self._refreshAfterSort = False
- self._restoreSort()
- self._refreshAfterSort = ref
+ def refresh(self, sort=True):
+ if sort:
+ ref = self._refreshAfterSort
+ self._refreshAfterSort = False
+ self._restoreSort()
+ self._refreshAfterSort = ref
self._syncCurrentRow()
self._syncColumnCount()
self._syncRowCount()
@@ -3984,7 +3985,7 @@
class _dGrid_test(dGrid):
def initProperties(self):
- self.DataSet = [{"name" : "Ed Lfe", "age" : 47, "coder" :
True, "color": "brown"},
+ self.DataSet = [{"name" : "Ed Leafe", "age" : 47, "coder" :
True, "color": "brown"},
{"name" : "Mike Leafe", "age" : 18, "coder" :
False, "color": "purple"},
{"name" : "Dan Leafe", "age" : 13, "coder" :
False, "color": "green"}]
self.Width = 360
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2006-06-20 12:41:56 UTC (rev 2224)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2006-06-20 12:42:34 UTC (rev 2225)
@@ -1103,10 +1103,12 @@
return obj
- def drawBitmap(self, bmp, x=0, y=0, persist=True):
+ def drawBitmap(self, bmp, x=0, y=0, persist=True, transparent=True):
"""Draws a bitmap on the object at the specified position."""
- obj = DrawObject(self, Bitmap=bmp,
- Shape="bmp", Xpos=x, Ypos=y)
+ if isinstance(bmp, basestring):
+ bmp = dabo.ui.strToBmp(bmp)
+ obj = DrawObject(self, Bitmap=bmp, Shape="bmp",
+ Xpos=x, Ypos=y, Transparent=transparent)
# Add it to the list of drawing objects
obj = self._addToDrawnObjects(obj, persist)
return obj
@@ -2104,6 +2106,7 @@
self._backColor = None
self._text = None
self._angle = 0
+ self._transparent = True
super(DrawObject, self).__init__(*args, **kwargs)
self._inInit = False
@@ -2125,7 +2128,7 @@
dc = wx.ClientDC(self.Parent)
if self.Shape == "bmp":
- dc.DrawBitmap(self._bitmap, self.Xpos, self.Ypos, False)
+ dc.DrawBitmap(self._bitmap, self.Xpos, self.Ypos,
self._transparent)
return
pw = self.PenWidth
Modified: trunk/dabo/ui/uiwx/dTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dTextBox.py 2006-06-20 12:41:56 UTC (rev 2224)
+++ trunk/dabo/ui/uiwx/dTextBox.py 2006-06-20 12:42:34 UTC (rev 2225)
@@ -82,6 +82,9 @@
# Use the ISO 8601 datetime string format (with a " "
separator
# instead of "T")
strVal = value.isoformat(" ")
+ elif isinstance(value, datetime.time):
+ # Use the ISO 8601 time string format
+ strVal = value.isoformat()
else:
# convert all other data types to string:
strVal = str(value) # (floats look like 25.55)
@@ -109,7 +112,6 @@
regex = self._dregex[format]
except KeyError:
regex = self._dregex[format] =
self._getDateRegex(format)
-
m = regex.match(strVal)
if m is not None:
groups = m.groupdict()
@@ -160,15 +162,13 @@
try:
regex = self._dtregex
except AttributeError:
- regex = self._dtregex =
re.compile(self._getDateTimeRegex())
-
+ regex = self._dtregex = self._getDateTimeRegex()
m = regex.match(strVal)
if m is not None:
groups = m.groupdict()
if len(groups["ms"]) == 0:
# no ms in the expression
groups["ms"] = 0
-
try:
return datetime.datetime(int(groups["year"]),
int(groups["month"]),
@@ -196,13 +196,49 @@
exp["second"] = "(?P<second>[0-5][0-9])" ## second
00-59
exp["ms"] = "\.{0,1}(?P<ms>[0-9]{0,6})" ## optional ms
exp["sep"] = "(?P<sep> |T)"
-
- exps = "^%s-%s-%s%s%s:%s:%s%s$" % (exp["year"], exp["month"],
- exp["day"], exp["sep"], exp["hour"], exp["minute"],
exp["second"], exp["ms"])
-
+ exps =
"^%(year)s-%(month)s-%(day)s%(sep)s%(hour)s:%(minute)s:%(second)s%(ms)s$" % exp
return re.compile(exps)
+ def _getTimeFromString(self, strVal):
+ """Given a string in ISO 8601 time format, return a
+ datetime.time object.
+ """
+ try:
+ regex = self._tmregex
+ except AttributeError:
+ regex = self._tmregex = self._getTimeRegex()
+ m = regex.match(strVal)
+ if m is not None:
+ groups = m.groupdict()
+ if len(groups["ms"]) == 0:
+ # no ms in the expression
+ groups["ms"] = 0
+ try:
+ return datetime.time(int(groups["hour"]),
+ int(groups["minute"]),
+ int(groups["second"]),
+ int(groups["ms"]))
+ except ValueError:
+ # Could be that the day was out of range for
the particular month
+ # (Sept. only has 30 days but the regex will
allow 31, etc.)
+ return None
+ else:
+ # The regex didn't match
+ return None
+
+
+ def _getTimeRegex(self):
+ exp = {}
+ exp["hour"] = "(?P<hour>[0-1][0-9]|2[0-3])" ## hour 00-23
+ exp["minute"] = "(?P<minute>[0-5][0-9])" ## minute
00-59
+ exp["second"] = "(?P<second>[0-5][0-9])" ## second
00-59
+ exp["ms"] = "\.{0,1}(?P<ms>[0-9]{0,6})" ## optional ms
+ exp["sep"] = "(?P<sep> |T)"
+ exps = "^%(hour)s:%(minute)s:%(second)s%(ms)s$" % exp
+ return re.compile(exps)
+
+
def __onKeyChar(self, evt):
"""This handles KeyChar events when ForceCase is set to a
non-empty value."""
if evt.keyChar.isalnum() or evt.keyChar in
""",./<>?;':%s[]\\{}|[EMAIL PROTECTED]&*()-_=+""" % '"':
@@ -388,12 +424,14 @@
else:
retVal = False
- elif dataType in (datetime.date, datetime.datetime):
+ elif dataType in (datetime.date, datetime.datetime,
datetime.time):
# We expect the string to be in ISO 8601 format.
if dataType == datetime.date:
retVal = self._getDateFromString(strVal)
elif dataType == datetime.datetime:
retVal = self._getDateTimeFromString(strVal)
+ elif dataType == datetime.time:
+ retVal = self._getTimeFromString(strVal)
if retVal is None:
# String wasn't in ISO 8601 format... put it
back to a valid
@@ -409,6 +447,14 @@
except ImportError:
retVal = self._value
+ elif str(dataType) == "<type 'DateTimeDelta'>":
+ # mx TimeDelta type. MySQLdb will use this for Time
columns if mx is installed.
+ try:
+ import mx.DateTime
+ retVal = mx.DateTime.TimeFrom(str(strVal))
+ except ImportError:
+ retVal = self._value
+
elif (decimal is not None and dataType == decimal.Decimal):
try:
_oldVal = self._oldVal
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev