[wxPython] wxGrid in wxPy 2.3.3

Can somebody test these two shorts applications? Robin?
They are not working ok on my platform.
I informed Vadim Zeiltin about the problems.
(I hope I didn't make a programming error)

···

#####################################################
#####################################################

#-------------------------------------------------------------------
# Grid1.py, wxgrid in a dialog window
#
# win98, python 2.2, wxPython 2.3.3pre2
# wxmsw233h.dll: time stamp 04/05/02 12.57p size 4373553
# file ver 0.0.0.0
# (infos from MS dependency walker)
#
# problems
# - cannot quit a cell in edit mode when hitting the ESC key
# - if cell in edit mode, ENTER pops up a new window!
# - check self.gg.CreateGrid(3, 2) in Dlg: grid is not desplayed
#-------------------------------------------------------------------

from wxPython.wx import *
from wxPython.grid import *

#-------------------------------------------------------------------

class DlgGrid1(wxDialog):
    def __init__(self, parent, id):
        wxDialog.__init__(self, parent, id, "DlgDataGrid1",
                         wxPoint(10, 10), wxSize(500, 400))

        self.gg = wxGrid(self, -1, wxPoint(10, 10), wxSize(400, 300),
wxSIMPLE_BORDER)
        #with the following next line, grid is not desplayed
        #~ self.gg.CreateGrid(3, 2)
        self.gg.CreateGrid(30, 20) #display ok

#-------------------------------------------------------------------

class MyPanel(wxPanel):
    def __init__(self, parent, id):
        wxPanel.__init__(self, parent, id)
        but1 = wxButton(self, 1001, "Grid", wxPoint(20, 20), wxDefaultSize)
        EVT_BUTTON(self, 1001, self.OnClick1)
    def OnClick1(self, event):
        win = DlgGrid1(self, -1)
        ret = win.ShowModal()
        print ret
        ret.Destroy()

#-------------------------------------------------------------------

class MyFrame(wxFrame):
    def __init__(self, parent, id):
        wxFrame.__init__(self, parent, id, "Grid1", wxPoint(10,10),
wxSize(300, 300))
        panel = MyPanel(self, -1)
        EVT_CLOSE(self, self.OnCloseWindow)
    def OnCloseWindow(self, event):
        print 'OnCloseWindow'
        self.Destroy()

#-------------------------------------------------------------------

class MyApp(wxApp):
    def OnInit(self):
        frame = MyFrame(NULL, -1)
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

#-------------------------------------------------------------------

def main():
    print 'main is running...'
    app = MyApp(0)
    app.MainLoop()

#-------------------------------------------------------------------

if __name__ == "__main__" :
    main()

#eof-------------------------------------------------------------------

#####################################################
#####################################################

#-------------------------------------------------------------------
# Grid2.py, wxgrid in a main window
#
# win98, python 2.2, wxPython 2.3.3pre2
# wxmsw233h.dll: time stamp 04/05/02 12.57p size 4373553
# file ver 0.0.0.0
# (infos from MS dependency walker)
#
# problem
# cannot quit a cell in edit mode when hitting the ESC key, ENTER key works
fine
# check self.gg.CreateGrid(3, 2) in MyPanel: grid is not desplayed
#-------------------------------------------------------------------

from wxPython.wx import *
from wxPython.grid import *

#-------------------------------------------------------------------

class MyPanel(wxPanel):
    def __init__(self, parent, id):
        wxPanel.__init__(self, parent, id)
        self.gg = wxGrid(self, -1, wxPoint(10, 10), wxSize(400, 300),
wxSIMPLE_BORDER)
        #with the following next line, grid is not desplayed
        #~ self.gg.CreateGrid(3, 2)
        self.gg.CreateGrid(30, 20)

#-------------------------------------------------------------------

class MyFrame(wxFrame):
    def __init__(self, parent, id):
        wxFrame.__init__(self, parent, id, "Grid2", wxPoint(10, 10),
wxSize(500, 400))
        panel = MyPanel(self, -1)

        EVT_CLOSE(self, self.OnCloseWindow)

    def OnCloseWindow(self, event):
        print 'OnCloseWindow'
        self.Destroy()

#-------------------------------------------------------------------

class MyApp(wxApp):
    def OnInit(self):
        frame = MyFrame(NULL, -1)
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

#-------------------------------------------------------------------

def main():
    print 'main is running...'
    app = MyApp(0)
    app.MainLoop()

#-------------------------------------------------------------------

if __name__ == "__main__" :
    main()

#eof-------------------------------------------------------------------

#####################################################
#####################################################

Jean-Michel Fauth, Switzerland

Can somebody test these two shorts applications? Robin?
They are not working ok on my platform.
I informed Vadim Zeiltin about the problems.
(I hope I didn't make a programming error)

No, what you wrote should work.

#-------------------------------------------------------------------
# Grid1.py, wxgrid in a dialog window
#
# problems
# - cannot quit a cell in edit mode when hitting the ESC key
# - if cell in edit mode, ENTER pops up a new window!

My guess is that the navigation keys are being stolen by the dialog and not
getting to the grid at all. In the case of the enter key, it's looking for
the default button and since there isn't one on the dialog it finds it on
the parent window. (I didn't think that it would go beyond a top-level
window anymore. Maybe that bug has come back...)

# - check self.gg.CreateGrid(3, 2) in Dlg: grid is not desplayed

I don't know what's going on here. I didn't see anything after a quick look
that would cause small grids to have trouble displaying. Please enter a bug
report about this.

#-------------------------------------------------------------------
# Grid2.py, wxgrid in a main window
#
# problem
# cannot quit a cell in edit mode when hitting the ESC key, ENTER key

works

fine

I expect that this is the same problem, that the panel is grabbing the ESC
as a navigation key. If You put the grid directly in the frame with no
panel then it works fine.

Vadim, would any of your recent key-handling changes have side effects like
this? Both of his samples work fine with 2.3.2 as well as with current CVS
on wxGTK.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!