wxPython-4.0.3 — Prevent overlapping expanding panels





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to build a wx.Panel object that has multiple paragraphs of individually wrapped text. When the parent panel becomes too small the paragraphs overlap and hide portions of the text.



How do I create a panel with flowing text that does not get hidden by other objects when the frame is resized? I want each paragraph to flow nicely when the window is resized; however, I do not want paragraphs to collide with each other when the window becomes too small.



The Panel.SetMinSize doesn't seem to be a candidate as I will never know the minimum height of a flowing paragraph based on the width of the window.



#!/usr/bin/env python3
import wx

class MyFrame(wx.Frame):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
frame_sizer = wx.BoxSizer(wx.VERTICAL)

text1 = wx.StaticText(self, label=self.big_string_one())
text2 = wx.StaticText(self, label=self.big_string_two())
color_panel = wx.Panel(self)
color_panel.SetMinSize(size=wx.Size(-1, 10))
color_panel.SetMaxSize(size=wx.Size(-1, 10))
color_panel.BackgroundColour = "blue"
frame_sizer.Add(text1, 1, flag=wx.ALL|wx.EXPAND, border=10)
frame_sizer.Add(color_panel, 1, flag=wx.EXPAND)
frame_sizer.Add(text2, 1, flag=wx.ALL|wx.EXPAND, border=10)
self.SetSizer(frame_sizer)

def big_string_one(self):
retval = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Ut ipsum lectus, mollis et pellentesque at, dapibus "
"eu, laoreet dui. Class aptent taciti sociosqu ad litora "
"torquent per conubia nostra, per inceptos himenaeos. "
"Curabitur vestibulum, turpis fringilla convallis "
"commodo, lectus lorem pharetra metus, non interdum magna "
"convallis. Sed id metus in leo porttitor eleifend. "
"Vivamus eget arcu at ligula ullamcorper consequat eget "
"non turpis. Duis consequat ultrices dolor eu porta. Cras "
"malesuada elementum urna, sed vulputate metus."
return retval

def big_string_two(self):
retval = "Morbi finibus hendrerit lacinia. Vestibulum eget metus "
"vitae mi vehicula dignissim. Donec lobortis dignissim "
"nisl, rutrum viverra nisl vulputate sed. Quisque quis "
"placerat. Ut tincidunt dolor justo, fermentum lacinia "
"metus bibendum a. Morbi ornare id ligula a eleifend. "
"Phasellus at ultricies ante. Praesent malesuada nunc "
"tortor, vel accumsan ex tempus at. Praesent eget ligula "
"ac purus pharetra semper rutrum a nunc. Donec et "
"lobortis mauris, non suscipit erat. Cras sagittis urna "
"lobortis tortor vestibulum, vel pulvinar nisi finibus."
return retval


if __name__ == "__main__":
app = wx.App()
my_frame = MyFrame(None).Show()
app.MainLoop()


The window is sized and both paragraph texts flows nicely
enter image description here



The window is now smaller and text of the first paragraph is cropped by the blue spacer.
enter image description here



My preference is to have the text for all paragraphs flow nicely but not have them overlap each other when the window becomes smaller.










share|improve this question























  • When the parent panel becomes too small the paragraphs overlap and hide portions of the text - What do you think should happen if there is insufficient space?

    – Rolf of Saxony
    Nov 25 '18 at 9:10











  • I want the text to flow when the window is resized;however I do not want the objects to overlap each other. Obviously the window is allowed to clip the viewable content. I don’t want internal objects to overlap. If I set a minimum size this can be achieved; however with flowing text the minimum height for the text area changes depending on the width of the window.

    – Kristian
    Nov 25 '18 at 13:33











  • Use a ScrolledPanel instead. Then nothing will overlap.

    – Mike Driscoll
    Nov 27 '18 at 14:21











  • Yes, thank you. That is what I ended up doing.

    – Kristian
    Nov 27 '18 at 14:23


















0















I am trying to build a wx.Panel object that has multiple paragraphs of individually wrapped text. When the parent panel becomes too small the paragraphs overlap and hide portions of the text.



How do I create a panel with flowing text that does not get hidden by other objects when the frame is resized? I want each paragraph to flow nicely when the window is resized; however, I do not want paragraphs to collide with each other when the window becomes too small.



