wxPython help please?

Thread Solved

Join Date: Jan 2008
Posts: 1
Reputation: dreambreeze is an unknown quantity at this point 
Solved Threads: 0
dreambreeze dreambreeze is offline Offline
Newbie Poster

wxPython help please?

 
0
  #1
Feb 1st, 2008
I'm relatively new to programming in wxPython and I have been trying to put a BoxSizer within a wx.Window. This only results in a small square (which is the panel within the BoxSizer) appearing in the window. Could somebody please tell me what I'm doing wrong?

Sample code:
  
class TestPanel(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, -1, size = (800, 400))
        
        win = wx.Window (self, -1)
        
        box = wx.BoxSizer(wx.VERTICAL)
        panel2 = wx.Panel(win)
        panel2.SetBackgroundColour("Red")
        box.Add(panel2, 1, wx.EXPAND, 10)
        self.SetSizer(box)
Thanks in advance!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,022
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 932
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: wxPython help please?

 
0
  #2
Feb 1st, 2008
Is this what you want ...
  1. import wx
  2.  
  3. class TestPanel(wx.Frame):
  4. def __init__(self, parent, id):
  5. wx.Frame.__init__(self, parent, -1,
  6. 'wx.BoxSizer test', size = (800, 400))
  7.  
  8. #win = wx.Window (self, -1)
  9.  
  10. box = wx.BoxSizer(wx.VERTICAL)
  11. panel1 = wx.Panel(self)
  12. panel1.SetBackgroundColour("green")
  13. # 1=stretch allowed, and use 10 pixel border
  14. box.Add(panel1, 1, wx.ALL|wx.EXPAND, 10)
  15. panel2 = wx.Panel(self)
  16. panel2.SetBackgroundColour("Red")
  17. box.Add(panel2, 1, wx.ALL|wx.EXPAND, 10)
  18. self.SetSizer(box)
  19.  
  20. # show the frame
  21. self.Show(True)
  22.  
  23. app = wx.PySimpleApp()
  24. tp = TestPanel(None, -1)
  25. app.MainLoop()
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC