From: Nick L. <ni...@ja...> - 2004-09-19 17:10:41
|
Hi folks, Im sure this must be in the documentation somewhere, but Im afraid I can't find it. Also I've searched the archives and I can't find it there either. Could someone please tell me how to capture when <return> is pressed on a keyboard ? I know this much : def on_ipInput_keyPress(self, event): print "key pressed %s" %event which outputs something like : you pressed <wx._core.KeyEvent; proxy of C++ wxKeyEvent instance at _0cf41200_p_wxKeyEvent> But I don't know how to specifically capture the <return> key. I apologise in advance for this post, as Im sure that this must be documented somewhere, I simply cannot find where. Any pointers to the relevant documentation greatfully received. Many thanks Nick. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004 |
From: Kevin A. <al...@se...> - 2004-09-19 17:22:57
|
On Sep 19, 2004, at 10:14 AM, Nick Lunt wrote: > Hi folks, > > Im sure this must be in the documentation somewhere, but Im afraid I > can't > find it. > Also I've searched the archives and I can't find it there either. > > Could someone please tell me how to capture when <return> is pressed > on a > keyboard ? > > I know this much : > > def on_ipInput_keyPress(self, event): > print "key pressed %s" %event > > which outputs something like : > > you pressed <wx._core.KeyEvent; proxy of C++ wxKeyEvent instance at > _0cf41200_p_wxKeyEvent> > > But I don't know how to specifically capture the <return> key. > > I apologise in advance for this post, as Im sure that this must be > documented somewhere, I simply cannot find where. Any pointers to the > relevant documentation greatfully received. > > Many thanks > Nick. If you use dir() on the event you'll see all the methods and attributes including the base wxPython ones. In this case, PythonCard "decorates" the event instance with some helper attributes so you don't have to use the methods. keyCode has what you're looking for. Return is ASCII 13, so... def on_ipinput_keyPress(self, event): print dir(event) if event.keyCode == 13: print "return" else: event.skip() If you want the field to get the return key, then you'll need to insert it yourself or call event.skip() in addition to whatever other processing you were planning on. And no, the event attributes are not documented very well, but they are used in quite a few of the samples and tools. You can take a look at event.py to see the basic "decoration" done for all events, mouse events, key events, etc. For component specific attributes, look at the individual component files. ka |
From: Nick L. <ni...@ja...> - 2004-09-19 17:27:22
|
Many thanks for the quick response, that has helped tremendously. I'll also go through the examples. Thanks again, Nick. -----Original Message----- From: Kevin Altis [mailto:al...@se...] Sent: 19 September 2004 18:23 To: Nick Lunt Cc: PythonCard Subject: Re: [Pythoncard-users] Capture <return> On Sep 19, 2004, at 10:14 AM, Nick Lunt wrote: > Hi folks, > > Im sure this must be in the documentation somewhere, but Im afraid I > can't > find it. > Also I've searched the archives and I can't find it there either. > > Could someone please tell me how to capture when <return> is pressed > on a > keyboard ? > > I know this much : > > def on_ipInput_keyPress(self, event): > print "key pressed %s" %event > > which outputs something like : > > you pressed <wx._core.KeyEvent; proxy of C++ wxKeyEvent instance at > _0cf41200_p_wxKeyEvent> > > But I don't know how to specifically capture the <return> key. > > I apologise in advance for this post, as Im sure that this must be > documented somewhere, I simply cannot find where. Any pointers to the > relevant documentation greatfully received. > > Many thanks > Nick. If you use dir() on the event you'll see all the methods and attributes including the base wxPython ones. In this case, PythonCard "decorates" the event instance with some helper attributes so you don't have to use the methods. keyCode has what you're looking for. Return is ASCII 13, so... def on_ipinput_keyPress(self, event): print dir(event) if event.keyCode == 13: print "return" else: event.skip() If you want the field to get the return key, then you'll need to insert it yourself or call event.skip() in addition to whatever other processing you were planning on. And no, the event attributes are not documented very well, but they are used in quite a few of the samples and tools. You can take a look at event.py to see the basic "decoration" done for all events, mouse events, key events, etc. For component specific attributes, look at the individual component files. ka --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004 |
From: Kevin A. <al...@se...> - 2004-09-19 17:36:56
|
On Sep 19, 2004, at 10:31 AM, Nick Lunt wrote: > Many thanks for the quick response, that has helped tremendously. > > I'll also go through the examples. > I should have specified that the simple way to find examples is to use the findfiles tool. For example, to find keyPress handlers, you might use: Search for: on_.*keyPress Directories: location of your copy of PythonCard here, perhaps limited to the samples or tools dirs File types: *.py;*.pyw with both Case sensitive and Search subdirectories checked. You can double-click on one of the lines found and it will open the file up with the codeEditor and jump to that line in the source. Searching for keyCode == would be another way to find examples, but the former assumes you didn't already know the attribute. ka |
From: Nick L. <ni...@ja...> - 2004-09-19 18:31:38
|
Well with the help you've given I've managed to get my first PythonCard app running succesfully :) Many, many thanks, Nick. -----Original Message----- From: Kevin Altis [mailto:al...@se...] Sent: 19 September 2004 18:37 To: Nick Lunt Cc: PythonCard Subject: Re: [Pythoncard-users] Capture <return> On Sep 19, 2004, at 10:31 AM, Nick Lunt wrote: > Many thanks for the quick response, that has helped tremendously. > > I'll also go through the examples. > I should have specified that the simple way to find examples is to use the findfiles tool. For example, to find keyPress handlers, you might use: Search for: on_.*keyPress Directories: location of your copy of PythonCard here, perhaps limited to the samples or tools dirs File types: *.py;*.pyw with both Case sensitive and Search subdirectories checked. You can double-click on one of the lines found and it will open the file up with the codeEditor and jump to that line in the source. Searching for keyCode == would be another way to find examples, but the former assumes you didn't already know the attribute. ka --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004 |