The Panel.SetMinSize doesn't seem to be a candidate as I will never know the minimum height of a flowing paragraph based on the width of the window.



#!/usr/bin/env python3
import wx

class MyFrame(wx.Frame):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
frame_sizer = wx.BoxSizer(wx.VERTICAL)

text1 = wx.StaticText(self, label=self.big_string_one())
text2 = wx.StaticText(self, label=self.big_string_two())
color_panel = wx.Panel(self)
color_panel.SetMinSize(size=wx.Size(-1, 10))
color_panel.SetMaxSize(size=wx.Size(-1, 10))
color_panel.BackgroundColour = "blue"
frame_sizer.Add(text1, 1, flag=wx.ALL|wx.EXPAND, border=10)
frame_sizer.Add(color_panel, 1, flag=wx.EXPAND)
frame_sizer.Add(text2, 1, flag=wx.ALL|wx.EXPAND, border=10)
self.SetSizer(frame_sizer)

def big_string_one(self):
retval = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Ut ipsum lectus, mollis et pellentesque at, dapibus "
"eu, laoreet dui. Class aptent taciti sociosqu ad litora "
"torquent per conubia nostra, per inceptos himenaeos. "
"Curabitur vestibulum, turpis fringilla convallis "
"commodo, lectus lorem pharetra metus, non interdum magna "
"convallis. Sed id metus in leo porttitor eleifend. "
"Vivamus eget arcu at ligula ullamcorper consequat eget "
"non turpis. Duis consequat ultrices dolor eu porta. Cras "
"malesuada elementum urna, sed vulputate metus."
return retval

def big_string_two(self):
retval = "Morbi finibus hendrerit lacinia. Vestibulum eget metus "
"vitae mi vehicula dignissim. Donec lobortis dignissim "
"nisl, rutrum viverra nisl vulputate sed. Quisque quis "
"placerat. Ut tincidunt dolor justo, fermentum lacinia "
"metus bibendum a. Morbi ornare id ligula a eleifend. "
"Phasellus at ultricies ante. Praesent malesuada nunc "
"tortor, vel accumsan ex tempus at. Praesent eget ligula "
"ac purus pharetra semper rutrum a nunc. Donec et "
"lobortis mauris, non suscipit erat. Cras sagittis urna "
"lobortis tortor vestibulum, vel pulvinar nisi finibus."
return retval


if __name__ == "__main__":
app = wx.App()
my_frame = MyFrame(None).Show()
app.MainLoop()


The window is sized and both paragraph texts flows nicely
enter image description here



The window is now smaller and text of the first paragraph is cropped by the blue spacer.
enter image description here



My preference is to have the text for all paragraphs flow nicely but not have them overlap each other when the window becomes smaller.










share|improve this question























  • When the parent panel becomes too small the paragraphs overlap and hide portions of the text - What do you think should happen if there is insufficient space?

    – Rolf of Saxony
    Nov 25 '18 at 9:10











  • I want the text to flow when the window is resized;however I do not want the objects to overlap each other. Obviously the window is allowed to clip the viewable content. I don’t want internal objects to overlap. If I set a minimum size this can be achieved; however with flowing text the minimum height for the text area changes depending on the width of the window.

    – Kristian
    Nov 25 '18 at 13:33











  • Use a ScrolledPanel instead. Then nothing will overlap.

    – Mike Driscoll
    Nov 27 '18 at 14:21











  • Yes, thank you. That is what I ended up doing.

    – Kristian
    Nov 27 '18 at 14:23














0












0








0








I am trying to build a wx.Panel object that has multiple paragraphs of individually wrapped text. When the parent panel becomes too small the paragraphs overlap and hide portions of the text.



How do I create a panel with flowing text that does not get hidden by other objects when the frame is resized? I want each paragraph to flow nicely when the window is resized; however, I do not want paragraphs to collide with each other when the window becomes too small.



The Panel.SetMinSize doesn't seem to be a candidate as I will never know the minimum height of a flowing paragraph based on the width of the window.



#!/usr/bin/env python3
import wx

class MyFrame(wx.Frame):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
frame_sizer = wx.BoxSizer(wx.VERTICAL)

