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

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()
···

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-users+unsubscribe@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.

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

On Behalf Of Barb-Cr33k

···

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()

--
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-users+unsubscribe@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](https://groups.google.com/d/msgid/wxpython-users/eaafc6e9-8832-4f8e-b7d4-03d89011a57c%40googlegroups.com?utm_medium=email&utm_source=footer).

</details>

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,

···

On Friday, 19 July 2019 02:02:55 UTC-4, Gadget Steve wrote:

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

From: wxpytho...@googlegroups.com wxpytho...@googlegroups.com
On Behalf Of Barb-Cr33k
Sent: 19 July 2019 01:39
To: wxPython-users wxpytho...@googlegroups.com
Subject: [wxPython-users] wxPython: When selecting a row on frame1 the same row is selected on frame2

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()


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
wxpytho...@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
.

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-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/dc5c4dc7-7968-4bd4-95b7-b259a9aa869a%40googlegroups.com.

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 (1.97 KB)

reportWindow.py (2.22 KB)

···

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-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/4243b573-8b7e-4398-9233-1f52d3581d73%40googlegroups.com.

“so if you click on the 4th column and up” sorry I meant to say 4th row and up

···

On Friday, 19 July 2019 22:07:06 UTC-4, Barb-Cr33k wrote:

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.

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-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/3ec0524a-c463-44a2-aabd-93f5f4c7b2b4%40googlegroups.com.

Answered here: https://discuss.wxpython.org/t/wxpython-when-selecting-a-row-on-frame1-the-same-row-is-selected-on-frame2/33008

···

Robin

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-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/53b50744-741d-4dd5-940d-e5618a93deef%40googlegroups.com.