From: Aaron H. <arc...@gm...> - 2004-12-22 17:32:56
|
Anybody... I have an app I'm developing using PythonCard. On my form, I have a grid that I'd like to allow the user to select a row and delete it. I thought I'd just capture a keyPress event and delete the row when the user presses a certain key...but I can't capture a keyPress event on a grid. I get the showEditor and hideEditor events. And I see from simpleGrid.py that there's a event.GetControl() to return the text edit control but how then do I capture a keyPress event on it? The way I envision this working is the user clicks on row label(s) to rangeSelect, then presses the Delete key to delete the row(s). But I can't figure out how to capture the keyPress on the grid. Alternatively, I would like to create a context menu so the user can select the row, then right click to have a menu pop up with a delete option. Can anybody point me towards some information that will help me accomplish either method? -Aaron |
From: Aaron H. <arc...@gm...> - 2004-12-23 17:46:36
|
On Wed, 2004-12-22 at 12:34 -0500, Aaron Howard wrote: > Alternatively, I would like to create a context menu so the user can > select the row, then right click to have a menu pop up with a delete > option. > FWIW, I have this part working now. I found some example code which got me going in the right direction. I'd still like to capture a delete key press when a row is selected to trigger the deletion that way. -Aaron |
From: Ruben M. <rmc...@ya...> - 2004-12-28 15:58:12
|
This is more a Python question than a PythonCard question, but out of curiosity I did a quick search on Comp.Lang.Python and found a possible solution: http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f719f4199542b53f/26b0f980d3e12c4a?q=capture+key+press&_done=%2Fgroup%2Fcomp.lang.python%2Fsearch%3Fgroup%3Dcomp.lang.python%26q%3Dcapture+key+press%26qt_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d#26b0f980d3e12c4a I haven't tested it. Hope it helps. -Ruben --- Aaron Howard <arc...@gm...> wrote: > On Wed, 2004-12-22 at 12:34 -0500, Aaron Howard > wrote: > > Alternatively, I would like to create a context > menu so the user can > > select the row, then right click to have a menu > pop up with a delete > > option. > > > > FWIW, I have this part working now. I found some > example code which got > me going in the right direction. I'd still like to > capture a delete key > press when a row is selected to trigger the deletion > that way. > > -Aaron > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT > Products from real users. > Discover which products truly live up to the hype. > Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo |
From: Alex T. <al...@tw...> - 2004-12-28 17:27:31
|
Ruben Marquez wrote: >This is more a Python question than a PythonCard >question, but out of curiosity I did a quick search on >Comp.Lang.Python and found a possible solution: > >http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f719f4199542b53f/26b0f980d3e12c4a?q=capture+key+press&_done=%2Fgroup%2Fcomp.lang.python%2Fsearch%3Fgroup%3Dcomp.lang.python%26q%3Dcapture+key+press%26qt_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d#26b0f980d3e12c4a > >I haven't tested it. Hope it helps. > > No, it really is a PythonCard question. The thread you found is about console IO (or rather, standard input) for non-GUI applications. Detecting and handling input (such as "key" events) within wxPython (and PythonCard) is completely different. I believe the KEY events aren't handled for a grid component, so you need to do it directly in wxPython. As a simple example, I added the following at the end of on_initialize in the simplegrid.py sample that came with PythonCard. ## try binding key_down mygrid.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) def OnKeyDown(self, evt): if evt.KeyCode() == wx.WXK_DELETE: print "Delete was pressed" evt.Skip() return and it does properly detect "delete" when pressed after selecting a row/column (and doesn't detect it when the delete is pressed within a cell editor). You can find some more examples in the wxPython Demo samples if you need it ... -- Alex. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 22/12/2004 |
From: Ruben M. <rmc...@ya...> - 2004-12-28 22:18:23
|
I stand corrected. Thank you for the clear explanation Alex. -Ruben --- Alex Tweedly <al...@tw...> wrote: > Ruben Marquez wrote: > > >This is more a Python question than a PythonCard > >question, but out of curiosity I did a quick search > on > >Comp.Lang.Python and found a possible solution: > > > >http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f719f4199542b53f/26b0f980d3e12c4a?q=capture+key+press&_done=%2Fgroup%2Fcomp.lang.python%2Fsearch%3Fgroup%3Dcomp.lang.python%26q%3Dcapture+key+press%26qt_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d#26b0f980d3e12c4a > > > >I haven't tested it. Hope it helps. > > > > > No, it really is a PythonCard question. > > The thread you found is about console IO (or rather, > standard input) for > non-GUI applications. Detecting and handling input > (such as "key" > events) within wxPython (and PythonCard) is > completely different. > > I believe the KEY events aren't handled for a grid > component, so you > need to do it directly in wxPython. As a simple > example, I added the > following at the end of on_initialize in the > simplegrid.py sample that > came with PythonCard. > > > ## try binding key_down > mygrid.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) > > def OnKeyDown(self, evt): > if evt.KeyCode() == wx.WXK_DELETE: > print "Delete was pressed" > evt.Skip() > return > > and it does properly detect "delete" when pressed > after selecting a > row/column (and doesn't detect it when the delete > is pressed within a > cell editor). > > You can find some more examples in the wxPython Demo > samples if you need > it ... > > -- Alex. > > > -- > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.298 / Virus Database: 265.6.4 - Release > Date: 22/12/2004 > > __________________________________ Do you Yahoo!? Send a seasonal email greeting and help others. Do good. http://celebrity.mail.yahoo.com |