0

Is it possible to have multiple panel in wxpython? I want to have something like this:

import wx.grid
import sys
class Mat_Frame(wx.Frame):
 def __init__(self,parent):
 wx.Frame.__init__(self,wx.GetApp().TopWindow,title='Material Properties')
 self.panel=wx.Panel(self,-1)
 self.AdderPanel=wx.Panel(self.panel,-1)
 self.InputPanel=wx.Panel(self.panel,-1)
 self.OutputPanel=wx.Panel(self.panel,-1)
 HorSizer=wx.BoxSizer(wx.HORIZONTAL)
 HorSizer.Add(self.panel,proportion=1,flag=wx.EXPAND|wx.ALL)
 HorSizer.Add(self.AdderPanel,proportion=1,flag=wx.EXPAND|wx.ALL)
 HorSizer.Add(self.InputPanel,proportion=1,flag=wx.EXPAND|wx.ALL)
 HorSizer.Add(self.OutputPanel,proportion=1,flag=wx.EXPAND|wx.ALL)

I tried this but it is not working. I mean, I get weird window unsized properly. Am I doing something wrong here? Can somebody point me how to use multiple panels in wxpython?

Person
3891 gold badge3 silver badges16 bronze badges
asked Mar 14, 2012 at 17:00

2 Answers 2

1

You can create as many Panels as you want. You've only created one though, then a series of tuples. You may want this:

self.panel=wx.Panel(self,-1,size=(x,x))
panel1=wx.Panel(self.panel,-1,size=(x,x))
panel2=wx.Panel(self.panel,-1,size=(x,x))

That will actually create several Panels, with the second two being children of the first one. Their layout isn't going to be friendly yet though - you're going to need to look into Sizers.

answered Mar 14, 2012 at 17:07
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for the typo before. I had done what you suggested but the output is not sized properly when I used sizers. Can you please take a look and see me mistake.
1

Sorry, I just realized I had forgotten to set the sizer. It worked fine after that.

answered Mar 14, 2012 at 17:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.