- GtkScrollbar
- Methods
- Virtual Methods
- Properties
- Signals
- 例子
Gtk.Scrollbar
Gtk.Scrollbar滾動條,是同Gtk.Scale一樣,是Gtk.Range的直接子類
Methods
方法修飾詞 | 方法名及參數 |
---|---|
static | new (orientation, adjustment) |
Virtual Methods
Properties
Name | Type | Flags | Short Description |
---|
Signals
Name | Short Description |
---|
例子
代碼:
#!/usr/bin/env python3
# Created by xiaosanyu at 16/7/11
# section 119
#
# author: xiaosanyu
# website: yuxiaosan.tk \
# http://blog.csdn.net/a87b01c14
# created: 16/7/11
TITLE = "Scrollbar"
DESCRIPTION = """
The Gtk.Scrollbar widget is a horizontal or vertical scrollbar,
depending on the value of the Gtk.Orientable :orientation property.
"""
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
string = "Try to move the Scrollbar,watch carefully the text cursor changes!!"
class ScrollbarWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Scrollbar Demo")
gird = Gtk.Grid()
textview = self.create_textview()
self.buffer = textview.get_buffer()
gird.attach(textview, , , , )
sb = self.create_scrollbar()
gird.attach(sb, , , , )
self.add(gird)
@staticmethod
def create_textview():
textview = Gtk.TextView()
buffer = textview.get_buffer()
buffer.set_text(string)
buffer.place_cursor(buffer.get_start_iter())
return textview
def create_scrollbar(self):
ad = Gtk.Adjustment(value=, lower=, upper=len(string), step_increment=, page_increment=,
page_size=)
sb = Gtk.Scrollbar(orientation=Gtk.Orientation.HORIZONTAL, adjustment=ad)
sb.connect("value-changed", self.move)
return sb
def move(self, range):
self.buffer.place_cursor(self.buffer.get_iter_at_offset(int(range.get_value())))
# print("Move", range.get_value())
def main():
win = ScrollbarWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
代碼下載下傳位址:http://download.csdn.net/detail/a87b01c14/9594728