CVS: anygui/lib/anygui Attribs.py,1.15,1.16 Proxies.py,1.19,1.20 Wrappers.py,1.34,1.35
Samuele Pedroni <[email protected]> Tue, 10 Sep 2002 13:17:23 -0700
| Newsgroups | gmane.comp.python.anygui.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/anygui/anygui/lib/anygui
In directory usw-pr-cvs1:/tmp/cvs-serv21619
Modified Files:
Attribs.py Proxies.py Wrappers.py
Log Message:
* wrapper.widget now uses None to signal widget absence. Replaced widget presence detection exception checking control flows with if <>.widget/if not <>.widget
* fixed tk bug: geometry x,y can be negative => capture re adjusted
Index: Attribs.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Attribs.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** Attribs.py 17 Jul 2002 04:40:27 -0000 1.15
--- Attribs.py 10 Sep 2002 20:17:20 -0000 1.16
***************
*** 15,19 ****
defaults = getattr(self, 'state', {})
self.state = defaults.copy()
! self.set(*args, **kwds) # Hm...
def push(self, *names): pass
--- 15,22 ----
defaults = getattr(self, 'state', {})
self.state = defaults.copy()
! self.set(*args, **kwds)
! # @@@ should this really be here, I think I would be better
! # factored out and be responsability of the subclasses to call this,
! # for examples for proxies it generates a redundant push
def push(self, *names): pass
Index: Proxies.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Proxies.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Proxies.py 18 Jul 2002 05:46:09 -0000 1.19
--- Proxies.py 10 Sep 2002 20:17:20 -0000 1.20
***************
*** 5,12 ****
# TBD: Add docstring for class
def __init__(self, *args, **kwds):
Attrib.__init__(self, *args, **kwds)
self.rawSet(container=None)
! self.rawSet(wrapper=self.wrapperFactory()) # wrapper in state?
self.push() # Hm... Move to wrapper.internalProd?
--- 5,16 ----
# TBD: Add docstring for class
+ _wrapper_set = 0 # FIXME: if set get refactored out from Attrib.__init__
+ # it would be no longer necessary
+
def __init__(self, *args, **kwds):
Attrib.__init__(self, *args, **kwds)
self.rawSet(container=None)
! self.rawSet(wrapper=self.wrapperFactory()) # wrapper in state ?
! self._wrapper_set = 1 # FIXME
self.push() # Hm... Move to wrapper.internalProd?
***************
*** 50,61 ****
with the result.
"""
! try:
! # Never pull if our widget is a dummy - we need
! # to keep all proxy state until a real widget
! # exists.
! assert self.wrapper.widget.isDummy()
! return
! except (AttributeError, AssertionError):
! pass
state = self._partialState(*names)
self.wrapper.pull(state)
--- 54,62 ----
with the result.
"""
! if not self._wrapper_set: return
! # Never pull if our widget is non-existent - we need
! # to keep all proxy state until a real widget
! # exists.
! if not self.wrapper.widget: return
state = self._partialState(*names)
self.wrapper.pull(state)
***************
*** 73,77 ****
of the interface.) If no names are supplied, all state
variables must be supplied. If names are supplied, these must
! at a minimum be supplied. Before Proxy/Wrapper
synchronisation, the internalPush method is called.
--- 74,78 ----
of the interface.) If no names are supplied, all state
variables must be supplied. If names are supplied, these must
! at a minimum be supplied. # @@@ unused Before Proxy/Wrapper
synchronisation, the internalPush method is called.
***************
*** 85,103 ****
# We may need to modify names, so...
names = list(names)
! self.internalPush(names) # @@@ May no longer be needed
! try:
! assert(self.wrapper)
! except (AttributeError,AssertionError):
! return
self.wrapper.push(self._partialState(*names,**kwds))
! def internalPush(self, names): # @@@ May no longer be needed!
! """
! Used for internal synchronisation in the Proxy.
!
! This method is especially important for dealing with aliased
! attributes (e.g. position being an alias for (x, y)). It
! should be implemented by subclasses, if needed.
! """
def enableEvent(self, event):
--- 86,102 ----
# We may need to modify names, so...
names = list(names)
! ## @@@ unused self.internalPush(names) # @@@ May no longer be needed
! if not self._wrapper_set: return
self.wrapper.push(self._partialState(*names,**kwds))
! ## @@@ unused
! ## def internalPush(self, names): # @@@ May no longer be needed!
! ## """
! ## Used for internal synchronisation in the Proxy.
! ##
! ## This method is especially important for dealing with aliased
! ## attributes (e.g. position being an alias for (x, y)). It
! ## should be implemented by subclasses, if needed.
! ## """
def enableEvent(self, event):
***************
*** 113,118 ****
# FIXME: try/except not really acceptable... (Create backlog?
# Rearrange __init__ stuff to avoid loop?
! try: self.wrapper.enableEvent(event)
! except AttributeError: pass
def destroy(self):
--- 112,117 ----
# FIXME: try/except not really acceptable... (Create backlog?
# Rearrange __init__ stuff to avoid loop?
! if not self._wrapper_set: return
! self.wrapper.enableEvent(event)
def destroy(self):
***************
*** 123,125 ****
--- 122,125 ----
where a native widget must be explicitly destroyed.
"""
+ assert self._wrapper_set,"?! absent wrapper in proxy" # @@@ can wrapper be absent/non set?
self.wrapper.destroy()
Index: Wrappers.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/Wrappers.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** Wrappers.py 23 Aug 2002 14:00:11 -0000 1.34
--- Wrappers.py 10 Sep 2002 20:17:20 -0000 1.35
***************
*** 23,45 ****
"""
! def isDummy(obj):
! try: return obj.isDummy()
! except AttributeError: return 0
!
! class DummyWidget:
! """
! A dummy object used when a wrapper currently has no native widget
! instantiated.
! """
! def isDummy(self): return 1
!
! def __call__(self, *args, **kwds): pass
!
! def __getattr__(self, name): return DummyWidget() # DummyObject?
!
! def __setattr__(self, name, value): pass
!
! def __str__(self): return '<DummyWidget>'
!
class AbstractWrapper:
--- 23,46 ----
"""
! ##def isDummy(obj): # not needed if __nonzero__ implemented
! ## return isinstance(obj,DummyWidget)
! ##
! ##class DummyWidget:
! ## """
! ## A dummy object used when a wrapper currently has no native widget
! ## instantiated.
! ## """
! ## #def isDummy(self): return 1 # impossible to use/exploit
! ##
! ## def __call__(self, *args, **kwds): pass
! ##
! ## def __getattr__(self, name): return DummyWidget() # DummyObject?
! ##
! ## def __setattr__(self, name, value): pass
! ##
! ## def __str__(self): return '<DummyWidget>'
! ##
! ## # perhaps def __nonzero__(self): return 0
! ##
class AbstractWrapper:
***************
*** 51,55 ****
"""
! widget = DummyWidget()
def __init__(self, proxy):
--- 52,56 ----
"""
! widget = None # @@@ was DummyWidget()
def __init__(self, proxy):
***************
*** 397,412 ****
# FIXME: Deal with dummy widgets...
if application().isRunning():
! if self.noWidget():
! #try:
! # widget = self.widget
! #except AttributeError:
! # widget = None
! #try:
! # assert self.widget.isDummy()
! #except (AttributeError, AssertionError):
! # if widget is None:
! # self.widget = self.widgetFactory(*args, **kwds)
! # self.widgetSetUp()
! #else:
self.widget = self.widgetFactory(*args, **kwds)
self.widgetSetUp()
--- 398,402 ----
# FIXME: Deal with dummy widgets...
if application().isRunning():
! if not self.widget:
self.widget = self.widgetFactory(*args, **kwds)
self.widgetSetUp()
***************
*** 426,433 ****
method.
"""
self.widgetTearDown()
self.internalDestroy()
! try: del self.widget # Restore DummyWidget
! except AttributeError: pass
def internalDestroy(self):
--- 416,423 ----
method.
"""
+ if not self.widget: return
self.widgetTearDown()
self.internalDestroy()
! del self.widget # Restore None
def internalDestroy(self):
***************
*** 467,484 ****
"""
! def noWidget(self):
! """
! Returns true if this wrapper's widget has not yet been
! created by the backend (i.e. it doesn't exist, or is
! a DummyWidget).
! """
! try:
! try:
! widget = self.widget
! except AttributeError:
! return 1
! assert(widget.isDummy())
! return 1
! except (AttributeError,AssertionError):
! return 0
!
--- 457,464 ----
"""
! ## def noWidget(self):
! ## """
! ## Returns true if this wrapper's widget has not yet been
! ## created by the backend.
! ## """
! ## return isDummy(self.widget) # perhaps not self.widget
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390