Hi pygtk users,

I am facing an unexpected behavior of a Gtk.Window with a ScrolledWindow
containing a TreeView. The window always has minimal size. The behavior
that I desire would be that the Gtk.Window scales as the TreeStore /
TreeView grows until it reaches the limit of the screen. This happens
without the ScrolledWindow. With a ScrolledWindow, the scroll bars then
should appear when the TreeView does not fit the screen.

I attached demo code. The set_policy method does not lead to the desired
behavior.

I'd highly appreciate any hints how the resize behavior of the
ScrollWindow could be manipulated into the desired direction.

Kind regards,
Enrico Minack

<<attachment: Bildschirmfoto-widget-window.py.png>>

from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, GConf, PanelApplet
import time

def delete_event(widget, event, data=None):
	print "delete event occurred"
	return False

def destroy(widget, data=None):
	Gtk.main_quit()

model = Gtk.TreeStore(GObject.TYPE_STRING)
model.insert(None, 0, ["1"])
model.insert(None, 0, ["2"])
iter = model.insert(None, 0, ["3"])
model.insert(None, 0, ["4"])
model.insert(None, 0, ["5"])

for i in range(6,10):
	model.insert(iter, 0, [str(i)])
tree = Gtk.TreeView()
tree.set_model(model)

cell_description = Gtk.CellRendererText ()
column_description = Gtk.TreeViewColumn ("name", cell_description)
column_description.add_attribute(cell_description, "text", 0)
tree.append_column(column_description)

window = Gtk.Window()
window.connect("delete_event", delete_event)
window.connect("destroy", destroy)
sw = Gtk.ScrolledWindow()
sw.add(tree)
#sw.set_policy(Gtk.PolicyType.NEVER,Gtk.PolicyType.AUTOMATIC)
#sw.set_policy(Gtk.PolicyType.NEVER,Gtk.PolicyType.NEVER)
window.add(sw)
window.show_all()
sw.set_policy(Gtk.PolicyType.NEVER,Gtk.PolicyType.AUTOMATIC)
Gtk.main()

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

Reply via email to