Phil, thank you very much. Three things in reply.
1. UNcomment the first win.show_all(), it messes up with the
phantom space.
2. Change the vbox to grid, and COMMENT the first win.show_all(),
nothing at all shows in the window. UNcomment that first line, and
like #1 above, the text shows, but with the phantom space.
3. Your version has a related problem in that it squishes the
textviews too close to one another and are truncated. As soon as
you do a resize of the window, the textviews are shown fully.
On 10/25/2018 3:50 PM, Phil Clayton
wrote:
Doing a
single show_all after the widget hierarchy is in place, as shown
below, seems to fix this. I would guess this is due to changes in
geometry management between GTK+ 2 and 3.
------------------------------------------------------------------------------------------
#!/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)
win.show_all()
Gtk.main()
On 25/10/18 12:47, Matthew A. Postiff via gtk-list wrote:
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
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list
|