faqts : Computers : Programming : Languages : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 17 people (59%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How to put wxGrid into wxPanel?

Jul 5th, 2000 10:03
Nathan Wallace, Hans Nowak, Snippet 324, Bernhard Reiter


"""
Packages: gui.wxpython
"""
"""
>my code can't put wxGrid into wxPanel properly.
>but i can put others, such as button,textctrl,listbox, 
>into wxPanel properly (i can manage it)
> i have a problem to put wxGrid into wxPanel. the following is my code
Which version of wxPython are you using?
(I think I have 2.1b2 here, which is a bit old.)
And for me it works after giving the grid a default size:
"""
from wxPython.wx import *
class MyFrame(wxFrame):
    def __init__(self,parent,id,title):
        wxFrame.__init__(self,parent,id,title,wxPoint(-1,-1),wxSize(300,200))
        panel = wxPanel(self,-1)
        grid  = wxGrid(panel,-1,wxPoint(10,10),wxSize(250,180))
        grid.CreateGrid(5,5)
class MyApp(wxApp):
        def OnInit(self):
                frame = MyFrame(NULL,-1,"wxPanel & wxGrid")
                frame.Show(true)
                self.SetTopWindow(frame)
                return true
app = MyApp(0)
app.MainLoop()