I am facing a problem in my code given below. I have 2 panels Image Panel (that covers 70% frame's width) and control panel (that covers remaining 30% frame's width). I add these panel into the horizontal box sizer but both the panels start from left edge of the frame i.e. they overlap instead of of being adjacent. Please run the code given below to see what exactly happens.
Thanks
Damodar
import wx
import wx.aui
class ParentFrame(wx.aui.AuiMDIParentFrame):
'''
This is main frame
'''
def __init__(self,parent,id,title):
'''
Creates a Parent Frame which has child frames into it.
'''
wx.aui.AuiMDIParentFrame.__init__(self,parent,id,title,
size=(900,700),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
self.SetMinSize((500,500))
self.CreateStatusBar()
class NetworkVisualizationFrame(wx.aui.AuiMDIChildFrame):
'''
This is a child frame
'''
def __init__(self,parent=None,id=-1,title="Network Visualization",image="Default.png"):
'''
Creates a child frame inside parent frame.
'''
wx.aui.AuiMDIChildFrame.__init__(self,parent,id,title)
(w,h) = self.GetSizeTuple()
#==================================================
# Find the aspect ratio of the image
#==================================================
#self.png = wx.Image(image, wx.BITMAP_TYPE_PNG)
#self.imageHeight = self.png.GetHeight()
#self.imageWidth = self.png.GetWidth()
#self.apectRatio = self.imageWidth/self.imageHeight
#=========================================================
# Create an image panel
#=========================================================
self.imagePanelHeight = h
self.imagePanelWidth = int(0.7 * w)
self.imagePanel = wx.Panel(self,id=-1,name="Image Panel",
style=wx.BORDER_THEME,
size=(self.imagePanelWidth,self.imagePanelHeight))
#==========================================================
# Display the .png image in the image panel
#==========================================================
#self.png = self.png.Scale(self.imagePanelWidth,self.imagePanelHeight)
#self.bitmap = self.png.ConvertToBitmap()
#wx.StaticBitmap(self.imagePanel, -1, self.bitmap, (20,20), (wx.CENTRE,wx.CENTRE))
#=========================================================
# Create an control panel
#=========================================================
self.controlPanelHeight = int(h)
self.controlPanelWidth = int(w - self.imagePanelWidth - 5)
self.controlPanel = wx.Panel(self,id=-1,name="Control Panel",
style=wx.BORDER_THEME,
size=(self.controlPanelWidth,self.controlPanelHeight))
#==========================================================
# Show the check boxes in the control panel
#==========================================================
cb1 = wx.CheckBox(self.controlPanel,-1,"Option 1")
cb2 = wx.CheckBox(self.controlPanel,-1,"Option 2")
cb3 = wx.CheckBox(self.controlPanel,-1,"Option 3")
cb4 = wx.CheckBox(self.controlPanel,-1,"Option 4")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.AddSpacer(10,10)
sizer.Add(cb1,1)
sizer.AddSpacer(10,10)
sizer.Add(cb2,1)
sizer.AddSpacer(10,10)
sizer.Add(cb3,1)
sizer.AddSpacer(10,10)
sizer.Add(cb4,1)
sizer.AddSpacer(10,10)
self.controlPanel.SetSizer(sizer)
#==================================================================
# Initialize the box sizer and add the panels into it horizontally
#==================================================================
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.imagePanel,1,wx.GROW)
box.AddSpacer(5,5)
box.Add(self.controlPanel,1,wx.GROW)
self.SetSizer(box)
self.Bind(wx.EVT_SIZE, self.onResize)
def onResize(self,event):
pass
app = wx.PySimpleApp()
parentFrame = ParentFrame(None,-1,"Main Frame")
NetworkVisualizationFrame(parentFrame,-1,"Network Visualization","Artifacts_vs_Elaborations_36855.png")
parentFrame.Show()
app.MainLoop()