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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/eaafc6e9-8832-4f8e-b7d4-03d89011a57c%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

GadgetSteve

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: [hidden email] <[hidden email]> On Behalf Of Barb-Cr33k
Sent: 19 July 2019 01:39
To: wxPython-users <[hidden email]>
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 [hidden email].
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/VI1PR03MB4479F850ED53D0CCEC0921B79BCB0%40VI1PR03MB4479.eurprd03.prod.outlook.com.
Reply | Threaded
Open this post in threaded view
|

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

Barb-Cr33k
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: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="xEjD_dSmCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">wxpytho...@googlegroups.com <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="xEjD_dSmCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">wxpytho...@googlegroups.com> On Behalf Of Barb-Cr33k
Sent: 19 July 2019 01:39
To: wxPython-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="xEjD_dSmCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="xEjD_dSmCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">wxpytho...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/wxpython-users/eaafc6e9-8832-4f8e-b7d4-03d89011a57c%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/wxpython-users/eaafc6e9-8832-4f8e-b7d4-03d89011a57c%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/wxpython-users/eaafc6e9-8832-4f8e-b7d4-03d89011a57c%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/dc5c4dc7-7968-4bd4-95b7-b259a9aa869a%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Barb-Cr33k
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/4243b573-8b7e-4398-9233-1f52d3581d73%40googlegroups.com.

publishers.py (2K) Download Attachment
reportWindow.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Barb-Cr33k
"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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/3ec0524a-c463-44a2-aabd-93f5f4c7b2b4%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Robin Dunn
In reply to this post by Barb-Cr33k

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/53b50744-741d-4dd5-940d-e5618a93deef%40googlegroups.com.