[PEAK] Trellis-ified wx Dialog
Grant Baillie
grant at osafoundation.org
Thu Jul 19 16:37:31 EDT 2007
On 19 Jul, 2007, at 13:05, Phillip J. Eby wrote:
> At 12:46 PM 7/19/2007 -0700, Grant Baillie wrote:
>
>> On 19 Jul, 2007, at 11:55, Phillip J. Eby wrote:
>>
>>> By the way, another way to do the above would be:
>>>
>>> class EditBridge(trellis.Component):
>>> trellis.values(
>>> widget = None,
>>> cell = None,
>>> )
>>> trellis.rules(
>>> setup = lambda self: self.widget.Bind
>>> (wx.EVT_KILL_FOCUS, self.write),
>>> read = lambda self: self.widget.SetValue(self.cell),
>>> )
>>> def write(self, event):
>>> self.cell = self.widget.GetValue()
>>
>> Hmmm ... if I do that, then the read rule gets called with a widget
>> of None.
>
> Eh? That shouldn't be possible -- isn't the code passing in a
> widget in the kwargs to EditBridge? The setting of 'widget' should
> be happening before *any* rules are called. Can you check to make
> sure that you are passing a non-None widget to EditBridge()?
I am, but it looks as if the read rule is called before widget is
available:
> /Users/grant/work/chandler-1.0/samples/wxTemp/wxTemperature.py(29)
__init__()
-> super(EditBridge, self).__init__(*args, **kw)
(Pdb) kw
{'cell': Cell(<bound method TempConverter.<lambda> of
<__main__.TempConverter object at 0x3c4fb30>>, 32), 'widget':
<wx._controls.TextCtrl; proxy of <Swig Object of type 'wxTextCtrl *'
at 0x1945e00> >}
(Pdb) c
Traceback (most recent call last):
File "wxTemperature.py", line 86, in <module>
ConverterDialog().dialog.Show()
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 366, in __init__
getattr(self, k)
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 388, in __get__
return cell.value
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 62, in _get_value
self.check_dirty(pulse)
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 103, in check_dirty
new = self._rule()
File "wxTemperature.py", line 48, in <lambda>
cell = self.converter.__cells__['F']
File "wxTemperature.py", line 29, in __init__
super(EditBridge, self).__init__(*args, **kw)
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 366, in __init__
getattr(self, k)
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 388, in __get__
return cell.value
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 62, in _get_value
self.check_dirty(pulse)
File "/Users/grant/Third-Party/PEAK/Trellis/peak/events/
trellis.py", line 103, in check_dirty
new = self._rule()
File "wxTemperature.py", line 37, in <lambda>
read = lambda self: self.widget.SetValue(unicode(self.cell)),
AttributeError: 'NoneType' object has no attribute 'SetValue'
--Grant
More information about the PEAK
mailing list