dabo Commit
Revision 3782
Date: 2007-12-10 04:39:32 -0800 (Mon, 10 Dec 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3782
Changed:
U trunk/dabo/ui/uiwx/dPemMixin.py
Log:
Added the 'getDisplayLocker()' method. This returns a simple object that locks
the display when created, and unlocks when destroyed. This is a safer way to
lock the display, since as soon as the code in which this is created goes out
of scope, the object will be released and the screen unlocked. You may also
release it manually.
Fixed a bug in the containerCoordinates() method in cases where the container
is the form itself.
Diff:
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2007-12-10 05:46:02 UTC (rev 3781)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2007-12-10 12:39:32 UTC (rev 3782)
@@ -764,6 +764,29 @@
dabo.errorLog.write(_("Extra call to unlockDisplay()
for object %s") % self)
+ def getDisplayLocker(self):
+ """Returns an object that locks the current display when
created, and
+ unlocks it when destroyed. This is generally safer than calling
lockDisplay()
+ and unlockDisplay(), especially when used with
callAfterInterval(), when
+ the unlockDisplay() calls may not all happen.
+ """
+ class DisplayLocker(object):
+ def __init__(self, obj):
+ self._obj = obj
+ obj.Freeze()
+
+ def __del__(self):
+ try:
+ self._obj.Thaw()
+ except StandardError, e:
+ # Create an error log message. We can't
record the obj reference,
+ # since it is most likely deleted, but
the presence of these messages
+ # will ensure that possible problems
will not be silenced.
+ dabo.errorLog.write(_("Failed to unlock
display: %s") % e)
+ release = __del__
+ return DisplayLocker(self)
+
+
def bringToFront(self):
"""Makes this object topmost"""
self.Raise()
@@ -870,6 +893,10 @@
l, t = pos
# If the container is a page, we need to use its containing
# pageframe/pagelist, etc.
+ if isinstance(cnt, dabo.ui.dForm):
+ return (l, t)
+ # If the container is a page, we need to use its containing
+ # pageframe/pagelist, etc.
if isinstance(cnt, dabo.ui.dPage):
cnt = cnt.Parent
p = self
@@ -892,8 +919,8 @@
l = posX - cntX
t = posY - cntY
return (l, t)
+
-
def objectCoordinates(self, pos=None):
"""Given a position relative to the form, return a position
relative
to this object. If no position is passed, returns the position
@@ -1234,7 +1261,7 @@
else:
dc = wx.ClientDC(obj)
rect = self.GetRect()
- bmp = wx.EmptyBitmap(rect.width, rect.height) # - htReduction)
+ bmp = wx.EmptyBitmap(rect.width, rect.height, -1) # -
htReduction)
memdc = wx.MemoryDC()
memdc.SelectObject(bmp)
@@ -2777,7 +2804,10 @@
dc.SetLogicalFunction(logic)
srcObj = self.Parent
if self.Application.Platform == "GTK" and not
(isinstance(srcObj, (dabo.ui.dPanel, dabo.ui.dPage))):
- x, y = self.Parent.containerCoordinates(srcObj.Parent,
(self.Xpos, self.Ypos))
+ if isinstance(srcObj, dabo.ui.dForm):
+ x, y = srcObj.containerCoordinates(srcObj,
(self.Xpos, self.Ypos))
+ else:
+ x, y =
self.Parent.containerCoordinates(srcObj.Parent, (self.Xpos, self.Ypos))
else:
x, y = self.Xpos, self.Ypos
_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]