text1 = wx.StaticText(self, label=self.big_string_one())
text2 = wx.StaticText(self, label=self.big_string_two())
color_panel = wx.Panel(self)
color_panel.SetMinSize(size=wx.Size(-1, 10))
color_panel.SetMaxSize(size=wx.Size(-1, 10))
color_panel.BackgroundColour = "blue"
frame_sizer.Add(text1, 1, flag=wx.ALL|wx.EXPAND, border=10)
frame_sizer.Add(color_panel, 1, flag=wx.EXPAND)
frame_sizer.Add(text2, 1, flag=wx.ALL|wx.EXPAND, border=10)
self.SetSizer(frame_sizer)

def big_string_one(self):
retval = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Ut ipsum lectus, mollis et pellentesque at, dapibus "
"eu, laoreet dui. Class aptent taciti sociosqu ad litora "
"torquent per conubia nostra, per inceptos himenaeos. "
"Curabitur vestibulum, turpis fringilla convallis "
"commodo, lectus lorem pharetra metus, non interdum magna "
"convallis. Sed id metus in leo porttitor eleifend. "
"Vivamus eget arcu at ligula ullamcorper consequat eget "
"non turpis. Duis consequat ultrices dolor eu porta. Cras "
"malesuada elementum urna, sed vulputate metus."
return retval

def big_string_two(self):
retval = "Morbi finibus hendrerit lacinia. Vestibulum eget metus "
"vitae mi vehicula dignissim. Donec lobortis dignissim "
"nisl, rutrum viverra nisl vulputate sed. Quisque quis "
"placerat. Ut tincidunt dolor justo, fermentum lacinia "
"metus bibendum a. Morbi ornare id ligula a eleifend. "
"Phasellus at ultricies ante. Praesent malesuada nunc "
"tortor, vel accumsan ex tempus at. Praesent eget ligula "
"ac purus pharetra semper rutrum a nunc. Donec et "
"lobortis mauris, non suscipit erat. Cras sagittis urna "
"lobortis tortor vestibulum, vel pulvinar nisi finibus."
return retval


if __name__ == "__main__":
app = wx.App()
my_frame = MyFrame(None).Show()
app.MainLoop()


The window is sized and both paragraph texts flows nicely
enter image description here



The window is now smaller and text of the first paragraph is cropped by the blue spacer.
enter image description here



My preference is to have the text for all paragraphs flow nicely but not have them overlap each other when the window becomes smaller.










share|improve this question














I am trying to build a wx.Panel object that has multiple paragraphs of individually wrapped text. When the parent panel becomes too small the paragraphs overlap and hide portions of the text.



How do I create a panel with flowing text that does not get hidden by other objects when the frame is resized? I want each paragraph to flow nicely when the window is resized; however, I do not want paragraphs to collide with each other when the window becomes too small.



The Panel.SetMinSize doesn't seem to be a candidate as I will never know the minimum height of a flowing paragraph based on the width of the window.



#!/usr/bin/env python3
import wx

class MyFrame(wx.Frame):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
frame_sizer = wx.BoxSizer(wx.VERTICAL)

text1 = wx.StaticText(self, label=self.big_string_one())
text2 = wx.StaticText(self, label=self.big_string_two())
color_panel = wx.Panel(self)
color_panel.SetMinSize(size=wx.Size(-1, 10))
color_panel.SetMaxSize(size=wx.Size(-1, 10))
color_panel.BackgroundColour = "blue"
frame_sizer.Add(text1, 1, flag=wx.ALL|wx.EXPAND, border=10)
frame_sizer.Add(color_panel, 1, flag=wx.EXPAND)
frame_sizer.Add(text2, 1, flag=wx.ALL|wx.EXPAND, border=10)
self.SetSizer(frame_sizer)

def big_string_one(self):
retval = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Ut ipsum lectus, mollis et pellentesque at, dapibus "
"eu, laoreet dui. Class aptent taciti sociosqu ad litora "
"torquent per conubia nostra, per inceptos himenaeos. "
"Curabitur vestibulum, turpis fringilla convallis "
"commodo, lectus lorem pharetra metus, non interdum magna "
"convallis. Sed id metus in leo porttitor eleifend. "
"Vivamus eget arcu at ligula ullamcorper consequat eget "
"non turpis. Duis consequat ultrices dolor eu porta. Cras "
"malesuada elementum urna, sed vulputate metus."
return retval

