wx.StaticText alignment issue

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

wx.StaticText alignment issue

daniel d
Hello, I'm having issues with wx.StaticText alignment. My program has rows for each connected device. Before a device is connected, it looks like this


After I connect a device, it looks like this



When user clicks "Program" it clears "CONNECT DFU DEVICE" on all rows. After user has disconnected all devices, I use wx.StaticText.SetLabelText to put "CONNECT DFU DEVICE" back on each row. Sometimes it works fine (text is centered as it should be). Other times the text comes back in the wrong place


If I resize the window using the mouse or other means, "CONNECT DFU DEVICE" on all rows pops back in the center where it should be. Any idea how to fix this? 




--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticText alignment issue

Anders Munch
daniel d:
> Hello, I'm having issues with wx.StaticText alignment.

I suspect that at the time of the previous .Layout(), the StaticText's were blank and so were given a very small size. And they're right-aligned that also means they ended up positioned to the far right.  So when you change the label text there's isn't room for the larger text.
Re-layouting the frame (or a panel of the frame) after SetLabelText should fix that.  If you want to avoid a re-layout, because it might move other things around slightly as well, then perhaps you can give the StaticText's explicit sizes instead of having the size set by content.

BR, Anders

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticText alignment issue

Dietmar Schwertberger-2
In reply to this post by daniel d
On 8/2/2018 12:00 AM, daniel d wrote:
> Hello, I'm having issues with wx.StaticText alignment. My program has
> rows for each connected device. Before a device is connected, it looks
> like this

Before optimizing the StaticText approach, I would suggest to use
read-only text controls.
That's more common for dynamic texts. StaticText is for what the name
says....

Regards,

Dietmar

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticText alignment issue

daniel d
In reply to this post by Anders Munch
Layout() did the trick! Thanks!

On Thursday, August 2, 2018 at 4:03:22 AM UTC-5, Anders Munch wrote:
daniel d:
> Hello, I'm having issues with wx.StaticText alignment.

I suspect that at the time of the previous .Layout(), the StaticText's were blank and so were given a very small size. And they're right-aligned that also means they ended up positioned to the far right.  So when you change the label text there's isn't room for the larger text.
Re-layouting the frame (or a panel of the frame) after SetLabelText should fix that.  If you want to avoid a re-layout, because it might move other things around slightly as well, then perhaps you can give the StaticText's explicit sizes instead of having the size set by content.

BR, Anders

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.StaticText alignment issue

daniel d
In reply to this post by Dietmar Schwertberger-2
Ah I was wondering if StaticText was the right thing to use. I am brand new to wx. Thanks for the suggestion! I will give that a try

On Thursday, August 2, 2018 at 12:35:46 PM UTC-5, Dietmar Schwertberger wrote:
On 8/2/2018 12:00 AM, daniel d wrote:
> Hello, I'm having issues with wx.StaticText alignment. My program has
> rows for each connected device. Before a device is connected, it looks
> like this

Before optimizing the StaticText approach, I would suggest to use
read-only text controls.
That's more common for dynamic texts. StaticText is for what the name
says....

Regards,

Dietmar

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.