Extra space after textview



Hi,

Working on a "bug" in a gtk program for a while. We have a window with multiple textviews one after the other strung together. Built against gtk2, things appear fine. I'm trying to upgrade to gtk3, and running into a problem. The following python-gtk programs demonstrate.

In GTK3, the more lines that are in the textview, the more extra blank space appears after each textview when it is initially created. And as soon as we resize the window, the extra space disappears. It is this phantom "extra space" that we need to get rid of. Any ideas what is wrong?

I included the gtk2 version of this code. It does not have the phantom space on initial creation.

Thanks for reading,

Matt


#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.set_default_size(300, 500)
win.show_all()

scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_border_width(10)
scrolledwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS)
win.add(scrolledwindow)
scrolledwindow.show()

vbox = Gtk.VBox()
scrolledwindow.add(vbox)

vbox.show()

def AddTextView(i):
    global vbox;
    textview = Gtk.TextView()
    textbuffer = textview.get_buffer()
    textbuffer.set_text("This is some text inside of a Gtk.TextView. In GTK3, the more lines that are here, the 
more extra blank space appears after the textview when it is initially created. And as soon as we resize the window, 
the extra space disappears. If we expand the window a lot, the textviews are laid out tightly, and extra gray space 
appears at the bottom of the window. The same code on gtk2 behaves differently. The textviews are packed nicely 
together if they have lots of text. If they only have a line or two, then there are gaps. But if we expand the the 
window a lot, then gaps appear between the textviews instead of at the end. Our problem is with GTK3. How do we 
eliminate the blanks-between-textviews upon initial load?")
    textview.set_wrap_mode(Gtk.WrapMode.WORD)
    textview.set_hexpand(True) # This is False by default
    vbox.add(textview)
    textview.show()

for i in range(6): AddTextView(i)

Gtk.main()



------------------------------------------------------------------------------------------
THE GTK2 VERSION OF THIS PROGRAM IS AS FOLLOWS:

#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk

win = gtk.Window()
win.connect("destroy", gtk.main_quit)
win.set_default_size(300, 500)
win.show_all()

scrolledwindow = gtk.ScrolledWindow()
scrolledwindow.set_border_width(10)
scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
win.add(scrolledwindow)
scrolledwindow.show()

vbox = gtk.VBox()
scrolledwindow.add_with_viewport(vbox)

vbox.show()

def AddTextView(i):
    global vbox;
    textview = gtk.TextView()
    textbuffer = textview.get_buffer()
    textbuffer.set_text("This is some text inside of a Gtk.TextView. In GTK3, the more lines that are here, the 
more extra blank space appears after the textview when it is initially created. And as soon as we resize the window, 
the extra space disappears. If we expand the window a lot, the textviews are laid out tightly, and extra gray space 
appears at the bottom of the window. The same code on gtk2 behaves differently. The textviews are packed nicely 
together if they have lots of text. If they only have a line or two, then there are gaps. But if we expand the the 
window a lot, then gaps appear between the textviews instead of at the end. Our problem is with GTK3. How do we 
eliminate the blanks-between-textviews upon initial load?")
    textview.set_wrap_mode(gtk.WRAP_WORD)
    #textview.set_hexpand(True) # This is True by default
    vbox.add(textview)
    textview.show()

for i in range(6): AddTextView(i)

gtk.main()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]