Question about frame/panel

It seams that once a wxPanel is placed in a wxFrame and
self.SetAutoLayout(True), the wxFrame is formatted forever. If I destroy
the wxPanel and put something else in the wxFrame, it pukes. This leads me
to the conclusion that once a framescontense are layed out, their is no
going back.

Am I right about this?

If so, then the only way of creating a dynamic updated screen is by using
self aware controls. It would also be impossible to change the controls
themselves, i.e. remove or add a wxStaticText control.

Henry Grantham wrote:

It seams that once a wxPanel is placed in a wxFrame and
self.SetAutoLayout(True), the wxFrame is formatted forever. If I destroy
the wxPanel and put something else in the wxFrame, it pukes. This leads me
to the conclusion that once a framescontense are layed out, their is no
going back.
Am I right about this?

No. This should be possible. Post a small sample, and we'll see if we can figure out what's wrong.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

I think that I figured out how to do it now, but how do I start over when
organizing the frame. The new sizers do nothing now.

import sys, os
from wxPython.wx import *

class myPanel(wxPanel):
    def __init__(self, parent, text,
                name='No Name'):
        "Instantiate a new NamedPanel with the given name."
        wxPanel.__init__(self, parent, -1, size=(150, 150))
        
        self.text = text
      
        #text values for customer and domestic partner name and dates
        outerbox = wxBoxSizer(wxVERTICAL)

        #customer
        self.textcontrol = wxStaticText(self, -1, text)
        outerbox.Add(self.textcontrol, 0, wxALIGN_CENTRE|wxALL, 5)
  
        self.SetSizer(outerbox)
        self.SetAutoLayout(True)
        outerbox.Fit(self)
        
class myFrame(wxFrame):
    def __init__(self, parent, ID, title, text,
                 pos=wxDefaultPosition, size=wxDefaultSize,
                 style=wxDEFAULT_DIALOG_STYLE):
            
        wxFrame.__init__(self, parent, ID, title, pos, size=(150, 150))
        
        self.text = text
        outerbox = wxBoxSizer(wxVERTICAL)
        
        # Property Value:
        box = wxBoxSizer(wxHORIZONTAL)
        self.panel = myPanel(self, text)
        self.panel.SetBackgroundColour(wxColour(100, 100, 100))
        box.Add(self.panel, 0, wxALIGN_CENTRE|wxALL, 5)
        
        outerbox.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
        
        box = wxBoxSizer(wxHORIZONTAL)

        if wxPlatform != "__WXMSW__":
            btn = wxContextHelpButton(self)
            box.Add(btn, 1, wxALIGN_BOTTOM|wxALL, 5)

        #update button
        self.btn = wxButton(self, 5, "Update")
        self.btn.SetDefault()
        box.Add(self.btn, 1, wxALIGN_BOTTOM|wxALL, 2)
        EVT_BUTTON(self, 5, self.OnClick)
            
        outerbox.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)

        self.SetSizer(outerbox)
        self.SetAutoLayout(True)
    
    def OnClick(self,event):
        id = event.GetId()
        if id == 5:
            self.panel.Destroy()
            
            outerbox = wxBoxSizer(wxVERTICAL)
            box = wxBoxSizer(wxHORIZONTAL)
            self.panel = myPanel(self, "New Text")
            self.panel.SetBackgroundColour(wxColour(100, 100, 100))
            box.Add(self.panel, 0, wxALIGN_CENTRE|wxALL, 5)
            outerbox.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
            box = wxBoxSizer(wxHORIZONTAL)
            box.Add(self.btn, 1, wxALIGN_BOTTOM|wxALL, 2)
            outerbox.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
            
            self.SetSizer(outerbox)
            self.SetAutoLayout(True)
            
            print "update"
            
if __name__ == '__main__':
    app = wxPySimpleApp()
    text = "Text in a panel"
    win = myFrame(None, -1, "Frame", text,
                    size = (300,300))
    win.CenterOnScreen()

    win.Show(True)
    app.MainLoop()

···

-----Original Message-----
From: Chris Barker [mailto:Chris.Barker@noaa.gov]
Sent: Monday, December 22, 2003 10:35 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Question about frame/panel

Henry Grantham wrote:

It seams that once a wxPanel is placed in a wxFrame and
self.SetAutoLayout(True), the wxFrame is formatted forever. If I
destroy the wxPanel and put something else in the wxFrame, it pukes.
This leads me to the conclusion that once a framescontense are layed
out, their is no going back.

Am I right about this?

No. This should be possible. Post a small sample, and we'll see if we can
figure out what's wrong.

-Chris

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Henry Grantham wrote:

I think that I figured out how to do it now, but how do I start over when
organizing the frame. The new sizers do nothing now.

Sizers are invoked to do layout when the window they are attached to gets a size event. Since the frame does not change size when you recreate everything then the first new layout does not happen automatically. If you call self.Layout() then it will be done.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!