User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,760 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 797 | Replies: 4
Reply
Join Date: Nov 2007
Location: Ireland
Posts: 21
Reputation: LarZ is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
LarZ LarZ is offline Offline
Newbie Poster

wxBoxSizer with 2 panels - panel size

  #1  
Dec 4th, 2007
Can anyone point me in the direction of a small app that displays 2 panels on a frame, where one panel is small and at the top taking up about 20% of the frame, and the other panel takes up 80%.

I would like it to be possible using wxBoxSizer but if anyone can show me any other way in wx then that's grand.

LarZ
if this were a computer game i'd be googling a patch right now...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Posts: 1,669
Reputation: sneekula is on a distinguished road 
Rep Power: 6
Solved Threads: 47
sneekula's Avatar
sneekula sneekula is offline Offline
Posting Virtuoso

Re: wxBoxSizer with 2 panels - panel size

  #2  
Dec 5th, 2007
Here is one example:
  1. # put two different size panels into a wxBoxSizer
  2.  
  3. import wx
  4.  
  5. class MyFrame(wx.Frame):
  6. def __init__(self, parent, id, title):
  7. wx.Frame.__init__(self, parent, id, title, size=(250, 70))
  8. panel = wx.Panel(self, -1)
  9. panel1 = wx.Panel(panel, -1, size=(50, 30))
  10. panel1.SetBackgroundColour('blue')
  11. panel2 = wx.Panel(panel, -1, size=(200, 30))
  12. panel2.SetBackgroundColour('green')
  13. box = wx.BoxSizer(wx.VERTICAL)
  14. box.Add(panel1, 1)
  15. box.Add(panel2, 1)
  16. panel.SetSizer(box)
  17. self.Centre()
  18.  
  19. class MyApp(wx.App):
  20. def OnInit(self):
  21. frame = MyFrame(None, -1, 'wxBoxSizer.py')
  22. frame.Show(True)
  23. return True
  24.  
  25. app = MyApp(0)
  26. app.MainLoop()
Last edited by sneekula : Dec 5th, 2007 at 3:40 pm. Reason: size
No one died when Clinton lied.
Reply With Quote  
Join Date: Nov 2007
Location: Ireland
Posts: 21
Reputation: LarZ is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
LarZ LarZ is offline Offline
Newbie Poster

Re: wxBoxSizer with 2 panels - panel size

  #3  
Dec 6th, 2007
Thanks a lot, but the panels are still resizing when the frame gets resized, so they're not of a fixed size.

I don't want each panel taking up half of the overall height of the panel/frame in which it is contained. I want at least the top one to stay the same size at all times....

anyone have any ideas?
if this were a computer game i'd be googling a patch right now...
Reply With Quote  
Join Date: Nov 2007
Location: Ireland
Posts: 21
Reputation: LarZ is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
LarZ LarZ is offline Offline
Newbie Poster

Re: wxBoxSizer with 2 panels - panel size

  #4  
Dec 7th, 2007
yeah i decided to ditch the boxsizer, as it has a mind of its own at the best of times... I'm just throwing in the position of the frames and the size as follows:

  1. from wxPython.wx import *
  2.  
  3. class APanel(wxPanel):
  4. def __init__(self, parent,size,pos):
  5. wxPanel.__init__(self,parent,-1,size = size,pos = pos)
  6.  
  7. class MainFrame(wxFrame):
  8. def __init__(self, parent, ID, title):
  9. wxFrame.__init__(self, parent, ID, title, size = (500,500))
  10. self.testPanel = self.createTestPanel(self)
  11. self.argsPanel = self.createArgsPanel(self)
  12.  
  13. def createTestPanel(self,parent):
  14. size = wxSize(250, 100)
  15. pos = (0,0)
  16. testPanel = APanel(parent,size,pos)
  17. testPanel.SetBackgroundColour("GRAY")
  18. print "returning panel %s" %testPanel
  19. return testPanel
  20.  
  21. def createArgsPanel(self,parent):
  22. size = wxSize(250, 300)
  23. pos = (0,100)
  24. argsPanel = APanel(parent,size,pos)
  25. argsPanel.SetBackgroundColour("BLUE")
  26. print "returning panel %s" %argsPanel
  27. return argsPanel
  28.  
  29. class MyApp(wxApp):
  30. def OnInit(self):
  31. frame = MainFrame(NULL, -1, "I hate sizers :D")
  32. frame.Show(1)
  33. return true
  34.  
  35. app = MyApp(0)
  36. app.MainLoop()
Last edited by LarZ : Dec 7th, 2007 at 10:20 am. Reason: Better Example
if this were a computer game i'd be googling a patch right now...
Reply With Quote  
Join Date: Oct 2004
Posts: 2,529
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 177
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: wxBoxSizer with 2 panels - panel size

  #5  
Dec 7th, 2007
Just replace the 1 with a zero in Add() ...
        box.Add(panel1, 0)
        box.Add(panel2, 0)
May 'the Google' be with you!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Python Forum

All times are GMT -4. The time now is 9:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC