Listbox changes size unnecessarily when window is resize.

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

Listbox changes size unnecessarily when window is resize.

Jaideep Singh
I am having a problem with listbox which expand automatically to a certain amount when the window is resized.
I am attaching a demo code to illustrate the issue.
If you hit "x" button more than four times and try to resize the window a little then listbox expands unnecessarily.
I don't know whether it's default behavior or not. If it is a default behavior, then how can I correct it?
I want the listbox to expand freely like it does when there is no value in it.

--
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.

demo.py (757 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Listbox changes size unnecessarily when window is resize.

Dietmar Schwertberger-2
On 2/11/2018 2:41 PM, Jaideep Singh wrote:
> I want the listbox to expand freely like it does when there is no
> value in it.

I'm not sure what you want to accomplish, but try this modification:

self.mainSizer.Add(self.List, 1, wx.ALL | wx.CENTER | wx.EXPAND, 20)

This makes the list box fill the available space vertically and
horizontally.

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: Listbox changes size unnecessarily when window is resize.

Jaideep Singh
Sir,
Thank you, for your reply. Your code above solved my problem, but i'm still not able to implement it in my original code.
I'm attaching my original code for reference. Any help is appreciated.

--
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.

demo.py (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Listbox changes size unnecessarily when window is resize.

Dietmar Schwertberger-2
On 2/12/2018 7:03 AM, Jaideep Singh wrote:
Thank you, for your reply. Your code above solved my problem, but i'm still not able to implement it in my original code.
You're welcome!
I'm attaching my original code for reference. Any help is appreciated.

Please try these modifications, i.e. with an explicit minimum size for both list boxes:

        self.panel.Screen1Editable2 = wx.ListBox(self.panel, style = wx.LB_SINGLE, size=(20,20))
        self.panel.Screen2Editable2 = wx.ListBox(self.panel, style = wx.LB_SINGLE, size=(20,20))

I think it behaves better this way. Without the minimum size it could be that the controls are setting their size themselves, depending on the number of entries and this triggers a re-layout. With the explicit sizes, the sizer takes those as base. I'm not 100% sure whether this explanation is correct, though.

You may want to replace your SetFont calls with this one right at the top:

        self.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))

The result is probably the same.

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: Listbox changes size unnecessarily when window is resize.

Jaideep Singh
Sir,
Thank you very much. Giving listboxes minimum size fixes my problem.
Your advice for replacing my SetFont calls is also very helpful.

Best Regards,
Jaideep


--
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.