Extra space after textview (cross-posted from gtk-app-devel-list)

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

 



Hi,
I have a scrolledwindow+vbox with multiple textviews one after the other strung together. 
Built against gtk2, things appear fine. I'm trying to upgrade to gtk3, and 
have a problem.

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

The following python-gtk programs demonstrate. The gtk2 version of this code 
does not have the phantom space on initial creation.

Thanks,

Matt

------------------------------------------------------------------------------------------
THE GTK3 VERSION:

#!/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:

#!/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()

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux