I want to do a interface with wxpython like this I have issues about embeding webview, button, textview and plots in different panels
and when I tried to embed a webview in panel3 it shown like little square on top right of the panel
please help me
import wx
import wx.html2
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title)
hbox = wx.BoxSizer(wx.HORIZONTAL)
panel1 = wx.Panel(self,-1 , pos=(1,1),size=(1600,50), style=wx.SUNKEN_BORDER)
panel2 = wx.Panel(self,-1 , pos=(1,50),size=(1300,500), style=wx.SUNKEN_BORDER)
panel3 = wx.Panel(self,-1 , pos=(1300,50),size=(300,500), style=wx.SUNKEN_BORDER)
panel4 = wx.Panel(self,-1 , pos=(1,550),size=(1600,500), style=wx.SUNKEN_BORDER)
panel1.SetBackgroundColour("BLUE") #buttons in here
panel2.SetBackgroundColour("RED") #plots in here
panel3.SetBackgroundColour("GREY") #webview in here
panel4.SetBackgroundColour("YELLOW") #textview in here
browser = wx.html2.WebView.New(panel3)
browser.LoadURL("http://www.google.com")
hbox.Add(browser,wx.EXPAND)
app = wx.App()
frame = MyFrame(None, -1, "Sizer Test")
frame.Show()
app.MainLoop()
You have defined a
Sizer
but you haven't assigned it, withSetSizer
.I assume, in an attempt to force it to work, you have included postions for the panels. A
Sizer
removes the need to have positions, as theSizer
/Sizers
perform that task for you.If we remove the positions, assign some rational sizes and apply the
Sizers
, we get this.It may not be what you are striving for but it's a starting point.