[pygtk] Can't Get Text to Wrap With PyGTK TextView
(ScrolledWindow Problem)
Jusa
sj.m at iloinen.net
Sun Jun 29 16:05:45 WST 2008
Jusa wrote:
>
> Hi,
>
> I've been trying to figure out why I can't get text to wrap by the word
> with PyGTK TextView. I have a method similar to this in a class which is
> supposed to create a scrollable TextView inside a ScrolledWindow:
>
> def buildTextBox(self):
> self.scrollWnd = gtk.ScrolledWindow()
> self.scrollWnd.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
> self.scrollWnd.set_shadow_type(gtk.SHADOW_ETCHED_IN)
> self.scrollWnd.show()
> self.table.attach(self.scrollWnd, 0, 2, 1, 2)
>
> self.textView = gtk.TextView()
> self.textBuffer = self.textView.get_buffer()
> self.textView.set_wrap_mode(gtk.WRAP_WORD)
>
> self.scrollWnd.add(self.textView)
> self.textView.show()
>
> With this code, when I type text into the resulting text box, the box
> seems to expand out of the application window according to the typed text
> and not wrap it as I intended. I also tried applying a TextTag with the
> wrap-mode parameter to the TextBuffer but it didn't seem to have any
> effect.
>
> I'm at a loss here, so I'd appreciate any help.
>
I did some experiments and found out that the text will wrap only when I
change:
self.scrollWnd.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
to
self.scrollWnd.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
ie. when the vertical scroll bar is showing in the ScrolledWindow. The
solution of forcing a vertical scroll bar is ok for this scenario, but I ran
into another problem which is caused by the same thing. I have a TreeView
that uses ListStore in another ScrolledWindow, and I really don't want a
horizontal scroll bar to show up. However, by having it disabled the
ScrolledWindow seems to grow horizontally to fit the contents of the
TreeView, and it totally messes up the GUI. I don't want to have a
horizontal scroll bar here for aesthetic reasons.
Is there any way to make a ScrolledWindow to not expand to fit its contents?
Any help is welcome.
--
View this message in context: http://www.nabble.com/Can%27t-Get-Text-to-Wrap-With-PyGTK-TextView-tp18171787p18178249.html
Sent from the Gtk+ - Python mailing list archive at Nabble.com.
More information about the pygtk
mailing list