I am very new to wxPython and facing a problem as given below.
I need to have 2 panels horizontaly inside a frame.
As of now I can put 2 panels in the frame using a box sizer. In one panel I have an image displayed and in other panel I have some controls like text ctrl or check box and stuff.
But when I resize the frame, the panels get resized wierdly. As I resize the frame, the image panel becomes smaller and smaller and starts moving towards the left hand corner and ultimately turns into a small dot on the left hand corner.
Please run my code to see what happens when the frame is resized.
I need help regarding this...
Please reply......
Thanks.
Damodar
Here is my code.
import wx
class ImagePanel(wx.Panel):
def __init__(self,parent,id,title,imagePath):
#=========================================================
# Create a panel
#=========================================================
wx.Panel.__init__(self,parent,id,style=wx.BORDER_THEME)
#==========================================================
# Display the .png image in the panel
#==========================================================
png = wx.Image(imagePath, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
wx.StaticBitmap(self, -1, png, (0, 0), (png.GetWidth(),png.GetHeight()))
class ControlPanel(wx.Panel):
def __init__(self,parent,id,title):
#=========================================================
# Create a panel
#=========================================================
wx.Panel.__init__(self,parent,id,size=(200,700),style=wx.BORDER_THEME)
cb1 = wx.CheckBox(self,-1,"Option 1")
cb2 = wx.CheckBox(self,-1,"Option 2")
cb3 = wx.CheckBox(self,-1,"Option 3")
cb4 = wx.CheckBox(self,-1,"Option 4")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.AddSpacer(5,5)
sizer.Add(cb1)
sizer.AddSpacer(5,5)
sizer.Add(cb2)
sizer.AddSpacer(5,5)
sizer.Add(cb3)
sizer.AddSpacer(5,5)
sizer.Add(cb4)
sizer.AddSpacer(5,5)
self.SetSizer(sizer)
#==========================================================
# Shows the text control in the panel
#==========================================================
#wx.TextCtrl(self,-1,"This is a multiline text editor.")
app = wx.PySimpleApp()
frame = wx.Frame(None,-1,"Main Frame",size=(900,700),
style=wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(ImagePanel(frame,1,"Panel A","Artifacts_vs_Elaborations_36855.png"))
box.AddSpacer(5,5)
box.Add(ControlPanel(frame,2,"Panel B"))
frame.SetSizer(box)
frame.Show(1)
app.MainLoop()