Gtk.CellView
Gtk.CellView用来显示Gtk.TreeModel中的一行数据,多个Gtk.CellView连在一起,就可以显示出和Gtk.TreeView类似的效果
继承关系
Methods
| 方法修饰词 | 方法名及参数 |
|---|---|
| static | new () |
| static | new_with_context (area, context) |
| static | new_with_markup (markup) |
| static | new_with_pixbuf (pixbuf) |
| static | new_with_text (text) |
| get_displayed_row () | |
| get_draw_sensitive () | |
| get_fit_model () | |
| get_model () | |
| get_size_of_row (path) | |
| set_background_color (color) | |
| set_background_rgba (rgba) | |
| set_displayed_row (path) | |
| set_draw_sensitive (draw_sensitive) | |
| set_fit_model (fit_model) | |
| set_model (model) |
Virtual Methods
Properties
| Name | Type | Flags | Short Description |
|---|---|---|---|
| background | str | w | Background color as a string |
| background-gdk | Gdk.Color | d/r/w | Background color as a Gdk.Color deprecated |
| background-rgba | Gdk.RGBA | r/w | Background color as a Gdk.RGBA |
| background-set | bool | r/w | Whether this tag affects the background color |
| cell-area | Gtk.CellArea | r/w/co | The Gtk.CellArea used to layout cells |
| cell-area-context | Gtk.CellAreaContext | r/w/co | The Gtk.CellAreaContext used to compute the geometry of the cell view |
| draw-sensitive | bool | r/w/en | Whether to force cells to be drawn in a sensitive state |
| fit-model | bool | r/w/en | Whether to request enough space for every row in the model |
| model | Gtk.TreeModel | r/w | The model for cell view |
Signals
| Name | Short Description |
|---|
例子
代码:
#!/usr/bin/env python3
# Created by xiaosanyu at 16/7/14
# section 108
#
# author: xiaosanyu
# website: yuxiaosan.tk \
# http://blog.youkuaiyun.com/a87b01c14
# created: 16/7/14
TITLE = "CellView"
DESCRIPTION = """
A Gtk.CellView displays a single row of a Gtk.TreeModel using a Gtk.CellArea and Gtk.CellAreaContext
"""
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, Gio, GLib
class CellViewWindow(Gtk.Window):
def __init__(self, *args, **kwargs):
Gtk.Window.__init__(self, title="CellView Example")
self.set_size_request(250, 200)
box = Gtk.VBox(spacing=6)
liststore = Gtk.ListStore(str, str)
liststore.append(["New", "document-new"])
liststore.append(["Open", "document-open"])
liststore.append(["Save", "document-save"])
cv = Gtk.CellView.new_with_text("New")
box.add(cv)
pixbuf = Gtk.IconTheme.get_default().load_icon("document-new", Gtk.IconSize.MENU, 0)
cv = Gtk.CellView.new_with_pixbuf(pixbuf)
box.add(cv)
# create Gtk.CellArea
cb = Gtk.CellAreaBox()
renderer_text = Gtk.CellRendererText()
cb.pack_start(renderer_text, False, False, 0)
cb.add_attribute(renderer_text, "text", 0)
renderer_pixbuf = Gtk.CellRendererPixbuf()
cb.pack_start(renderer_pixbuf, False, False, 0)
cb.add_attribute(renderer_pixbuf, "icon_name", 1)
# create Gtk.CellAreaContext
ctx = cb.create_context()
for i in range(3):
cv = Gtk.CellView.new_with_context(cb, ctx)
cv.set_model(liststore)
cv.set_background_rgba(Gdk.RGBA((1, 0)[i == 0], (1, 0)[i == 1], (1, 0)[i == 2], 1))
cv.set_displayed_row(Gtk.TreePath(i))
box.add(cv)
# model = cv.get_model()
# for row in model:
# print(row[:])
self.add(box)
def main():
win = CellViewWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
代码下载地址:http://download.youkuaiyun.com/detail/a87b01c14/9594728

本文介绍Gtk.CellView组件的使用方法,展示如何通过Gtk.CellView显示Gtk.TreeModel中的一行数据,并提供了一个Python示例程序来演示如何创建和配置Gtk.CellView。
666

被折叠的 条评论
为什么被折叠?