def big_string_two(self):
retval = "Morbi finibus hendrerit lacinia. Vestibulum eget metus "
"vitae mi vehicula dignissim. Donec lobortis dignissim "
"nisl, rutrum viverra nisl vulputate sed. Quisque quis "
"placerat. Ut tincidunt dolor justo, fermentum lacinia "
"metus bibendum a. Morbi ornare id ligula a eleifend. "
"Phasellus at ultricies ante. Praesent malesuada nunc "
"tortor, vel accumsan ex tempus at. Praesent eget ligula "
"ac purus pharetra semper rutrum a nunc. Donec et "
"lobortis mauris, non suscipit erat. Cras sagittis urna "
"lobortis tortor vestibulum, vel pulvinar nisi finibus."
return retval


if __name__ == "__main__":
app = wx.App()
my_frame = MyFrame(None).Show()
app.MainLoop()


The window is sized and both paragraph texts flows nicely
enter image description here



The window is now smaller and text of the first paragraph is cropped by the blue spacer.
enter image description here



My preference is to have the text for all paragraphs flow nicely but not have them overlap each other when the window becomes smaller.







python-3.x wxpython






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 20:12









KristianKristian

1354




1354













  • When the parent panel becomes too small the paragraphs overlap and hide portions of the text - What do you think should happen if there is insufficient space?

    – Rolf of Saxony
    Nov 25 '18 at 9:10











  • I want the text to flow when the window is resized;however I do not want the objects to overlap each other. Obviously the window is allowed to clip the viewable content. I don’t want internal objects to overlap. If I set a minimum size this can be achieved; however with flowing text the minimum height for the text area changes depending on the width of the window.

    – Kristian
    Nov 25 '18 at 13:33











  • Use a ScrolledPanel instead. Then nothing will overlap.

    – Mike Driscoll
    Nov 27 '18 at 14:21











  • Yes, thank you. That is what I ended up doing.

    – Kristian
    Nov 27 '18 at 14:23



















  • When the parent panel becomes too small the paragraphs overlap and hide portions of the text - What do you think should happen if there is insufficient space?

    – Rolf of Saxony
    Nov 25 '18 at 9:10











  • I want the text to flow when the window is resized;however I do not want the objects to overlap each other. Obviously the window is allowed to clip the viewable content. I don’t want internal objects to overlap. If I set a minimum size this can be achieved; however with flowing text the minimum height for the text area changes depending on the width of the window.

    – Kristian
    Nov 25 '18 at 13:33











  • Use a ScrolledPanel instead. Then nothing will overlap.

    – Mike Driscoll
    Nov 27 '18 at 14:21











  • Yes, thank you. That is what I ended up doing.

    – Kristian
    Nov 27 '18 at 14:23

















When the parent panel becomes too small the paragraphs overlap and hide portions of the text - What do you think should happen if there is insufficient space?

– Rolf of Saxony
Nov 25 '18 at 9:10





When the parent panel becomes too small the paragraphs overlap and hide portions of the text - What do you think should happen if there is insufficient space?

– Rolf of Saxony
Nov 25 '18 at 9:10













I want the text to flow when the window is resized;however I do not want the objects to overlap each other. Obviously the window is allowed to clip the viewable content. I don’t want internal objects to overlap. If I set a minimum size this can be achieved; however with flowing text the minimum height for the text area changes depending on the width of the window.

– Kristian
Nov 25 '18 at 13:33





I want the text to flow when the window is resized;however I do not want the objects to overlap each other. Obviously the window is allowed to clip the viewable content. I don’t want internal objects to overlap. If I set a minimum size this can be achieved; however with flowing text the minimum height for the text area changes depending on the width of the window.

– Kristian
Nov 25 '18 at 13:33













Use a ScrolledPanel instead. Then nothing will overlap.

– Mike Driscoll
Nov 27 '18 at 14:21





Use a ScrolledPanel instead. Then nothing will overlap.

– Mike Driscoll
Nov 27 '18 at 14:21













Yes, thank you. That is what I ended up doing.

– Kristian
Nov 27 '18 at 14:23





Yes, thank you. That is what I ended up doing.

– Kristian
Nov 27 '18 at 14:23












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461959%2fwxpython-4-0-3-prevent-overlapping-expanding-panels%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461959%2fwxpython-4-0-3-prevent-overlapping-expanding-panels%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini