[WxPython] Dynamically Sized Widget - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [WxPython] Dynamically Sized Widget (/thread-14026.html) |
Dynamically Sized Widget - CanadaGuy - Nov-11-2018 I have a wx.Dialog box. In that dialog, I have widgetA. WidgetA contains widgetB. WidgetB can change its size at runtime in response to user selections. When widgetB gets larger, then widgetA, and the dialog box both need to adjust their layout/size to accomodate the larger widget. This page talks about doing this, and describes a few methods: https://wiki.wxpython.org/WhenAndHowToCallLayout The hierarchy is such that all panels and the dialog frame will need resizing, so I'm tempted to use one of the ideas from the page: widget = self.widgetThatWasChanged while widget.GetParent(): widget = widget.GetParent() widget.Layout() widget.Fit() if widget.IsTopLevel(): breakIs there any real downside to this since any fancy code would just be calling Layout() on all the parents anyway? RE: Dynamically Sized Widget - Larz60+ - Nov-12-2018 Read about sizers: https://wxpython.org/Phoenix/docs/html/sizers_overview.html RE: Dynamically Sized Widget - CanadaGuy - Nov-12-2018 (Nov-12-2018, 12:42 AM)Larz60+ Wrote: Read about sizers: https://wxpython.org/Phoenix/docs/html/sizers_overview.html Is there a particular section you had in mind? I'm using sizers for layout (i.e. no absolute positioning). Calling object.Layout() when a sizer is configured causes the sizer to do its thing with the new window boundaries (it appears so, anyways). Unless I'm missing something, I'm not aware of how sizers would automatically address container changes especially when windows are nested like nested panels in a custom widget. RE: Dynamically Sized Widget - Larz60+ - Nov-12-2018 This snippet I posted some time ago embeds sizers. Hope you can make some sense out of it. Perhaps if you run it and try resizing it will make sense, my brain has difficulty remembering anything more that a month old (sorry about that I'm in my 70's, so it comes as baggage). https://python-forum.io/Thread-Perfectly-proportioned-3-frame-wxpython-application-template |