Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wxPython 4.2.1 wxGrid with GridCellChoiceEditor crash at destroy Grid/Frame

Open Knurrdachs opened this issue 2 years ago • 1 comments

Operating system: Win10 Pro wxPython version & source: wxPython 4.2.1, pypi Python version & source: 3.8, python.org

Description of the problem:

I create a wxGrid with a GridCellChoiceEditor. If I open the GridCellChoiceEditor, at the destroy of the Frame/Grid I have the following error:

"any pushed event handlers must have been removed"

I have tried to work around the error using IncRef and DecRef, but this has not led to any success. With wxPython 4.1.1 I have no problems to run the code.

The same Error are by the following Example from wxPython.org:

https://wiki.wxpython.org/GridCellChoiceEditor.

Code Example (click to expand)

# SHORTENED CODE EXAMPLE FROM: https://wiki.wxpython.org/GridCellChoiceEditor
#
#-----------------------------------------------------------------------------
# Name:        GridCombo.py
# Purpose:     Dynamic list updating with a wx.grid.GridCellChoiceEditor
#
# Author:      Thomas M Wetherbee
#
# Created:     2009/04/27
# RCS-ID:      $Id: GridCombo.py $
# Copyright:   (c) 2009
# Licence:     Distributed under the terms of the GNU General Public License
#-----------------------------------------------------------------------------
#!/usr/bin/env python


import wx
import wx.grid

class Frame1(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, id=-1, name='', parent=None,
              pos=wx.Point(100, 100), size=wx.Size(480, 250),
              style=wx.DEFAULT_FRAME_STYLE, title='Spam & Eggs')
        self.SetClientSize(wx.Size(400, 250))

        self.scrolledWindow1 = wx.ScrolledWindow(id=-1,
              name='scrolledWindow1', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(400, 250), style=wx.HSCROLL | wx.VSCROLL)

        self.grid1 = wx.grid.Grid(id=-1, name='grid1',
              parent=self.scrolledWindow1, pos=wx.Point(0, 0),
              size=wx.Size(400, 250), style=0)
        
        self.grid1.CreateGrid(4, 2)

        tChoiceEditor = wx.grid.GridCellChoiceEditor([('spam', 42), ('eggs', 69)], allowOthers=True)

        self.grid1.SetCellEditor(0, 0, tChoiceEditor)
        self.grid1.SetCellEditor(0, 1, tChoiceEditor)
        
        self.grid1.SetCellValue(0, 0, self.grid1.list[0][0])
        self.grid1.SetCellValue(0, 1, self.grid1.list[0][0])        

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Frame1(None)
    frame.Show(True)
    app.MainLoop()

Knurrdachs avatar Sep 13 '23 07:09 Knurrdachs

See here:

https://github.com/wxWidgets/Phoenix/issues/627#issuecomment-354219493

On Wed, 13 Sept 2023 at 09:24, Knurrdachs @.***> wrote:

Operating system: Win10 Pro wxPython version & source: wxPython 4.2.1, pypi Python version & source: 3.8, python.org

Description of the problem:

I create a wxGrid with a GridCellChoiceEditor. If I open the GridCellChoiceEditor, at the destroy of the Frame/Grid I have the following error:

"any pushed event handlers must have been removed"

I have tried to work around the error using IncRef and DecRef, but this has not led to any success. With wxPython 4.1.1 I have no problems to run the code.

The same Error are by the following Example from wxPython.org:

https://wiki.wxpython.org/GridCellChoiceEditor. Code Example (click to expand)

SHORTENED CODE EXAMPLE FROM: https://wiki.wxpython.org/GridCellChoiceEditor##-----------------------------------------------------------------------------# Name: GridCombo.py# Purpose: Dynamic list updating with a wx.grid.GridCellChoiceEditor## Author: Thomas M Wetherbee## Created: 2009/04/27# RCS-ID: $Id: GridCombo.py $# Copyright: (c) 2009# Licence: Distributed under the terms of the GNU General Public License#-----------------------------------------------------------------------------#!/usr/bin/env python

import wximport wx.grid class Frame1(wx.Frame): def init(self, parent): wx.Frame.init(self, id=-1, name='', parent=None, pos=wx.Point(100, 100), size=wx.Size(480, 250), style=wx.DEFAULT_FRAME_STYLE, title='Spam & Eggs') self.SetClientSize(wx.Size(400, 250))

    self.scrolledWindow1 = wx.ScrolledWindow(id=-1,
          name='scrolledWindow1', parent=self, pos=wx.Point(0, 0),
          size=wx.Size(400, 250), style=wx.HSCROLL | wx.VSCROLL)

    self.grid1 = wx.grid.Grid(id=-1, name='grid1',
          parent=self.scrolledWindow1, pos=wx.Point(0, 0),
          size=wx.Size(400, 250), style=0)

    self.grid1.CreateGrid(4, 2)

    tChoiceEditor = wx.grid.GridCellChoiceEditor([('spam', 42), ('eggs', 69)], allowOthers=True)

    self.grid1.SetCellEditor(0, 0, tChoiceEditor)
    self.grid1.SetCellEditor(0, 1, tChoiceEditor)

    self.grid1.SetCellValue(0, 0, self.grid1.list[0][0])
    self.grid1.SetCellValue(0, 1, self.grid1.list[0][0])

if name == 'main': app = wx.PySimpleApp() frame = Frame1(None) frame.Show(True) app.MainLoop()

— Reply to this email directly, view it on GitHub https://github.com/wxWidgets/Phoenix/issues/2458, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACESNIKJMJYWCFC22VK5YF3X2FNSJANCNFSM6AAAAAA4V6LSME . You are receiving this because you are subscribed to this thread.Message ID: @.***>

infinity77 avatar Sep 13 '23 07:09 infinity77