Hello,
First time poster to this list.
I know it's a newbie mistake, but I'm having
trouble understanding sizers. I've got an
application that creates a MainWindow which
creates two parts:
···
---------------------------
> >
> >
A | B |
> >
---------------------------
"A" is a wxPanel and "B" is a wxNotebook.
I can get these to display OK. Now, I'm
trying to add labels and buttons in the "A"
panel. In the "Overview" class used for "A",
I create a VERTICAL sizer and add the label
and buttons to it. However, all I ever see
in the "A" panel is the button labeled "Hello2".
It's as if the text label and two buttons are
overlaying each other perhaps. I thought
using a VERTICAL sizer would put them under
each other. I've also tried using a gridsizer
with the same result. Here is the code I'm
using -- please ignore newbie coding practices.
Thanks in advance for any help.
Roggie Boone
----------- MyProg.py (imports GUI below)-----
import wx
import GUI
if __name__ == '__main__':
PCTWIDTH = 0.85
PCTHEIGHT = 0.80
app = wx.App()
screen = wx.GetDisplaySize();
width = int(screen.x * PCTWIDTH)
height = int(screen.y * PCTHEIGHT)
frame = GUI.MainWindow(None, -1, "My Program",
width, height)
print width, height
frame.Show(1)
app.MainLoop()
------
------ GUI.py (imported by main above) ---
------
import wx
from wxPython.wx import *
class MainWindow(wx.Frame):
""" We simply derive a new class of Frame. """
def __init__(self,parent,id, title, width,
height):
wx.Frame.__init__(self,parent,wx.ID_ANY,title,size=(width,height))
self.Sizer = wxBoxSizer(wxHORIZONTAL)
self.CenterOnScreen()
self.CreateStatusBar()
mm = MainMenu()
self.SetMenuBar(mm)
panel = OverviewPanel(self,width,height)
ws = panel.GetClientSize()
nb =
MainNoteBook(self,ws.x,ws.y,width,height)
self.Sizer.Add(panel,0)
self.Sizer.Add(nb,1)
self.Show(True)
class MainMenu(wx.MenuBar):
def __init__(self):
wx.MenuBar.__init__(self)
file = wx.Menu()
about = wx.Menu()
quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q',
"Quit the Application")
file.AppendItem(quit)
self.Append(file, '&File')
self.Append(about,'&About')
class OverviewPanel(wx.Panel):
def __init__(self, parent, width, height):
wx.Panel.__init__(self, parent, -1,
style=wx.RAISED_BORDER)
self.Sizer = wxBoxSizer(wxVERTICAL)
# self.Sizer = wxGridSizer(0,1,0,0)
PCTWIDTH = 0.20
PCTHEIGHT = 1.0
ws = parent.GetClientSize()
self.SetSize((int(ws.x*PCTWIDTH),
int(ws.y*PCTHEIGHT)))
self.SetBackgroundColour(wx.WHITE)
dateLabel = wx.StaticText(self,-1,"Date:")
button = wx.Button(self, -1, "hello")
button2 = wx.Button(self, -1, "hello2")
self.Sizer.Add(dateLabel,0)
self.Sizer.Add(button,0)
self.Sizer.Add(button2,0)
self.SetAutoLayout(true)
class MainNoteBook(wx.Window):
def __init__(self,parent,x,y,width,height):
wx.Window.__init__(self,parent, -1, (x+3,0),
(0,0), 0, "MainNotebook" )
# wx.Window.__init__(self,parent,-1)
nb =
wx.Notebook(self,-1,style=wx.NB_TOP|wx.SIMPLE_BORDER)
PCTWIDTH = 0.80
PCTHEIGHT = 1.0
ws = parent.GetClientSize()
nbPanel = wxPanel(nb,-1)
nbPanel2 = wxPanel(nb,-1)
nbPanel3 = wxPanel(nb,-1)
nbPanel4 = wxPanel(nb,-1)
nb.AddPage(nbPanel,"Test",-1)
nb.AddPage(nbPanel2,"Test2", -1)
nb.AddPage(nbPanel3,"Test3", -1)
nb.AddPage(nbPanel4,"Test4", -1)
nb.SetSize((int(ws.x*PCTWIDTH),
int(ws.y*PCTHEIGHT)))
self.SetSize((int(ws.x*PCTWIDTH),
int(ws.y*PCTHEIGHT)))
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around