wxPython: When selecting a row on frame1 the same row is selected on frame2

1,303 views
Skip to first unread message

Barb-Cr33k

unread,
Jul 18, 2019, 8:38:59 PM7/18/19
to wxPython-users
Hi,

I have a code that extracts some minimalist data using API and when double-clicking on a cell it opens a new frame with more detailed data about that row. I also select the complete row when a cell is clicked.


My problem is that when I select a row on the second frame it is also selected on the first frame. Also, when I try to select row #10, for example, on the second frame and the first frame contains less rows, the row won't select and I receive an error message saying that the row doesn't exist.


Is there a way to differentiate between the 2 frames? I tried renaming the second frame TestFrame1 but that doesn't change anything.


Here is the code of the first frame, the second one is based on the same template with the only difference TestFrame1 instead of TestFrame. Thank you,


class SimpleGrid(gridlib.Grid): 
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)


        # test all the events
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)

    def openPublishers(self, evt):

        from publishers import TestFrame1
        frame = TestFrame1(self, sys.stdout)
        frame.Show()

    #Select complete row
    def OnSelectCell(self, evt): 
         self.log.write("OnSelectCell: (%d,%d) %s\n" % 
                        (evt.GetRow(), evt.GetCol(), evt.GetPosition())) 
         self.SelectRow(evt.GetRow()) 
         evt.Skip() 

    #open TestFrame1
    def openPublishers(self, evt):

        from publishers import TestFrame1
        frame = TestFrame1(self, sys.stdout)
        frame.Show()

class TestFrame(wx.Frame):
    def __init__(self, parent, log):
        wx.Frame.__init__(self, parent, 0, "Report", size=(1400,800))
        self.grid = SimpleGrid(self, log)


if __name__ == '__main__':
    import sys
    from wx.lib.mixins.inspection import InspectableApp
    app = InspectableApp(False)
    frame = TestFrame(None, sys.stdout)
    frame.Show(True)
    #import wx.lib.inspection
    #wx.lib.inspection.InspectionTool().Show()
    app.MainLoop()

Steve Barnes

unread,
Jul 19, 2019, 2:02:55 AM7/19/19
to wxpytho...@googlegroups.com

I think the problem is that at the end of your select event handler you call event.Skip – this tells the system to carry on trying to find event handlers for your event. Since frame 2 is a child of frame 1 selecting in frame 2 and skipping after the selection results in frame 1 also seeing the click with the row, col values.

 

Gadget Steve

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/eaafc6e9-8832-4f8e-b7d4-03d89011a57c%40googlegroups.com.

Barb-Cr33k

unread,
Jul 19, 2019, 6:53:48 PM7/19/19
to wxPython-users
Thank you, it worked I can now select rows independently on each frame but I still have the problem where I can't select some rows on frame 2. For example, if frame 1 contains 5 rows I can't select rows 6 and + and get this error message: invalid row or column index in wxGridStringTable.

Do you have any idea how to solve this please?

Thank you again,

To unsubscribe from this group and stop receiving emails from it, send an email to wxpytho...@googlegroups.com.

Barb-Cr33k

unread,
Jul 19, 2019, 10:07:06 PM7/19/19
to wxPython-users
Here I've created a minimalist code that is replicating my issue.
Execute reportWindow.py and double-click on any cell and it will open publishers.py. Now, publishers,py contains more rows than reportWindow.py, so if you click on the 4th column and up, it will generate the error I was talking about.

Thank you.
publishers.py
reportWindow.py

Barb-Cr33k

unread,
Jul 19, 2019, 10:12:26 PM7/19/19
to wxPython-users
"so if you click on the 4th column and up" sorry I meant to say 4th row and up

Robin Dunn

unread,
Jul 20, 2019, 1:20:32 AM7/20/19
to wxPython-users
Reply all
Reply to author
Forward
0 new messages