wxpython add line to TextCtrl

前端 未结 3 1589
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 05:46

I have a multi line, read only TextCtrl in wxpython I know how to set values using

myTextCtrl.SetValue(\'hello\')

But this will change wha

3条回答
  •  醉话见心
    2021-01-19 06:32

    I've had issues like this before and want to share what I discovered on this topic for future inquiries.

    In order to successfully have a multiline widget.TextCtrl object that interprets newline (\n) characters properly, two conditions have to be met:

    1) The wx.TE_MULTILINE tag is included in the "style" argument when instantiating the object.

    2) When setting the text value of the widget.TextCtrl object, you must use widget.SetValue and not widget.SetLabel to properly include the newline character. Using widget.SetLabel removes the newline characters entirely, and possibly other non-printable characters as well.

提交回复
热议问题