From: Alex T. <al...@tw...> - 2005-06-07 18:19:33
|
John Henry wrote: >No, the processing code has nothing with the problem. >The point is that the mere existence of the keyPress >handling is causing the crash. May be my handler is >not correct. I looked at the sample Pythoncard sample >programs and didn't find any sample code on how to add >the keyPress event. > > Can you please send the complete traceback report. Alternatively, here's a simple example that works OK for me ... #!/usr/bin/python """ __version__ = "$Revision: 1.5 $" __date__ = "$Date: 2004/04/30 16:26:12 $" """ rsrc = {'application':{'type':'Application', 'name':'Template', 'backgrounds': [ {'type':'Background', 'name':'bgTemplate', 'title':'Standard Template with File->Exit menu', 'size':(400, 300), 'style':['resizeable'], 'menubar': {'type':'MenuBar', 'menus': [ {'type':'Menu', 'name':'menuFile', 'label':'&File', 'items': [ {'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit', 'command':'exit', }, ] }, ] }, 'components': [ {'type':'TextArea', 'name':'TextArea1', 'position':(52, 82), 'size':(205, 138), 'actionBindings':{}, 'text':'TextArea1', }, {'type':'TextField', 'name':'TextField1', 'position':(10, 10), 'size':(179, -1), 'actionBindings':{}, 'text':'TextField1', }, ] # end components } # end background ] # end backgrounds } } from PythonCard import model class MyBackground(model.Background): def on_initialize(self, event): # if you have any initialization # including sizer setup, do it here pass def on_TextField1_keyPress(self, event): print event.keyCode self.components.TextArea1.text = self.components.TextArea1.text + "%d\n" % (event.keyCode) pass if __name__ == '__main__': app = model.Application(MyBackground, None, rsrc) app.MainLoop() -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.2 - Release Date: 04/06/2005 |