0
votes

I made an interface in Glade and I have a GtkScrolledWindow with a GtkTreeView inside. There are no scrollbars though. I set the policies to Always, and tried creating adjustments and set the treeview and the scrolled window to them. Items display in the treeview just fine, apart from being cut off. The ScrolledWindow is set to Visible.

I couldn't find any hint of anyone else having trouble with this, so what am I missing?

Here's the relevant part of the .glade file:

<object class="GtkScrolledWindow" id="joinwindow">
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="hadjustment">joinview_h_adjust</property>
    <property name="vadjustment">joinview_v_adjust</property>
    <property name="shadow_type">in</property>
    <child>
      <object class="GtkTreeView" id="joinview">
        <property name="visible">True</property>
        <property name="can_focus">True</property>
        <property name="model">jointree</property>
        <property name="hadjustment">joinview_h_adjust</property>
        <property name="vadjustment">joinview_v_adjust</property>
        <property name="headers_visible">False</property>
        <property name="headers_clickable">False</property>
        <property name="enable_search">False</property>
        <property name="search_column">0</property>
        <property name="fixed_height_mode">True</property>
        <property name="enable_tree_lines">True</property>
        <child>
          <object class="GtkTreeViewColumn" id="joinviewcolumn">
            <property name="sizing">fixed</property>
            <property name="title" translatable="yes">column</property>
            <child>
              <object class="GtkCellRendererText" id="joinviewcolumntext"/>
              <attributes>
                <attribute name="text">0</attribute>
              </attributes>
            </child>
          </object>
        </child>
      </object>
    </child>
  </object>

screenshot of the treeview with no scrollbars and the glade widget tree: why
(source: dogtato.net)

Glade for GTK-2 is a little buggy for me, It doesn't draw all the widgets right until I select them in the treeview in the upper right. Anyways, the scrollbars will appear IN GLADE if I fiddle with the Page Size setting of the adjustments, but still none in the app.

I haven't written any actual code doing anything with the ScrolledWindow. Is there any setup outside of glade that needs to be done, like connecting a signal?

The full code is here: https://github.com/dogtato/dbfutil/tree/pygtk

1

1 Answers

0
votes

The simple fix was:

  • TreeView: set Fixed Height Mode to No
  • TreeViewColumn: set Sizing to Automatic or Grow Only

With single-column views, the column resizes to fit its contents and scrollbars appear if the contents don't fit.
With multiple-column views, the columns will get an initial width and the scrollbars will appear if they don't fit.
It's less than obvious that "fixed height mode" for a treeview would mean "fixed width mode" for its columns, but that seems to be the case.

Alternately, the columns could be given fixed widths that exceed the width of the ScrolledWindow, but this was about showing scrollbars as-needed.