dabo Commit
Revision 3090
Date: 2007-04-26 09:41:54 -0700 (Thu, 26 Apr 2007)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/3090

Changed:
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/test/test_dForm.py

Log:
The problem with the dForm test was that we now cache calls to update(),
to avoid repeated unnecessary updates. So if more than one update() is
called within 100 ms, only one call will get processed, in the next 100 ms 
interval. This is great for an actual UI, but for the test script, which
doesn't wait for 100ms before running its tests, it isn't good.

I added a force argument to both dForm.update() and dForm.refresh();
when True, the call happens immediately like before. I can see this being
needed from user code as well in some cases, if the code relies on the
form being updated after a coded operation. I also fixed the docstrings
for those methods to actually explain what they do, instead of commenting
on the need to cache the calls.

Fixed the test to explicitly call update(True) in the needed places.


Diff:
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2007-04-26 15:34:27 UTC (rev 3089)
+++ trunk/dabo/ui/uiwx/dForm.py 2007-04-26 16:41:54 UTC (rev 3090)
@@ -96,16 +96,30 @@
                func(message=msg, title=title)
 
 
-       def refresh(self):
-               """For performance reasons, cache repeated calls."""
-               dabo.ui.callAfterInterval(100, self.__refresh)
+       def refresh(self, force=False):
+               """Repaints the form and all contained objects.
+
+               When force is False, repeated calls to refresh() will be cached 
for
+               performance reasons. Send force=True to force an immediate 
refresh.
+               """
+               if force:
+                       self.__refresh()
+               else:
+                       dabo.ui.callAfterInterval(100, self.__refresh)
        def __refresh(self):
                super(BaseForm, self).refresh()
                
                
-       def update(self):
-               """For performance reasons, cache repeated calls."""
-               dabo.ui.callAfterInterval(100, self.__update)
+       def update(self, force=False):
+               """Updates the contained controls with current values from the 
source. 
+
+               When force is False, repeated calls to update() will be cached 
for
+               performance reasons. Send force=True to force an immediate 
update.
+               """
+               if force:
+                       self.__update()
+               else:
+                       dabo.ui.callAfterInterval(100, self.__update)
        def __update(self):
                super(BaseForm, self).update()
                

Modified: trunk/dabo/ui/uiwx/test/test_dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/test/test_dForm.py       2007-04-26 15:34:27 UTC (rev 
3089)
+++ trunk/dabo/ui/uiwx/test/test_dForm.py       2007-04-26 16:41:54 UTC (rev 
3090)
@@ -33,8 +33,8 @@
 
                ## force the frm to get the first record:
                frm.first()
+               frm.update(True)  ## need to force the update here because it 
is delayed by default, which doesn't work for scripted tests.
 
-
        def tearDown(self):
                self.biz = None
                self.frm = None
@@ -66,6 +66,7 @@
                biz = frm.getBizobj()
                self.assertEqual(frm.cField.Value, "Paul Keith McNett")
                frm.next()
+               frm.update(True)  ## Need to force the update here which would 
otherwise happen 100 ms in the future.
                self.assertEqual(biz.RowNumber, 1)
                self.assertEqual(frm.cField.Value, "Edward Leafe")
 
@@ -79,6 +80,7 @@
                frm.requery()
                self.assertEqual(biz.RowCount, 4)
                frm.last()
+               frm.update(True)  ## Need to force the update here, otherwise 
it won't happen until 100 ms in the future.
                self.assertEqual(biz.RowNumber, 3)
                self.assertEqual(biz.Record.cField, None)
                self.assertEqual(biz.Record.iField, None)





_______________________________________________
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]

Reply via email to