dabo Commit
Revision 2575
Date: 2006-12-21 13:31:39 -0800 (Thu, 21 Dec 2006)
Author: Carl
Changed:
U branches/carl/dabo/db/dCursorMixin.py
U branches/carl/dabo/lib/propertyHelperMixin.py
U branches/carl/dabo/ui/uiwx/dForm.py
U branches/carl/dabo/ui/uiwx/dGrid.py
U branches/carl/dabo/ui/uiwx/dImage.py
U branches/carl/dabo/ui/uiwx/dStatusBar.py
Log:
merging with trunk
Diff:
Modified: branches/carl/dabo/db/dCursorMixin.py
===================================================================
--- branches/carl/dabo/db/dCursorMixin.py 2006-12-21 18:55:15 UTC (rev
2574)
+++ branches/carl/dabo/db/dCursorMixin.py 2006-12-21 21:31:39 UTC (rev
2575)
@@ -193,9 +193,9 @@
break
else:
raise UnicodeDecodeError, e
- elif isinstance(field_val, array.array):
- # Usually blob data
- ret = val.tostring()
+# elif isinstance(field_val, array.array):
+# # Usually blob data
+# ret = field_val.tostring()
return ret
@@ -210,13 +210,16 @@
#### NOTE: NEEDS TO BE TESTED THOROUGHLY!!!! ####
# Some backends, notably Firebird, require that fields be
specially marked.
+ if not isinstance(sql, unicode):
+ sql = unicode(sql, self.Encoding)
sql = self.processFields(sql)
# Make sure all Unicode characters are properly encoded.
- if isinstance(sql, unicode):
- sqlEX = sql.encode(self.Encoding)
- else:
- sqlEX = sql
+# if isinstance(sql, unicode):
+# sqlEX = sql.encode(self.Encoding)
+# else:
+# sqlEX = sql
+ sqlEX = sql
try:
if params is None or len(params) == 0:
@@ -1918,7 +1921,7 @@
except (dException.dException,
dException.NoRecordsException):
err = True
if err:
- raise AttributeError, _(" '%s'
object has no attribute '%s' ") % (self.cursor.DataSource, att)
+ raise AttributeError, _("Record
has no field '%s'") % att
return ret
def __setattr__(self, att, val):
Modified: branches/carl/dabo/lib/propertyHelperMixin.py
===================================================================
--- branches/carl/dabo/lib/propertyHelperMixin.py 2006-12-21 18:55:15 UTC
(rev 2574)
+++ branches/carl/dabo/lib/propertyHelperMixin.py 2006-12-21 21:31:39 UTC
(rev 2575)
@@ -163,15 +163,15 @@
self.setProperties({"FontBold": True}, ForeColor="Red")
"""
def _setProps(_propDict):
- delayedSetter, delayedValue = None, None
+ delayedSettings = {}
for prop in _propDict.keys():
propRef = eval("self.__class__.%s" % prop)
if type(propRef) == property:
setter = propRef.fset
if setter is not None:
- if prop == "Value":
+ if prop in ("Value", "Picture"):
# We need to delay
setting this to last
- delayedSetter,
delayedValue = setter, _propDict[prop]
+ delayedSettings[setter]
= _propDict[prop]
else:
setter(self,
_propDict[prop])
else:
@@ -179,8 +179,9 @@
raise ValueError,
"Property '%s' is read-only." % prop
else:
raise AttributeError, "'%s' is not a
property." % prop
- if delayedSetter is not None:
- delayedSetter(self, delayedValue)
+ if delayedSettings is not None:
+ for setter, val in delayedSettings.items():
+ setter(self, val)
# Set the props specified in the passed propDict dictionary:
_setProps(propDict)
Modified: branches/carl/dabo/ui/uiwx/dForm.py
===================================================================
--- branches/carl/dabo/ui/uiwx/dForm.py 2006-12-21 18:55:15 UTC (rev 2574)
+++ branches/carl/dabo/ui/uiwx/dForm.py 2006-12-21 21:31:39 UTC (rev 2575)
@@ -113,10 +113,10 @@
# Don't let the form close, or requery happen
return False
elif response == True: ## yes
- for biz in bizList:
+ for biz in changedBizList:
self.save(dataSource=biz.DataSource)
elif response == False: ## no
- for biz in bizList:
+ for biz in changedBizList:
self.cancel(dataSource=biz.DataSource)
return True
@@ -353,16 +353,18 @@
# A False from confirmChanges means "don't proceed"
return
- self.setStatusText(_("Please wait... requerying dataset..."))
+# self.setStatusText(_("Please wait... requerying dataset..."))
try:
+ busy = dabo.ui.busyInfo(_("Please wait... requerying
dataset..."))
self.stopWatch.Start()
- response = dProgressDialog.displayAfterWait(self, 2,
bizobj.requery)
-# response = bizobj.requery()
+# response = dProgressDialog.displayAfterWait(self, 2,
bizobj.requery)
+ response = bizobj.requery()
self.stopWatch.Pause()
elapsed = round(self.stopWatch.Time()/1000.0, 3)
self.update()
+ del busy
# Notify listeners that the row number changed:
self.raiseEvent(dEvents.RowNumChanged)
Modified: branches/carl/dabo/ui/uiwx/dGrid.py
===================================================================
--- branches/carl/dabo/ui/uiwx/dGrid.py 2006-12-21 18:55:15 UTC (rev 2574)
+++ branches/carl/dabo/ui/uiwx/dGrid.py 2006-12-21 21:31:39 UTC (rev 2575)
@@ -442,7 +442,7 @@
att = self._gridColAttr = parent._defaultGridColAttr.Clone()
att.SetFont(self._getDefaultFont()._nativeFont)
- super(dColumn, self).__init__(properties, *args, **kwargs)
+ super(dColumn, self).__init__(properties, attProperties, *args,
**kwargs)
self._baseClass = dColumn
@@ -3669,7 +3669,7 @@
if self._constructed():
self.SetColLabelSize(val)
else:
- self._properties["HeaderHeight"]
+ self._properties["HeaderHeight"] = val
def _getHeaderHorizontalAlignment(self):
Modified: branches/carl/dabo/ui/uiwx/dImage.py
===================================================================
--- branches/carl/dabo/ui/uiwx/dImage.py 2006-12-21 18:55:15 UTC (rev
2574)
+++ branches/carl/dabo/ui/uiwx/dImage.py 2006-12-21 21:31:39 UTC (rev
2575)
@@ -7,12 +7,12 @@
import dabo.dEvents as dEvents
from dabo.dLocalize import _
#import dControlMixin as dcm
-import dDataControlMixin as dcm
+from dDataControlMixin import dDataControlMixin as dcm
import dImageMixin as dim
from dabo.ui import makeDynamicProperty
-class dImage(dcm.dDataControlMixin, dim.dImageMixin, wx.StaticBitmap):
+class dImage(dcm, dim.dImageMixin, wx.StaticBitmap):
""" Create a simple bitmap to display images."""
def __init__(self, parent, properties=None, attProperties=None,
*args, **kwargs):
@@ -23,11 +23,14 @@
self._imgProp = 1.0
self._rotation = 0
self.__image = None
+ self._inShowPic = False
+ self.__val = None
+ self.__imageData = None
bmp = wx.EmptyBitmap(1, 1)
picName = self._extractKey((kwargs, properties, attProperties),
"Picture", "")
dim.dImageMixin.__init__(self)
- dcm.dDataControlMixin.__init__(self, preClass, parent,
properties,
+ dcm.__init__(self, preClass, parent, properties, attProperties,
bitmap=bmp, *args, **kwargs)
# Display the picture, if any. This will also initialize the
@@ -42,8 +45,12 @@
def _onResize(self, evt):
self._showPic()
+
+ def update(self):
+ dabo.ui.callAfterInterval(100, super(dImage, self).update)
+
def rotateCounterClockwise(self):
self._rotation -= 1
if self._rotation == -4:
@@ -81,9 +88,13 @@
def _showPic(self):
"""Displays the picture according to the ScaleMode and image
size."""
+ if self._inShowPic:
+ return
if not self._Image.Ok():
# No image to display
- return
+ self.Bitmap = wx.EmptyBitmap(1, 1)
+ self.SetBitmap(self.Bitmap)
+ return
img = self._Image.Copy()
switchProportions = False
@@ -134,7 +145,7 @@
# Stretch; just use the control size
img = img.Scale(w, h)
- # We have the adjusted image; now generate the bitmap
+ # We have the adjusted image; now generate the bitmap
self.Bitmap = img.ConvertToBitmap()
self._bitmapHeight = self.Bitmap.GetHeight()
self._bitmapWidth = self.Bitmap.GetWidth()
@@ -142,9 +153,11 @@
try:
self.SetBitmap(self.Bitmap)
except TypeError, e: pass
+ self._inShowPic = True
self.SetSize((origW, origH))
+ self._inShowPic = False
+
-
# Property definitions
def _getPic(self):
return self._picture
@@ -165,13 +178,16 @@
self._picture = ""
self._rotation = 0
self._bmp = wx.EmptyBitmap(1, 1, 1)
- self.__image =
self._bmp.ConvertToImage()
+ self.__image = wx.EmptyImage(1, 1)
# self._bmp.ConvertToImage()
self._showPic()
return
self._picture = val
self._rotation = 0
self._Image.LoadFile(val)
- self._imgProp = float(self._Image.GetWidth()) /
float(self._Image.GetHeight())
+ if self._Image.Ok():
+ self._imgProp = float(self._Image.GetWidth()) /
float(self._Image.GetHeight())
+ else:
+ self._imgProp = 1.0
self._showPic()
@@ -190,14 +206,18 @@
def _getValue(self):
+ return self.__val
try:
ret = self.__imageData
except AttributeError:
- ret = self.__imageData = ""
+ ret = self.__imageData = u""
return ret
def _setValue(self, val):
if self._constructed():
+ if self.__val == val:
+ return
+ self.__val = val
try:
isFile = os.path.exists(val)
except TypeError:
@@ -205,27 +225,23 @@
if not isFile:
# Probably an image stream
try:
+ log = wx.LogNull()
img = dabo.ui.imageFromData(val)
except:
# No dice, so just bail
- img = ""
+ img = wx.EmptyImage(1, 1)
self._setPic(img)
else:
self._setPic(val)
- if (type(self.Value) != type(val) or self.Value != val):
-
- import datetime
- print datetime.datetime.now()
-
+ if ((type(self.__imageData) != type(val)) or
(self.__imageData != val)):
hnd, tfname = tempfile.mkstemp()
- self.__image.SaveFile(tfname,
wx.BITMAP_TYPE_BMP)
- self.__imageData = open(tfname, "rb").read()
-
- print datetime.datetime.now()
-
-
+ try:
+ self.__image.SaveFile(tfname,
wx.BITMAP_TYPE_BMP)
+ self.__imageData = open(tfname,
"rb").read()
+ except StandardError,e:
+ self.__imageData = u""
self._afterValueChanged()
- self.flushValue()
+ self.flushValue()
else:
self._properties["Value"] = val
Modified: branches/carl/dabo/ui/uiwx/dStatusBar.py
===================================================================
--- branches/carl/dabo/ui/uiwx/dStatusBar.py 2006-12-21 18:55:15 UTC (rev
2574)
+++ branches/carl/dabo/ui/uiwx/dStatusBar.py 2006-12-21 21:31:39 UTC (rev
2575)
@@ -20,3 +20,19 @@
dcm.dControlMixin.__init__(self, preClass, parent, properties,
*args, **kwargs)
+
+ def layout(self):
+ """ Wrap the wx version of the call, if possible. """
+ self.Layout()
+ for child in self.Children:
+ try:
+ child.layout()
+ except: pass
+ try:
+ # Call the Dabo version, if present
+ self.Sizer.layout()
+ except:
+ pass
+ if self._platformIsWindows:
+ self.refresh()
+
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev