dabo Commit
Revision 2573
Date: 2006-12-21 08:17:31 -0800 (Thu, 21 Dec 2006)
Author: Ed
Changed:
U trunk/dabo/ui/uiwx/dForm.py
U trunk/dabo/ui/uiwx/dGrid.py
U trunk/dabo/ui/uiwx/dImage.py
U trunk/dabo/ui/uiwx/dStatusBar.py
Log:
Fixed some issues with using the dImage control for handling blob data.
Improved the performance of dImage by removing some repeated calls to methods
such as _showPic() that were being called several dozen times per change to the
image.
Fixed the attProperties parameter issue in dColumn.
Changed the form's requery to not use the progress dialog, and just call the
bizobj requery directly. I added a dabo.ui.busyInfo() call in case of long
requeries, which was the original intent of the progress dialog.
Added a layout() method to dStatusBar. It can contain sizers and other
controls, so this makes it consistent with other Dabo containers.
Diff:
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2006-12-21 15:39:50 UTC (rev 2572)
+++ trunk/dabo/ui/uiwx/dForm.py 2006-12-21 16:17:31 UTC (rev 2573)
@@ -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: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2006-12-21 15:39:50 UTC (rev 2572)
+++ trunk/dabo/ui/uiwx/dGrid.py 2006-12-21 16:17:31 UTC (rev 2573)
@@ -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
Modified: trunk/dabo/ui/uiwx/dImage.py
===================================================================
--- trunk/dabo/ui/uiwx/dImage.py 2006-12-21 15:39:50 UTC (rev 2572)
+++ trunk/dabo/ui/uiwx/dImage.py 2006-12-21 16:17:31 UTC (rev 2573)
@@ -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: trunk/dabo/ui/uiwx/dStatusBar.py
===================================================================
--- trunk/dabo/ui/uiwx/dStatusBar.py 2006-12-21 15:39:50 UTC (rev 2572)
+++ trunk/dabo/ui/uiwx/dStatusBar.py 2006-12-21 16:17:31 UTC (rev 2573)
@@ -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