I am working on this: http://pythoncard.sourceforge.net/walkthrough2.html
and instead of rewriting each function, I tried to alias them. However, that
does not work. Can anyone explain why? Code below:
#!/usr/bin/python
import sys
"""
__version__ = "$Revision: 1.8 $"
__date__ = "$Date: 2005/12/17 15:20:02 $"
"""
from PythonCard import model, dialog
class Counter(model.Background):
"""
def __init__(self):
self.initialValue = 666
"""
def on_menuFileAbout_select(self, event):
result = dialog.alertDialog(self,
self.components.field1.text,
'Showing off')
def valueDelta(self, delta):
startValue = int(self.components.field1.text)
endValue = startValue + delta
self.components.field1.text = str(endValue)
def on_incrBtn_mouseClick(self, event):
self.valueDelta(1)
def on_decrBtn_mouseClick(self, event):
self.valueDelta(-1)
def on_resetBtn_mouseClick(self, event):
self.components.field1.text = str(222)
"""Either of these works:
def on_menuIncr_select(self, event):
# works: self.valueDelta(1)
# works: self.on_incrBtn_mouseClick(event)
but when I try to directly alias the function to another, it
just hangs:
"""
on_menuIncr_select = on_incrBtn_mouseClick
if __name__ == '__main__':
app = model.Application(Counter)
app.MainLoop()
|