From: John H. <kim...@ya...> - 2005-06-03 16:08:26
|
Thanks for the reply. "What's the platform ?" Windows XP fp 2 "Version of wxPython" wxPython2.5-win32-unicode-2.5.4.1-py23.exe "and of Python ?" 2.3.5 "Do the Pythoncard samples work OK ?" Yes. "How about the wxPython demos ?" I don't see any demo ap in the wxPython directory. I am beginning to wonder if it has to do with the keyPress event I am trying. This is what I am doing: #********* def on_tfStudy_keyPress(self, event): keyCode = event.keyCode if keyCode==13 : ...some processing code... else: event.skip() #********* Without this event, the program doesn't crash. Thanks, -- John -----Original Message----- From: pyt...@li... [mailto:pyt...@li...] On Behalf Of Liam Clarke Sent: Friday, June 03, 2005 4:57 AM To: pyt...@li... Subject: Re: [Pythoncard-users] TextField bug? On 6/3/05, Alex Tweedly <al...@tw...> wrote: kim...@ya... wrote: >Hello list, > >I am having touble with textfield objects in >Pythoncard - I am using the latest version downloaded >from www.pythoncard.org (ver 0.81?). > >I have a no-brainer application and when I run it, the >moment I hit a key when inside a textfield, I get an >exception in class point within _core.py, method >__getitem__. The code says: > > def __getitem__(self, index): > return self.Get()[index] > >and it's choking on indexing out-of-range. > >I've checked and the size of self.Get() is 2 and the >value of index is 2 and that's why it crashed. > >As I said, this is a no-brainer ap (just a textfield >and nothing else). What's wrong? > > > What's the platform ? Version of wxPython, and of Python ? Do the Pythoncard samples work OK ? How about the wxPython demos ? -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.322 / Virus Database: 267.5.2 - Release Date: 03/06/2005 ------------------------------------------------------- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 _______________________________________________ Pythoncard-users mailing list Pyt...@li... https://lists.sourceforge.net/lists/listinfo/pythoncard-users Ai, please post the whole error message, is _core.py part of the Pythoncard package? I get the feeling it's a part of wxPython. -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences.' |
From: John H. <kim...@ya...> - 2005-06-07 15:25:12
|
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. Thanks again. > I am beginning to wonder if it has to do with the > keyPress event I am trying. This is what I am doing: > > #********* > def on_tfStudy_keyPress(self, event): > keyCode = event.keyCode > if keyCode==13 : > ...some processing code... > else: > event.skip() > #********* > > Without this event, the program doesn't crash. > > Sounds like that's the culprit; dig in with your usual debugging techniques to see where it is. If you want more help - just holler. Liam's request for the whole traceback is also a good idea if you want to send that - but I think you now have it narrowed down to something in the "...some processing code ..." -- |
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 |
From: <kim...@ya...> - 2005-06-07 22:03:52
|
Alex, Your code crashed the same way on my system. As soon as I hit a key at the entry field, the program crashed. Here's the trace back from WingIDE: IndexError: tuple index out of range Traceback (innermost last): File "C:\KeyEvent\KeyEvent.py", line 1, in ? #!/usr/bin/python File "C:\KeyEvent\KeyEvent.py", line 72, in ? app.MainLoop() File "D:\Python23\Lib\site-packages\wx-2.5.4-msw-unicode\wx\_core.py", line 5597, in MainLoop wx.PyApp.MainLoop(self) File "D:\Python23\Lib\site-packages\wx-2.5.4-msw-unicode\wx\_core.py", line 5031, in MainLoop return _core_.PyApp_MainLoop(*args, **kwargs) File "D:\Python23\Lib\site-packages\PythonCard\components\textfield.py", line 342, in _dispatch widget.Widget._dispatch(self, aWxEvent) File "D:\Python23\Lib\site-packages\PythonCard\widget.py", line 365, in _dispatch aWxEvent = eventClassInstance.decorate(aWxEvent, self) File "D:\Python23\Lib\site-packages\PythonCard\event.py", line 341, in decorate aWxEvent.position = tuple(aWxEvent.GetPosition()) File "D:\Python23\Lib\site-packages\wx-2.5.4-msw-unicode\wx\_core.py", line 1043, in __getitem__ Regards, -- John |
From: Alex T. <al...@tw...> - 2005-06-07 23:08:14
|
kim...@ya... wrote: >Alex, > >Your code crashed the same way on my system. As soon >as I hit a key at the entry field, the program >crashed. > > > Well, I'm pretty baffled - so I really hope someone else can chime in with an idea. In the meantime, I'll bash on, hoping I don't ask too many stupid questions or make too many stupid suggestions. Earlier, you said: >"Do the Pythoncard samples work OK ?" > >Yes. > Could you verify that the simpleBrowser sample works properly, including typing a URL into the URL field at the top ? Looking at the code involved in the traceback, I would think tuple should be safe enough - so let's see what it's being called on. Could you change lines 335-341 of PythonCard/event.py from > class KeyEvent(Event): > def decorate(self, aWxEvent, source): > aWxEvent = Event.decorate(self, aWxEvent, source) > > # this is basically the same block as MouseEvent.decorate > # but it seems wrong to have KeyEvent be a subclass of MouseEvent > aWxEvent.position = tuple(aWxEvent.GetPosition()) to class KeyEvent(Event): def decorate(self, aWxEvent, source): aWxEvent = Event.decorate(self, aWxEvent, source) # this is basically the same block as MouseEvent.decorate # but it seems wrong to have KeyEvent be a subclass of MouseEvent mypoint = aWxEvent.GetPosition() print mypoint aWxEvent.position = tuple(mypoint) and see if that tells us anything. If it fails one the aWxEvent.GetPosition() then let's print out the aWxEvent and see what's in it. btw - you said you were using latest download of PythonCard, 0.81 but latest should be 0.82 (I think). Could you possibly run the codeEditor (or resourceEditor) and click on Help/About PythonCard.... and check what it says; my system has PythonCard version: 0.8.2 wxPython version: 2.5.3.1 Python version: 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] Platform: win32 which doesn't make it clear, but it's actually wxPython wx-2.5.3-msw-ansi where you have a unicode version. (shouldn't matter - but it's the biggest difference I've seen in our version so far) Thanks, -- 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 |
From: Bo G. <bo...@sy...> - 2005-06-08 14:47:07
|
Alex Tweedly wrote: > kim...@ya... wrote: > >> Alex, >> >> Your code crashed the same way on my system. As soon >> as I hit a key at the entry field, the program >> crashed. >> >> > Well, I'm pretty baffled - so I really hope someone else can chime in > with an idea. > In the meantime, I'll bash on, hoping I don't ask too many stupid > questions or make too many stupid suggestions. > > I'm running Python 2.4, wxPython 2.5.3, PCard 0.81 and despite best efforts I can't get either keyPress handler to crash. My suggestion, since it requires the least amount of work, would be to try downgrading to wx-2.5.3.x and see what happens. At least rule it out. Bo |
From: <kim...@ya...> - 2005-06-08 17:32:17
|
Okay, Alex, The simpleBrowser example works. May be it doesn't use KeyEvent? I replaced the KeyEvent code in pythoncard\event.py to the code you listed and the program doesn't crash. It's not working like one would expect, however (may be that's your purpose?) When I hit a key, say BACKSPACE, the lower text field becomes "TextArea18"... Incidentally, my KeyEvent doesn't look like the one you listed. It's doing: ## def decorate(self, aWxEvent, source): aWxEvent = Event.decorate(self, aWxEvent, source) # this is basically the same block as MouseEvent.decorate # but it seems wrong to have KeyEvent be a subclass of MouseEvent aWxEvent.position = tuple(aWxEvent.GetPosition()) aWxEvent.x = aWxEvent.GetX() aWxEvent.y = aWxEvent.GetY() aWxEvent.altDown = aWxEvent.AltDown() aWxEvent.controlDown = aWxEvent.ControlDown() aWxEvent.shiftDown = aWxEvent.ShiftDown() aWxEvent.keyCode = aWxEvent.GetKeyCode() return aWxEvent ## From the Help function of the resource editor, I get: PythonCard PythonCard is a GUI construction kit for building cross-platform desktop applications on Windows, Mac OS X, and Linux, using the Python language. PythonCard version: 0.8.1 wxPython version: 2.5.4.1 Python version: 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] Platform: win32 I will look around and see if I can find 0.8.2. Regarding the unicode version, so far the only problem I found is in the multi-column control. It was using "String" as a class type check. The proper check should have been "Strings". Thanks, -----Original Message----- Alex Tweedly wrote: > kim...@ya... wrote: > >> Alex, >> >> Your code crashed the same way on my system. As soon >> as I hit a key at the entry field, the program >> crashed. >> >> > Well, I'm pretty baffled - so I really hope someone else can chime in with an idea. > In the meantime, I'll bash on, hoping I don't ask too many stupid questions or make too many stupid suggestions. > > > Earlier, you said: > >> "Do the Pythoncard samples work OK ?" >> >> Yes. >> > Could you verify that the simpleBrowser sample works properly, including typing a URL into the URL field at the top ? > > Looking at the code involved in the traceback, I would think tuple should be safe enough - so let's see what it's being called on. > Could you change lines 335-341 of PythonCard/event.py from > >> class KeyEvent(Event): >> def decorate(self, aWxEvent, source): >> aWxEvent = Event.decorate(self, aWxEvent, source) >> # this is basically the same block as MouseEvent.decorate >> # but it seems wrong to have KeyEvent be a subclass of MouseEvent >> aWxEvent.position = tuple(aWxEvent.GetPosition()) > > > to > > class KeyEvent(Event): > def decorate(self, aWxEvent, source): > aWxEvent = Event.decorate(self, aWxEvent, source) > # this is basically the same block as MouseEvent.decorate > # but it seems wrong to have KeyEvent be a subclass of MouseEvent > mypoint = aWxEvent.GetPosition() > print mypoint > aWxEvent.position = tuple(mypoint) > > and see if that tells us anything. > If it fails one the aWxEvent.GetPosition() then let's print out the aWxEvent and see what's in it. > > btw - you said you were using latest download of PythonCard, 0.81 but latest should be 0.82 (I think). > Could you possibly run the codeEditor (or resourceEditor) and click on Help/About PythonCard.... and check what it says; my system has > > PythonCard version: 0.8.2 > wxPython version: 2.5.3.1 > Python version: 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] > Platform: win32 > > which doesn't make it clear, but it's actually wxPython wx-2.5.3-msw-ansi where you have a unicode version. > (shouldn't matter - but it's the biggest difference I've seen in our version so far) > > > Thanks, > |
From: Alex T. <al...@tw...> - 2005-06-08 17:54:24
|
kim...@ya... wrote: >Okay, Alex, > >The simpleBrowser example works. May be it doesn't >use KeyEvent? > > > It does (at least, the version I have does). It has def on_fldURL_keyPress(self, event): keyCode = event.keyCode target = event.target if keyCode == 13: self.on_goURL_command(None) else: event.skip() which is why I mentioned typing a URL to it. Check if your sample/simpleBroswer has that too .... >I replaced the KeyEvent code in pythoncard\event.py to >the code you listed and the program doesn't crash. >It's not working like one would expect, however (may >be that's your purpose?) When I hit a key, say >BACKSPACE, the lower text field becomes >"TextArea18"... > > Sounds right - it previously had "TextArea1" in it (from the resource definition), so when you hit BACKSPACE it should: print the "point" to the console window and then execute the keyPress handler, which says def on_TextField1_keyPress(self, event): print event.keyCode self.components.TextArea1.text = self.components.TextArea1.text + "%d\n" % (event.keyCode) i.e. add the decimal value of the keyCode to the end of the text of TextArea1; BACKSPACE is ctrl-H == 8, so this is what I'd expect. Note I didn't do an event.Skip() in on_TextField1_keyPress, so the key would not be passed through the usual processing..... so (tentatively) I think the modified code is giving the right result. >Incidentally, my KeyEvent doesn't look like the one >you listed. It's doing: > >## > def decorate(self, aWxEvent, source): > aWxEvent = Event.decorate(self, aWxEvent, source) > > # this is basically the same block as MouseEvent.decorate > # but it seems wrong to have KeyEvent be a subclass of MouseEvent > aWxEvent.position = tuple(aWxEvent.GetPosition()) > aWxEvent.x = aWxEvent.GetX() > aWxEvent.y = aWxEvent.GetY() > aWxEvent.altDown = aWxEvent.AltDown() > aWxEvent.controlDown = aWxEvent.ControlDown() > aWxEvent.shiftDown = aWxEvent.ShiftDown() > > aWxEvent.keyCode = aWxEvent.GetKeyCode() > return aWxEvent >## > > > > I can't see what's different between that and what I quoted in the original mail Could you change lines 335-341 of PythonCard/event.py from class KeyEvent(Event): def decorate(self, aWxEvent, source): aWxEvent = Event.decorate(self, aWxEvent, source) # this is basically the same block as MouseEvent.decorate # but it seems wrong to have KeyEvent be a subclass of MouseEvent aWxEvent.position = tuple(aWxEvent.GetPosition()) (I only listed lines 335 to 341 - so apart from funny indentation of the comment, it looks the same as what you have). Perhaps just the confusion of line-wrapping in email ? >>From the Help function of the resource editor, I get: > >PythonCard > >PythonCard is a GUI construction kit for building >cross-platform desktop applications on Windows, Mac OS >X, and Linux, using the Python language. > >PythonCard version: 0.8.1 >wxPython version: 2.5.4.1 >Python version: 2.3.5 (#62, Feb 8 2005, 16:23:02) >[MSC v.1200 32 bit (Intel)] >Platform: win32 > >I will look around and see if I can find 0.8.2. > > As I said above - it looks as though it's working for you 0.8.1, so unless you run into a problem, you may be able to stick with 0.8.1 (0.8.2 may be only in CVS) >Regarding the unicode version, so far the only problem >I found is in the multi-column control. It was using >"String" as a class type check. The proper check >should have been "Strings". > > We should make sure we get that fix incorporated - but maybe we'll let it sit until you have another week or two's experience, in case you run into anything else .... -- 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 |
From: <kim...@ya...> - 2005-06-08 17:36:47
|
Sorry, Alex. I changed the wrong file. Let me try the KeyEvent change again....standby -- John |
From: <kim...@ya...> - 2005-06-08 17:49:32
|
Puzzle partially solved. The issue is that there is an genuine problem of: IndexError: tuple index out of range as documented before. However, python.exe doesn't appear to be bothered by it. Since I am doing my development under WingIDE, I am seeing the error. The next question is to what to do about the error. I will hunt down 0.82 and see if it does better. As indicated, my event.py looks different from yours. Regards, -- John |
From: Alex T. <al...@tw...> - 2005-06-08 18:04:49
|
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 |
From: Alex T. <al...@tw...> - 2005-06-03 21:47:24
|
John Henry wrote: <snip - thanks> >"How about the wxPython demos ?" > >I don't see any demo ap in the wxPython directory. > > > Sorry, I forgot - the wxPython demos and docs are now a separate download .... worth getting to see what else is in there. But not needed, since the Pythoncard samples work OK. >I am beginning to wonder if it has to do with the >keyPress event I am trying. This is what I am doing: > >#********* > def on_tfStudy_keyPress(self, event): > keyCode = event.keyCode > if keyCode==13 : > ...some processing code... > else: > event.skip() >#********* > >Without this event, the program doesn't crash. > > Sounds like that's the culprit; dig in with your usual debugging techniques to see where it is. If you want more help - just holler. Liam's request for the whole traceback is also a good idea if you want to send that - but I think you now have it narrowed down to something in the "...some processing code ..." -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.322 / Virus Database: 267.5.2 - Release Date: 03/06/2005 |