Problem with label centering and asyncron updates of wx.Dialogs

Hello,

Ive got a dialog with a StaticText label, which is correctly centered inside
the parent boxsizer during dialog creation. Attached to the dialog is also
an "asyncron" method which updates this label depending on an external
hotplugging event.

The dialog looks exactly the way I want it to before the asyncron method kicks
in and updates the label with a SetLabel() call on the label instance. This
call causes the label to not be centered anymore, and I've tried just about
anything to get it to center again, including

label instance: SetWindowStyle(wx.ALIGN_CENTRE), SetInitialSize(), Refresh(),
Update()
dialog instance: Refresh(), Update()

But to no avail. The only thing which actually works, is:

size=dialog.GetSize()
dialog.SetSize(size[0]+1, size[1]+1)

This will cause the entire dialog to be resized and the label to be centered
again, but the solution is non-optimal for several reasons :slight_smile: (Setting the
size to the same as GetSize returns does not work)

Now the question is - how do I do this "the proper way" ?

Best regards,
Frank

Hi Frank,

Ive got a dialog with a StaticText label, which is correctly centered inside
the parent boxsizer during dialog creation. Attached to the dialog is also
an "asyncron" method which updates this label depending on an external
hotplugging event.

The dialog looks exactly the way I want it to before the asyncron method kicks
in and updates the label with a SetLabel() call on the label instance. This
call causes the label to not be centered anymore, and I've tried just about
anything to get it to center again, including

label instance: SetWindowStyle(wx.ALIGN_CENTRE), SetInitialSize(), Refresh(),
Update()
dialog instance: Refresh(), Update()

But to no avail. The only thing which actually works, is:

size=dialog.GetSize()
dialog.SetSize(size[0]+1, size[1]+1)

This will cause the entire dialog to be resized and the label to be centered
again, but the solution is non-optimal for several reasons :slight_smile: (Setting the
size to the same as GetSize returns does not work)

Now the question is - how do I do this "the proper way" ?

Have you tried something like:

dialog.GetSizer().Layout()

or:

dialog.Layout()

? I don't know if it will work, but it's worth trying it...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On Wed, Oct 15, 2008 at 10:04 AM, Frank Aune wrote:

dialog.Layout() worked perfectly - thank you for the incredibly fast response
Andrea! :slight_smile:

Cheers,
Frank

···

On Wednesday 15 October 2008 11:41:29 Andrea Gavana wrote:

Have you tried something like:

dialog.GetSizer().Layout()

or:

dialog.Layout()