Multiline TextCtrl does not fill up window

When I create a multiline TextCtrl, it does not fill up its window (panel), whereas a non-multiline one does.

#!/usr/bin/env python3
# a multiline text widget with wxPython

import wx
import os


class TextWindow(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(520, 340))
        self.panel = wx.Panel(self)
        self.text = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE)
        self.text.SetBackgroundColour('LIGHT GREY')
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.panel, 1, wx.EXPAND | wx.ALIGN_CENTER)
        self.SetSizer(vbox)
        self.Bind(wx.EVT_SIZE, self.onSize)
        self.Show()

    def onSize(self, e):
        e.Skip()
        self.text.SetSize(self.GetClientSize())


def main():
    app = wx.App(False)
    view = TextWindow(None, "TextWindow")
    app.MainLoop()


if __name__ == '__main__':
    main()

I am using Python 3.8 with wxPython ‘4.0.7.post2 osx-cocoa (phoenix) wxWidgets 3.0.5’ on MacOS High Sierra.

As you can see there is a white area on the right that is not part of the TextCtrl. Is there something that I am doing wrong?

image ![image|520x340]

Nope. That white area is the text control’s scrollbar widget.

1 Like

Thanks Robin.
The MacOS scrollbar is very inconspicuous.