Buggy Paned() + TextView() behavior

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Buggy Paned() + TextView() behavior

Thomas Mills Hinkle
I'm found some seriously strange behavior with a TextView inside a
Paned() widget. I believe this is most likely a bug in the underlying
gtk, but I'm not sure which component is to blame and so I'd be
grateful for any thoughts on where the underlying problem is so I can
find/file a useful bug report.

Note: this isn't a huge problem since I can fix it by changing the
scroll policy of the TextView widget. Nonetheless, it seems like it
shouldn't be happening.

Wrapping text in a TextView in a ScrolledWindow with a
no-horizontal-scroll policy inside an HPaned results in a rapidly
expanding window when the Paned widget's set_position method is
called.

Example code is below.

Tom
----

import gtk

w = gtk.Window()
vb = gtk.VBox()
b=gtk.Button("Show strange behavior")
vb.add(b)
hp=gtk.HPaned()
vb.add(hp)
w.add(vb)

# set up scrolled window
sw=gtk.ScrolledWindow()
# Changing POLICY_NEVER to POLICY_AUTOMATIC will make the
# strange behavior go away.
sw.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC)
txvw=gtk.TextView()
blob='This is some text to fill our buffer. ' * 10
blob = '%s\n'%blob * 75
txvw.get_buffer().set_text(blob)
txvw.set_wrap_mode(gtk.WRAP_WORD)
sw.add(txvw)

# add something to both sides
hp.add1(gtk.Label('This is absurd and very silly'))
hp.add2(sw)

def set_pos (*args):
    hp.set_position(45)

# connect our button to demonstrate
b.connect('clicked',set_pos)

w.show_all()
hp.show_all()
gtk.main()
_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Reply | Threaded
Open this post in threaded view
|

Re: Buggy Paned() + TextView() behavior

Maciej Katafiasz
Dnia 03-06-2005, pią o godzinie 22:14 -0400, Thomas Mills Hinkle
napisał:
> I'm found some seriously strange behavior with a TextView inside a
> Paned() widget. I believe this is most likely a bug in the underlying
> gtk, but I'm not sure which component is to blame and so I'd be
> grateful for any thoughts on where the underlying problem is so I can
> find/file a useful bug report.

>From quick look, it looks like bug in wordwrapping code interacting with
size request logic. Try grabbing gutter manually and slowly moving it to
the left -- you'll notice that it occurs every time textview gains
enough horizontal space to try re-wrapping lines. Because (with gutter
enough to the left) this will be reason for resize itself, you get the
behaviour you're observing -- textview rapidly expanding horizontally.
You can however stop it by moving gutter back to the right, thus
shutting the supply of horizontal space.

This indeed looks like genuine bug, please report to bugzilla.

Cheers,
Maciej

--
Maciej Katafiasz <[hidden email]>

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/