The minimum height that the scrolled window will allocate to its content
min-content-width
int
r/w/en
The minimum width that the scrolled window will allocate to its content
overlay-scrolling
bool
r/w/en
Overlay scrolling mode
shadow-type
Gtk.ShadowType
r/w/en
阴影样式
vadjustment
Gtk.Adjustment
r/w/c
垂直方向Gtk.Adjustment
vscrollbar-policy
Gtk.PolicyType
r/w/en
垂直滚动条显示方式
window-placement
Gtk.CornerType
r/w/en
Where the contents are located with respect to the scrollbars.
window-placement-set
bool
r/w/en
Whether “window-placement” should be used to determine the location of the contents with respect to the scrollbars. deprecated
Signals
Name
Short Description
edge-overshot
The ::edge-overshot signal is emitted whenever user initiated scrolling makes the scrolledwindow firmly surpass (ie.
edge-reached
The ::edge-reached signal is emitted whenever user-initiated scrolling makes the scrolledwindow exactly reaches the lower or upper limits defined by the adjustment in that orientation.
move-focus-out
The ::move-focus-out signal is a keybinding signal which gets emitted when focus is moved away from the scrolled window by a keybinding.
scroll-child
The ::scroll-child signal is a keybinding signal which gets emitted when a keybinding that scrolls is pressed.
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/7/11# section 055# # author: xiaosanyu# website: yuxiaosan.tk \# http://blog.csdn.net/a87b01c14# created: 16/7/11
TITLE = "ScrolledWindow"
DESCRIPTION = """
Gtk.ScrolledWindow is a Gtk.Bin subclass: it’s a container the accepts a single child widget.
Gtk.ScrolledWindow adds scrollbars to the child widget and optionally draws a beveled frame around the child widget.
The scrolled window can work in two ways. Some widgets have native scrolling support;
these widgets implement the Gtk.Scrollable interface. Widgets with native scroll support include Gtk.TreeView, Gtk.TextView, and Gtk.Layout.
For widgets that lack native scrolling support, the Gtk.Viewport widget acts as an adaptor class,
implementing scrollability for child widgets that lack their own scrolling capabilities.
Use Gtk.Viewport to scroll child widgets such as Gtk.Grid, Gtk.Box, and so on.
If a widget has native scrolling abilities, it can be added to the Gtk.ScrolledWindow
with Gtk.Container.add(). If a widget does not, you must first add the widget to a Gtk.Viewport,
then add the Gtk.Viewport to the scrolled window. Gtk.Container.add() will do this for you for widgets
that don’t implement Gtk.Scrollable natively, so you can ignore the presence of the viewport
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
HEIGHT = 20
NUM = 100classScrolledWindow(Gtk.Window):def__init__(self):
super(ScrolledWindow, self).__init__(title="ScrolledWindow Demo")
self.set_size_request(200, 200)
self.layout = Gtk.Layout.new(None, None)
# important Sets the size of the scrollable area of the layout.
self.layout.set_size(200, NUM * HEIGHT)
self.sw = Gtk.ScrolledWindow()
self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.sw.add(self.layout)
for i in range(NUM):
self.layout.put(Gtk.Label("label" + str(i)), 20, HEIGHT * i)
self.add(self.sw)
defmain():
win = ScrolledWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()