Refreshing window after control addition

Hi all,

I have a wx.SashLayoutWindow into which I add a panel
when an event is generated. However, the panel does
not apear until I resize the application frame. I
tried to call Refresh() on the application frame and
sash window but the panel still does not apear only
after I resize the app frame. What am I mising?

Thanks,
Sorin

···

__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover

Ok, really wanting to get a solid grasp of how all of this is going
together....soo..

I tried to create a notebook class that would take a window as one of
the arguments. My thought being that I could then create windows based
on any set of data, and then pass them to a function that could load
them into a notebook. Sounds ok? But, this doesn't work. I keep
getting an error that's demanding notebook pages have the notebook as
the parent. This happens because my windows are being created early?
This has something to do with the way I'm building them and addressing
the parents. Can someone give me a link or direct me to a place where I
can learn more about the hierarchy of how all this is supposed to go
together?

Stryder

···

-----Original Message-----
From: Sorin C. [mailto:soso_pub@yahoo.com]
Sent: Tuesday, May 11, 2004 1:34 AM
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] Refreshing window after control addition

Hi all,

I have a wx.SashLayoutWindow into which I add a panel
when an event is generated. However, the panel does
not apear until I resize the application frame. I
tried to call Refresh() on the application frame and
sash window but the panel still does not apear only
after I resize the app frame. What am I mising?

Thanks,
Sorin

__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover

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

<reply text snipped>

As I don't see your problem related to mine I believe
you just hijacked my thread. Please be more careful in
the future.
I'll repost my original question:

Hi all,

I have a wx.SashLayoutWindow into which I add a
panel
when an event is generated. However, the panel does
not apear until I resize the application frame. I
tried to call Refresh() on the application frame and
sash window but the panel still does not apear only
after I resize the app frame. What am I mising?

Thanks,
Sorin

···

--- firephreek <firephreek@earthlink.net> wrote:

__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover

I have a program I am working on that has a few wxStaticText control
fields where the label information

will change based on user input. I am having trouble getting them to
resize properly (i.e. if the new label has more

text than the previous label, not all of it is being displayed. If
the label has less text, than the unused space is not being

reused by items below.)

I have written a small test program to try to figure out how my program
should work and I haven’t figured it out yet.

I am trying to get self.label_1 to resize based on when the user hits the
button.

Can someone give me some ideas with this…maybe point me at a web
site?

Here is the test code

#!/usr/bin/env python

generated by wxGlade 0.3.1 on Tue May 11 12:39:38 2004

from wxPython.wx import *

from wxPython.lib.scrolledpanel import wxScrolledPanel

class MyFrame(wxFrame):

def __init__(self, *args, **kwds):

    # begin wxGlade:

MyFrame.init

    kwds["style"] =

wxDEFAULT_FRAME_STYLE

    wxFrame.__init__(self, *args,

**kwds)

    self.status = TRUE

    self.sizer_1 =

wxBoxSizer(wxVERTICAL)

    self.sizer_2 =

wxBoxSizer(wxVERTICAL)

    self.panel_1 =

wxScrolledPanel(self, -1, (-1,-1))

    self.button_1 =

wxButton(self.panel_1, wxID_OK, “button_1”)

    self.label_1 =

wxStaticText(self.panel_1, -1, “The Cat”)

    self.label_2 =

wxStaticText(self.panel_1, -1, “The Dog”)

    EVT_BUTTON(self.panel_1,

wxID_OK, self.OnButton)

    self.__set_properties()

    self.__do_layout()

    # end wxGlade

def __set_properties(self):

    # begin wxGlade:

MyFrame.__set_properties

self.SetTitle(“frame_1”)

    # end wxGlade

def __do_layout(self):

    # begin wxGlade:

MyFrame.__do_layout

    self.sizer_1 =

wxBoxSizer(wxVERTICAL)

    self.sizer_2 =

wxBoxSizer(wxVERTICAL)

self.sizer_2.Add(self.button_1, 1, 0, 0)

    self.sizer_2.Add(self.label_1,

1, wxADJUST_MINSIZE|wxALL, 10)

    self.sizer_2.Add(self.label_2,

1, wxADJUST_MINSIZE|wxALL, 10)

self.panel_1.SetAutoLayout(1)

self.panel_1.SetSizer(self.sizer_2)

self.sizer_2.Fit(self.panel_1)

self.sizer_2.SetSizeHints(self.panel_1)

self.panel_1.SetupScrolling(scroll_x = TRUE)

    self.sizer_1.Add(self.panel_1,

1, wxEXPAND, 0)

    self.SetAutoLayout(1)

self.SetSizer(self.sizer_1)

    self.sizer_1.Fit(self)

self.sizer_1.SetSizeHints(self)

    self.Layout()

    # end wxGlade

def OnButton(self, event):

    if self.status == TRUE :

self.status = FALSE

self.label_1.SetLabel(“The Cat\nate the food\nin the
bowl”)

    else :

self.status = TRUE

self.label_1.SetLabel(“The Cat”)

w,h =

self.label_1.GetSizeTuple()

···

self.sizer_2.SetItemMinSize(self.label_1, w, h)

self.panel_1.Layout()

    self.panel_1.Fit()

self.panel_1.GetAdjustedBestSize()

self.panel_1.Refresh(TRUE)

self.panel_1.SetupScrolling(scroll_x = TRUE)

end of class MyFrame

class MyApp(wxApp):

def OnInit(self):

    wxInitAllImageHandlers()

    frame_1 = MyFrame(None, -1,

“”)

self.SetTopWindow(frame_1)

    frame_1.Show(1)

    return 1

end of class MyApp

if name == “main”:

app = MyApp(0)

app.MainLoop()

Frank,

     self\.sizer\_2\.Fit\(self\.panel\_1\)
     self\.sizer\_1\.Fit\(self\)

Fit this code (or something alike, it's some time ago) in you OnButton handler

--eric

Sorin C. wrote:

Hi all,

I have a wx.SashLayoutWindow into which I add a panel
when an event is generated. However, the panel does
not apear until I resize the application frame. I
tried to call Refresh() on the application frame and
sash window but the panel still does not apear only
after I resize the app frame. What am I mising?

Layout normally happens upon resize events. When you change things and there is not a natural resize event (because the sizes don't change) then you need to help things along. In this case since you are using wx.SashLayoutWindow you need to call one of the wx.LayoutAlgorithm.Layout* methods, something like this:

  wx.LayoutAlgorithm().LayoutWindow(theParentWindow)

···

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

Frank Wilder wrote:

I have a program I am working on that has a few wxStaticText control fields where the label information
will change based on user input. I am having trouble getting them to resize properly (i.e. if the new label has more
text than the previous label, not all of it is being displayed. If the label has less text, than the unused space is not being
reused by items below.)

I have written a small test program to try to figure out how my program should work and I haven't figured it out yet.
I am trying to get self.label_1 to resize based on when the user hits the button.

Can someone give me some ideas with this...maybe point me at a web site?

You need to call Layout to tell the sizers to recalculate positions and sizes.

···

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

Hmmm…this works when you add more text (i.e. make the wxStaticText
larger), but it doesn’t seem to make the field any smaller when you make
the text field smaller.

Frank

···

At 02:27 PM 5/11/2004, you wrote:

Frank,

self.sizer_2.Fit(self.panel_1)

self.sizer_1.Fit(self)

Fit this code (or something alike, it’s some time ago) in you OnButton
handler

–eric