How to put wxGrid into wxPanel ?

Bernhard Reiter bernhard at alpha1.csd.uwm.edu
Thu Nov 18 13:07:59 EST 1999


On Thu, 18 Nov 1999 14:32:51 GMT, Ahmad Munif <muniff at yahoo.com> wrote:
> 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()



>from wxPython.wx import *
>class MyFrame(wxFrame):
>	def __init__(self,parent,id,title):
>		wxFrame.__init__(self,parent,id,title,size=(300,200))
>		panel = wxPanel(self,-1)
>		grid  = wxGrid(panel,-1)
>		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()
>
>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)

Your parent seems to be fine.
You should have givin us the error message you get.
	Bernhard

-- 
Research Assistant, Geog Dept UM-Milwaukee, USA.  (www.uwm.edu/~bernhard)
Free Software Projects and Consulting 		         (intevation.net)  
Association for a Free Informational Infrastructure            (ffii.org)




More information about the Python-list mailing list