简体   繁体   English

PyGTK / Glade-滚动条未出现在ScrolledWindow中

[英]PyGTK/Glade - Scrollbars don't appear in ScrolledWindow

I made an interface in Glade and I have a GtkScrolledWindow with a GtkTreeView inside. 我在Glade中创建了一个接口,并且有一个内部带有GtkTreeView的GtkScrolledWindow。 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. ScrolledWindow设置为可见。

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: 这是.glade文件的相关部分:

<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: 没有滚动条和glade小部件树的treeview屏幕截图: 为什么
(source: dogtato.net ) (来源: 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. GTK-2的Glade对我来说是个小虫子,直到我在右上角的树状视图中选择它们后,它才绘制正确的所有小部件。 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. 我没有编写任何实际的代码使用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 完整的代码在这里: https : //github.com/dogtato/dbfutil/tree/pygtk

The simple fix was: 简单的解决方法是:

  • TreeView: set Fixed Height Mode to No TreeView:将“固定高度模式”设置为“否”
  • TreeViewColumn: set Sizing to Automatic or Grow Only TreeViewColumn:将“大小调整”设置为“自动”或“仅增长”

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. 或者,可以为列提供固定的宽度,该宽度超过ScrolledWindow的宽度,但这是根据需要显示滚动条。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM