Stanfield, Vicki {D167~Indianapolis} wrote:
I am back into the design business, trying to create a gui using wxPython and the picture drawn by my boss. He says, "Divide the space where the top one third or so is the output box and the bottom two thirds is divided vertically in half. Put the correct stuff in each half." He knows even less of how this stuff works than I do. I have written code that creates a box sizer and added a textctrl widget at the top, two radio buttons next, etc, but resizing screws it all up. I will attempt to draw in ascii art what I want it to look like:
[snip beautifull ascii art
I am better at ascii art than at wxPython at this point!
The code I have (which doesn't yet implement the Second set of Radio Buttons is below:
[snip python code]
I am close, but I need the outputbox to be about one third the size of the entire gui space. Also I need to shrink the parameters box to within its side of the gui. Can anyone help me figure this out? I apologize for not posting the actual code, but some aspects are proprietary.
Vicki Stanfield
3S Confidence Meter Project
"A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty."
-- Winston Churchill
Why not use wxGlade to design the window ? Included here is a quick try at the layout you describe (I hope
This will give you an example on how it can be designed. If you wabt to get it fully working you'll have to add event handlers at the proper places (and sprinkle some wxIds)
/Rob
---- example.py --------------
#!/usr/bin/env python
# generated by wxGlade 0.3.3 on Sat Jul 10 08:47:36 2004
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
self.radio_box_1 = wx.RadioBox(self, -1, "radio_box_1", choices=["choice 1", "choice 2"], majorDimension=0, style=wx.RA_SPECIFY_COLS)
self.radio_box_2 = wx.RadioBox(self, -1, "radio_box_2", choices=["choice 1", "choice 2"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
self.label_1 = wx.StaticText(self, -1, "label_1")
self.spin_ctrl_1 = wx.SpinCtrl(self, -1, "", min=0, max=100)
self.label_2 = wx.StaticText(self, -1, "label_2")
self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
self.button_1 = wx.Button(self, -1, "button_1")
self.button_2 = wx.Button(self, -1, "button_2")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.radio_box_1.SetSelection(0)
self.radio_box_2.SetSelection(0)
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_3 = wx.BoxSizer(wx.VERTICAL)
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
sizer_5 = wx.BoxSizer(wx.VERTICAL)
sizer_6 = wx.BoxSizer(wx.VERTICAL)
grid_sizer_1 = wx.FlexGridSizer(2, 2, 0, 0)
sizer_2.Add(self.text_ctrl_1, 1, wx.EXPAND, 0)
sizer_3.Add(self.radio_box_1, 0, wx.EXPAND, 0)
sizer_4.Add(self.radio_box_2, 0, wx.EXPAND, 0)
grid_sizer_1.Add(self.label_1, 0, 0, 0)
grid_sizer_1.Add(self.spin_ctrl_1, 1, wx.EXPAND, 0)
grid_sizer_1.Add(self.label_2, 0, 0, 0)
grid_sizer_1.Add(self.text_ctrl_2, 1, wx.EXPAND, 0)
grid_sizer_1.AddGrowableCol(1)
sizer_5.Add(grid_sizer_1, 0, wx.EXPAND, 0)
sizer_6.Add(self.button_1, 0, wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 3)
sizer_6.Add(self.button_2, 0, wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 2)
sizer_5.Add(sizer_6, 1, wx.EXPAND, 0)
sizer_4.Add(sizer_5, 1, wx.EXPAND, 0)
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0)
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
self.SetAutoLayout(1)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
# end of class MyFrame
------------ example.wxg ----------------
<?xml version="1.0"?>
<!-- generated by wxGlade 0.3.3 on Sat Jul 10 08:48:01 2004 -->
<application path="/home/lobo/download/Source/wxGlade-0.3.3/example.py" name="" class="" option="0" language="python" top_window="" encoding="ANSI_X3.4-1968" use_gettext="0" overwrite="0" use_new_namespace="1">
<object class="MyFrame" name="frame_1" base="EditFrame">
<style>wxDEFAULT_FRAME_STYLE</style>
<title>frame_1</title>
<object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxTextCtrl" name="text_ctrl_1" base="EditTextCtrl">
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>0</option>
<object class="wxRadioBox" name="radio_box_1" base="EditRadioBox">
<style>wxRA_SPECIFY_COLS</style>
<selection>0</selection>
<dimension>0</dimension>
<label>radio_box_1</label>
<choices>
<choice>choice 1</choice>
<choice>choice 2</choice>
</choices>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>0</option>
<object class="wxRadioBox" name="radio_box_2" base="EditRadioBox">
<style>wxRA_SPECIFY_ROWS</style>
<selection>0</selection>
<dimension>0</dimension>
<label>radio_box_2</label>
<choices>
<choice>choice 1</choice>
<choice>choice 2</choice>
</choices>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxBoxSizer" name="sizer_5" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>0</option>
<object class="wxFlexGridSizer" name="grid_sizer_1" base="EditFlexGridSizer">
<hgap>0</hgap>
<rows>2</rows>
<growable_cols>1</growable_cols>
<cols>2</cols>
<vgap>0</vgap>
<object class="sizeritem">
<border>0</border>
<option>0</option>
<object class="wxStaticText" name="label_1" base="EditStaticText">
<attribute>1</attribute>
<label>label_1</label>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxSpinCtrl" name="spin_ctrl_1" base="EditSpinCtrl">
</object>
</object>
<object class="sizeritem">
<border>0</border>
<option>0</option>
<object class="wxStaticText" name="label_2" base="EditStaticText">
<attribute>1</attribute>
<label>label_2</label>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxTextCtrl" name="text_ctrl_2" base="EditTextCtrl">
</object>
</object>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxBoxSizer" name="sizer_6" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL</flag>
<border>3</border>
<option>0</option>
<object class="wxButton" name="button_1" base="EditButton">
<label>button_1</label>
</object>
</object>
<object class="sizeritem">
<flag>wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL</flag>
<border>2</border>
<option>0</option>
<object class="wxButton" name="button_2" base="EditButton">
<label>button_2</label>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</application>