| | |
wxBoxSizer with 2 panels - panel size
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 21
Reputation:
Solved Threads: 2
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
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...
Here is one example:
python Syntax (Toggle Plain Text)
# put two different size panels into a wxBoxSizer import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(250, 70)) panel = wx.Panel(self, -1) panel1 = wx.Panel(panel, -1, size=(50, 30)) panel1.SetBackgroundColour('blue') panel2 = wx.Panel(panel, -1, size=(200, 30)) panel2.SetBackgroundColour('green') box = wx.BoxSizer(wx.VERTICAL) box.Add(panel1, 1) box.Add(panel2, 1) panel.SetSizer(box) self.Centre() class MyApp(wx.App): def OnInit(self): frame = MyFrame(None, -1, 'wxBoxSizer.py') frame.Show(True) return True app = MyApp(0) app.MainLoop()
Last edited by sneekula; Dec 5th, 2007 at 3:40 pm. Reason: size
No one died when Clinton lied.
•
•
Join Date: Nov 2007
Posts: 21
Reputation:
Solved Threads: 2
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?
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...
•
•
Join Date: Nov 2007
Posts: 21
Reputation:
Solved Threads: 2
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:
python Syntax (Toggle Plain Text)
from wxPython.wx import * class APanel(wxPanel): def __init__(self, parent,size,pos): wxPanel.__init__(self,parent,-1,size = size,pos = pos) class MainFrame(wxFrame): def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, size = (500,500)) self.testPanel = self.createTestPanel(self) self.argsPanel = self.createArgsPanel(self) def createTestPanel(self,parent): size = wxSize(250, 100) pos = (0,0) testPanel = APanel(parent,size,pos) testPanel.SetBackgroundColour("GRAY") print "returning panel %s" %testPanel return testPanel def createArgsPanel(self,parent): size = wxSize(250, 300) pos = (0,100) argsPanel = APanel(parent,size,pos) argsPanel.SetBackgroundColour("BLUE") print "returning panel %s" %argsPanel return argsPanel class MyApp(wxApp): def OnInit(self): frame = MainFrame(NULL, -1, "I hate sizers :D") frame.Show(1) return true app = MyApp(0) 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...
Just replace the 1 with a zero in Add() ...
Python Syntax (Toggle Plain Text)
box.Add(panel1, 0) box.Add(panel2, 0)
May 'the Google' be with you!
![]() |
Other Threads in the Python Forum
- Previous Thread: Python 2.4.4, Segmentation fault
- Next Thread: GUI Python - A Guessing Game
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary bluetooth book builtin calculator character code converter countpasswordentry curved customdialog dan08 dictionaries dictionary dynamic examples exe file float format function gnu graphics gui heads homework ideas import inches input java launcher library line lines linux list lists loop mouse mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib






