Possible to have a multi-line TextCtrl without scrollbar?

I'm wondering if there's some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.

Thanks for any tips.

Try,

wx.TextCtrl(self, wx.ID_ANY, text, style=wx.TE_MULTILINE)

···

On Mar 12, 4:33 pm, wrybread <wrybr...@gmail.com> wrote:

I'm wondering if there's some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.

Thanks for any tips.

wx.TextCtrl(self, wx.ID_ANY, text, style=wx.TE_MULTILINE)

That produces a vertical scrollbar. I'm trying to avoid that.

Hi,
I'm not sure, it is possible in TextCtrl, but you may have a look at
wx.richtext.RichTextCtrl if it is an option,
in the demo the scrollbars appear first, after the text gets longer to
need scrolling.
Or maybe a custom widget like
wx.lib.expando.ExpandoTextCtrl which also doesn't show scrollbars

hth,
  vbr

···

2010/3/12 wrybread <wrybread@gmail.com>:

I'm wondering if there's some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.

Thanks for any tips.

Use the style wx.TE_MULTILINE | wx.TE_RICH

This wraps, and only shows the scroll bar when it's needed.

Bob

···

At 06:33 AM 3/12/2010, wrybread wrote:

I'm wondering if there's some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.

Thanks for any tips.

Use the style wx.TE_MULTILINE | wx.TE_RICH

This wraps, and only shows the scroll bar when it's needed.

Bob

···

At 06:33 AM 3/12/2010, wrybread wrote:

I'm wondering if there's some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.

Thanks for any tips.

It can be tricky and can vary somewhat by platform and what other styles are being used, but this is the best I could come up with in the ExpandoTextCtrl where I wanted the same thing:

     def __init__(self, parent, id=-1, value="",
                  pos=wx.DefaultPosition, size=wx.DefaultSize,
                  style=0, validator=wx.DefaultValidator, name="expando"):
         ...
         # always use the multi-line style
         style = style | wx.TE_MULTILINE | wx.TE_NO_VSCROLL | wx.TE_RICH2
         # init the base class
         wx.TextCtrl.__init__(self, parent, id, value, pos, (w, h),
                              style, validator, name)
         ...

···

On 3/12/10 3:33 AM, wrybread wrote:

I'm wondering if there's some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.

--
Robin Dunn
Software Craftsman

This is windows 7.
In windows 7 wx.TE_NO_VSCROLL removes the scrollbar but limits the number of lines (this behavior is documented).

However, I was testing interactively and I found that:

self.log = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)

self.log.SetScrollbar(-1, -1, 5, -1)

self.log.WriteText(‘adfgg\n’ * 10)

self.log.SetScrollbar(-1, -1, 5, -1)

self.log.Clear()

produces a scrollable multiline window with no line limits and without the scrollbar.

I dont know how this works, and feel dirty in some way after writing this code but setting the scrollbar twice before and after filling the textcontrol with text does the trick.

J

···

On Friday, March 12, 2010 8:15:48 PM UTC+1, Robin Dunn wrote:

On 3/12/10 3:33 AM, wrybread wrote:

I’m wondering if there’s some clever style combination, or some other
widget that would allow me to have a multi line TextCtrl without the
scrollbar on the side? It should still wrap.
It can be tricky and can vary somewhat by platform and what other styles
are being used, but this is the best I could come up with in the
ExpandoTextCtrl where I wanted the same thing:

def init(self, parent, id=-1, value=“”,
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=0, validator=wx.DefaultValidator, name=“expando”):

# always use the multi-line style
style = style | wx.TE_MULTILINE | wx.TE_NO_VSCROLL | wx.TE_RICH2
# init the base class
wx.TextCtrl.init(self, parent, id, value, pos, (w, h),
style, validator, name)


Robin Dunn
Software Craftsman
http://wxPython.org