Recently I have been writing my own Python editor for fun. I have came pretty far but now I have some issues. My editor object is in my notebook but wont go to the bottom of my window. I can get it to expand across the screen but not down.

Any help is greatly welcomed.

source and screen shot are in zip archive.

Dani AI

Generated

Good catch, — that is the key rule most people trip over: the sizer’s orientation determines which dimension the numeric proportion controls, while the wx.EXPAND flag makes a child fill the cross axis. That explains why the StyledTextCtrl stretched left/right but not top/bottom.

Checklist to make a notebook page fill vertically:

  • Make sure the notebook itself is added to the frame’s sizer with a nonzero proportion and an expand flag so the notebook grows with the frame.
  • Put page contents on a wx.Panel (recommended) and call SetSizer on that panel. The panel’s sizer is what actually manages the controls on the page.
  • In a vertical BoxSizer give the editor control a nonzero proportion so it takes remaining vertical space; also use the expand flag so it fills horizontally. For horizontal BoxSizers the roles are reversed.
  • After building the layout call Layout (or the parent’s SendSizeEvent) so sizes propagate. Avoid hard-coded SetSize calls or fixed size hints unless you really need them.

Troubleshooting notes:

  • If multiple siblings should share space, adjust their proportions accordingly; if only one should stretch, give only that child a positive proportion.
  • For grid-based layouts use growable rows/columns (AddGrowableRow/AddGrowableCol) so the right cells expand.
  • Check the actual parent of the StyledTextCtrl — if it’s parented directly to the notebook instead of a panel the sizer behavior can be less predictable.

This expands on your solution so others reading later can apply the same rules to nested sizers, multiple controls, or different notebook/page arrangements.

Let me explain my issue a bit differently. I want to expand a wxStyledTextCtrl that is in a notebook pane to the bottom of my application. Right now it resizes horizontal but not vertical. How can I make it resize both ways?

Well sorry for opening this thread. I figured it out.

[ from Stackoverflow]
If you have a VERTICAL BoxSizer, wx.EXPAND will make the control fill horizontally, while a proportion of 1 or more (second argument to Add) will make the control fill vertically. It's the opposite for HORIZONTAL BoxSizers.

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(widget1, 0, wx.EXPAND)
sizer.Add(widget2, 1)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.