Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6365695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:19:34+00:00 2026-05-25T00:19:34+00:00

I have a problem with Gtk.Treeview indide a Gtk.ScrolledWindow . I have a large

  • 0

I have a problem with Gtk.Treeview indide a Gtk.ScrolledWindow. I have a large amount of data, which doesnt fit inside my normal window geometrics, so i put my Treeview inside a ScrolledWindow, which seems to be the normal way. The problem with this solution is, that my Column Headers disapear, when I scroll. This behaviour seems somewhat ok to me, since the ScrolledWindow should care about the widgets inside of it.

So, how do I get my Treeview to be scrollable AND show the column headers always in the first row?

I modified the basictreeview.py example to represent my problem:

#!/usr/bin/env python

# example basictreeview.py

import pygtk
pygtk.require('2.0')
import gtk

class BasicTreeViewExample:

    # close the window and quit
    def delete_event(self, widget, event, data=None):
        gtk.main_quit()
        return False

    def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Basic TreeView Example")
        self.window.set_size_request(200, 200)
        self.window.connect("delete_event", self.delete_event)

        # create a TreeStore with one string column to use as the model
        self.liststore = gtk.ListStore(str)

        # we'll add some data now - 4 rows with 3 child rows each
        for i in range(10):
            self.liststore.append([str(i)])

        # create the TreeView using treestore
        self.treeview = gtk.TreeView(self.liststore)

        # create the TreeViewColumn to display the data
        self.tvcolumn = gtk.TreeViewColumn("Column-Name", gtk.CellRendererText(), text=0)

        # add tvcolumn to treeview
        self.treeview.append_column(self.tvcolumn)

        # make it searchable
        self.treeview.set_search_column(0)

        # Allow sorting on the column
        self.tvcolumn.set_sort_column_id(0)

        # Allow drag and drop reordering of rows
        self.treeview.set_reorderable(True)

        # Add Treeview to a ScrolledWindow
        self.scrolledwindow = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
        self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scrolledwindow.add_with_viewport(self.treeview)

        self.window.add(self.scrolledwindow)

        self.window.show_all()

def main():
    gtk.main()

if __name__ == "__main__":
    tvexample = BasicTreeViewExample()
    main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:19:35+00:00Added an answer on May 25, 2026 at 12:19 am

    Change self.scrolledwindow.add_with_viewport to self.scrolledwindow.add and it will work. From the documentation:

    The add_with_viewport() method is used to add a widget (specified by child) without native scrolling capabilities to the scrolled window. This is a convenience function that is equivalent to adding child to a gtk.Viewport, then adding the viewport to the scrolled window. If a child has native scrolling (e.g. gtk.TextView, gtk.TreeView, gtk.Layout), use gtk.Container.add() instead of this method.

    gtk.TreeView‘s “native scrolling” keeps the column headers at the top, but if you put the entire treeview widget in a gtk.Viewport first, then the entire widget will scroll.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have GUI application with gtk.Treeview component. It's model is set to gtk.Treestore, which
The problem is basically this, in python's gobject and gtk bindings. Assume we have
I have problem when I try insert some data to Informix TEXT column via
I have a Gtk scrolled window that I'm trying to attach a PopupMenuHandler function
I'm into a problem with a GTK+ C application. I have a container that,
In my GUI, I have a list store treeview in my main window. When
Environment: Mono 2.6.7 CentOS 5.4, 32-bit I have a Gtk Window with various docking
I have problem while adding a child to a GtkVBox. The VBox is inside
Problem: I have a gtk.Dialog. Whenever the 'minimize' button on the dialog is clicked,
In our project, we're using gtkmm and we have several classes that extend Gtk::Window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.