Hi,
In the code below, I have an horizontal box with two pannels ... can someone
tell me why the pannels are one above the other (i.e, the green pannel
hides the blue)?
Thanks,
#!/bin/env python
# -*- coding: iso-8859-15 -*-
···
#----------------------------------------------------------------------------
# Name: SCIDE.py
# Author: XXXX
# Created: XX/XX/XX
# Copyright:
#----------------------------------------------------------------------------
import wx
#from SCIDE_wdr import *
ID_MENU = 10002
def MyMenuBarFunc():
item0 = wx.MenuBar()
item1 = wx.Menu()
item1.Append( wx.ID_ABOUT, "About", "" )
item1.Append( wx.ID_EXIT, "Quit", "" )
item0.Append( item1, "File" )
return item0
# Toolbar functions
def MyToolBarFunc( parent ):
parent.SetMargins( [2,2] )
parent.Realize()
# WDR: classes
ID_PANEL_SHELL = 1000
ID_PANEL_CODE = 1001
class MySCIDEFrame(wx.Frame):
def __init__(self, parent, id, title,
pos = wx.DefaultPosition, size = wx.DefaultSize,
style = wx.DEFAULT_FRAME_STYLE ):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.CreateMyMenuBar()
self.CreateMyToolBar()
self.CreateStatusBar(1)
self.SetStatusText("Welcome!")
# insert main window here
#MySCIDEDialogFunc(self, False, False)
item0 = wx.BoxSizer( wx.HORIZONTAL )
item1 = wx.Panel( self, ID_PANEL_SHELL, wx.DefaultPosition, [200,160],
0 )
item1.SetBackgroundColour( wx.BLUE )
item0.Add( item1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
item2 = wx.Panel( self, ID_PANEL_CODE, wx.DefaultPosition, [200,160],
0 )
item2.SetBackgroundColour( wx.GREEN )
item0.Add( item2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
self.SetSizer( item0 )
item0.SetSizeHints( self )
# WDR: handler declarations for MySCIDEFrame
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout)
wx.EVT_MENU(self, wx.ID_EXIT, self.OnQuit)
wx.EVT_CLOSE(self, self.OnCloseWindow)
wx.EVT_SIZE(self, self.OnPanel1Size)
# WDR: methods for MySCIDEFrame
def CreateMyMenuBar(self):
self.SetMenuBar( MyMenuBarFunc() )
def CreateMyToolBar(self):
tb = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER)
MyToolBarFunc( tb )
# WDR: handler implementations for MySCIDEFrame
def OnAbout(self, event):
dialog = wx.MessageDialog(self, "Welcome to SuperApp 1.0\n(C)opyright
Joe Hacker",
"About SuperApp", wx.OK|wx.ICON_INFORMATION )
dialog.CentreOnParent()
dialog.ShowModal()
dialog.Destroy()
def OnQuit(self, event):
self.Close(True)
def OnCloseWindow(self, event):
self.Destroy()
def OnPanel1Size(self, event):
print 'CALLED'
l_frame_size = event.GetSize()
l_fs_1 = (l_frame_size[0] / 2, l_frame_size[1] / 2,)
l_fs_2 = (l_frame_size[0] / 2, l_frame_size[1] / 2,)
# Resize the top level panel
self.GetCodePanel().SetSize(l_fs_1)
self.GetShellPanel().SetSize(l_fs_2)
def GetCodePanel(self):
return self.FindWindowById( ID_PANEL_CODE )
def GetShellPanel(self):
return self.FindWindowById( ID_PANEL_SHELL)
#----------------------------------------------------------------------------
class MySCIDEApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
frame = MySCIDEFrame( None, -1, "SuperApp", [20,20], [500,340] )
frame.Show(True)
return True
#----------------------------------------------------------------------------
app = MySCIDEApp(False)
app.MainLoop()
--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________