Whether the cell renderer is currently in editing mode
height
int
r/w/en
The fixed height
is-expanded
bool
r/w/en
Row is an expander row, and is expanded
is-expander
bool
r/w/en
Row has children
mode
Gtk.CellRendererMode
r/w/en
Editable mode of the CellRenderer
sensitive
bool
r/w/en
xlib.Display the cell sensitive
visible
bool
r/w/en
xlib.Display the cell
width
int
r/w/en
The fixed width
xalign
float
r/w/en
The x-align
xpad
int
r/w/en
The xpad
yalign
float
r/w/en
The y-align
ypad
int
r/w/en
The ypad
Signals
Name
Short Description
editing-canceled
This signal gets emitted when the user cancels the process of editing a cell.
editing-started
This signal gets emitted when a cell starts to be edited.
Gtk.CellRendererText
继承关系
Methods
方法修饰词
方法名及参数
static
new ()
set_fixed_height_from_font (number_of_rows)
Virtual Methods
do_edited (path, new_text)
Properties
Name
Type
Flags
Short Description
align-set
bool
r/w
Whether this tag affects the alignment mode
alignment
Pango.Alignment
r/w/en
How to align the lines
attributes
Pango.AttrList
r/w
A list of style attributes to apply to the text of the renderer
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
editable
bool
r/w
Whether the text can be modified by the user
editable-set
bool
r/w
Whether this tag affects text editability
ellipsize
Pango.EllipsizeMode
r/w/en
The preferred place to ellipsize the string, if the cell renderer does not have enough room to display the entire string
ellipsize-set
bool
r/w
Whether this tag affects the ellipsize mode
family
str
r/w
Name of the font family, e.g. Sans, Helvetica, Times, Monospace
family-set
bool
r/w
Whether this tag affects the font family
font
str
r/w
Font description as a string, e.g. “Sans Italic 12”
font-desc
Pango.FontDescription
r/w
Font description as a Pango.FontDescription struct
foreground
str
w
Foreground color as a string
foreground-gdk
Gdk.Color
d/r/w
Foreground color as a Gdk.Color deprecated
foreground-rgba
Gdk.RGBA
r/w
Foreground color as a Gdk.RGBA
foreground-set
bool
r/w
Whether this tag affects the foreground color
language
str
r/w
The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If you don’t understand this parameter, you probably don’t need it
language-set
bool
r/w
Whether this tag affects the language the text is rendered as
markup
str
w
Marked up text to render
max-width-chars
int
r/w/en
The maximum width of the cell, in characters
placeholder-text
str
r/w
Text rendered when an editable cell is empty
rise
int
r/w
Offset of text above the baseline (below the baseline if rise is negative)
rise-set
bool
r/w
Whether this tag affects the rise
scale
float
r/w
Font scaling factor
scale-set
bool
r/w
Whether this tag scales the font size by a factor
single-paragraph-mode
bool
r/w/en
Whether to keep all text in a single paragraph
size
int
r/w
Font size
size-points
float
r/w
Font size in points
size-set
bool
r/w
Whether this tag affects the font size
stretch
Pango.Stretch
r/w
Font stretch
stretch-set
bool
r/w
Whether this tag affects the font stretch
strikethrough
bool
r/w
Whether to strike through the text
strikethrough-set
bool
r/w
Whether this tag affects strikethrough
style
Pango.Style
r/w
Font style
style-set
bool
r/w
Whether this tag affects the font style
text
str
r/w
Text to render
underline
Pango.Underline
r/w
Style of underline for this text
underline-set
bool
r/w
Whether this tag affects underlining
variant
Pango.Variant
r/w
Font variant
variant-set
bool
r/w
Whether this tag affects the font variant
weight
int
r/w
Font weight
weight-set
bool
r/w
Whether this tag affects the font weight
width-chars
int
r/w/en
The desired width of the label, in characters
wrap-mode
Pango.WrapMode
r/w/en
How to break the string into multiple lines, if the cell renderer does not have enough room to display the entire string
wrap-width
int
r/w/en
The width at which the text is wrapped
Signals
Name
Short Description
edited
This signal is emitted after renderer has been edited.
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/15# section 081
TITLE = "CellRendererText"
DESCRIPTION = """
A Gtk.CellRendererText renders a given text in its cell,
using the font, color and style information provided by its properties.
The text will be ellipsized if it is too long and the
Gtk.CellRendererText :ellipsize property allows it.
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
classCellRendererTextWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="CellRendererText Example")
self.set_default_size(200, 200)
self.liststore = Gtk.ListStore(str, str)
self.liststore.append(["Fedora", "http://fedoraproject.org/"])
self.liststore.append(["Slackware", "http://www.slackware.com/"])
self.liststore.append(["Sidux", "http://sidux.com/"])
treeview = Gtk.TreeView(model=self.liststore)
renderer_text = Gtk.CellRendererText()
column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
treeview.append_column(column_text)
renderer_editabletext = Gtk.CellRendererText()
renderer_editabletext.set_property("editable", True)
column_editabletext = Gtk.TreeViewColumn("Editable Text",
renderer_editabletext, text=1)
treeview.append_column(column_editabletext)
renderer_editabletext.connect("edited", self.text_edited)
self.add(treeview)
deftext_edited(self, widget, path, text):
self.liststore[path][1] = text
defmain():
win = CellRendererTextWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Gtk.CellRendererCombo
继承关系
Methods
方法修饰词
方法名及参数
static
new ()
Virtual Methods
Properties
Name
Type
Flags
Short Description
has-entry
bool
r/w/en
If False, don’t allow to enter strings other than the chosen ones
model
Gtk.TreeModel
r/w
The model containing the possible values for the combo box
text-column
int
r/w/en
A column in the data source model to get the strings from
Signals
Name
Short Description
changed
This signal is emitted each time after the user selected an item in the combo box, either by using the mouse or the arrow keys.
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/15# section 082
TITLE = "CellRendererCombo"
DESCRIPTION = """
Gtk.CellRendererCombo renders text in a cell like Gtk.CellRendererText from which it is derived.
But while Gtk.CellRendererText offers a simple entry to edit the text,
Gtk.CellRendererCombo offers a Gtk.ComboBox widget to edit the text.
The values to display in the combo box are taken from the tree model specified
in the Gtk.CellRendererCombo :model property
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
classCellRendererComboWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="CellRendererCombo Example")
self.set_default_size(200, 200)
liststore_manufacturers = Gtk.ListStore(str)
manufacturers = ["Sony", "LG",
"Panasonic", "Toshiba", "Nokia", "Samsung"]
for item in manufacturers:
liststore_manufacturers.append([item])
self.liststore_hardware = Gtk.ListStore(str, str)
self.liststore_hardware.append(["Television", "Samsung"])
self.liststore_hardware.append(["Mobile Phone", "LG"])
self.liststore_hardware.append(["DVD Player", "Sony"])
treeview = Gtk.TreeView(model=self.liststore_hardware)
renderer_text = Gtk.CellRendererText()
column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
treeview.append_column(column_text)
renderer_combo = Gtk.CellRendererCombo()
renderer_combo.set_property("editable", True)
renderer_combo.set_property("model", liststore_manufacturers)
renderer_combo.set_property("text-column", 0)
renderer_combo.set_property("has-entry", False)
renderer_combo.connect("edited", self.on_combo_changed)
column_combo = Gtk.TreeViewColumn("Combo", renderer_combo, text=1)
treeview.append_column(column_combo)
self.add(treeview)
defon_combo_changed(self, widget, path, text):
self.liststore_hardware[path][1] = text
defmain():
win = CellRendererComboWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Gtk.CellRendererSpin
继承关系
Methods
方法修饰词
方法名及参数
static
new ()
Virtual Methods
Properties
Name
Type
Flags
Short Description
adjustment
Gtk.Adjustment
r/w
The adjustment that holds the value of the spin button
climb-rate
float
r/w
The acceleration rate when you hold down a button
digits
int
r/w/en
The number of decimal places to display
Signals
Name
Short Description
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/15# section 083
TITLE = "CellRendererSpin"
DESCRIPTION = """
Gtk.CellRendererSpin renders text in a cell like Gtk.CellRendererText from which it is derived.
But while Gtk.CellRendererText offers a simple entry to edit the text,
Gtk.CellRendererSpin offers a Gtk.SpinButton widget. Of course,
that means that the text has to be parseable as a floating point number.
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
classCellRendererSpinWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="CellRendererSpin Example")
self.set_default_size(200, 200)
self.liststore = Gtk.ListStore(str, int)
self.liststore.append(["Oranges", 5])
self.liststore.append(["Apples", 4])
self.liststore.append(["Bananas", 2])
treeview = Gtk.TreeView(model=self.liststore)
renderer_text = Gtk.CellRendererText()
column_text = Gtk.TreeViewColumn("Fruit", renderer_text, text=0)
treeview.append_column(column_text)
renderer_spin = Gtk.CellRendererSpin()
renderer_spin.connect("edited", self.on_amount_edited)
renderer_spin.set_property("editable", True)
adjustment = Gtk.Adjustment(0, 0, 100, 1, 10, 0)
renderer_spin.set_property("adjustment", adjustment)
column_spin = Gtk.TreeViewColumn("Amount", renderer_spin, text=1)
treeview.append_column(column_spin)
self.add(treeview)
defon_amount_edited(self, widget, path, value):
self.liststore[path][1] = int(value)
defmain():
win = CellRendererSpinWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Gtk.CellRendererPixbuf
继承关系
Methods
方法修饰词
方法名及参数
static
new ()
Virtual Methods
Properties
Name
Type
Flags
Short Description
follow-state
bool
d/r/w
Whether the rendered pixbuf should be colorized according to the state deprecated
gicon
Gio.Icon
r/w
The Gio.Icon being displayed
icon-name
str
r/w
The name of the icon from the icon theme
pixbuf
GdkPixbuf.Pixbuf
r/w
The pixbuf to render
pixbuf-expander-closed
GdkPixbuf.Pixbuf
r/w
Pixbuf for closed expander
pixbuf-expander-open
GdkPixbuf.Pixbuf
r/w
Pixbuf for open expander
stock-detail
str
r/w
Render detail to pass to the theme engine
stock-id
str
d/r/w
The stock ID of the stock icon to render deprecated
stock-size
int
r/w
The Gtk.IconSize value that specifies the size of the rendered icon
surface
cairo.Surface
r/w
The surface to render
Signals
Name
Short Description
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/15# section 084
TITLE = "CellRendererPixbuf"
DESCRIPTION = """
A Gtk.CellRendererPixbuf can be used to render an image in a cell.
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
classCellRendererPixbufWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="CellRendererPixbuf Example")
self.set_default_size(200, 200)
self.liststore = Gtk.ListStore(str, str)
self.liststore.append(["New", "document-new"])
self.liststore.append(["Open", "document-open"])
self.liststore.append(["Save", "document-save"])
treeview = Gtk.TreeView(model=self.liststore)
renderer_text = Gtk.CellRendererText()
column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
treeview.append_column(column_text)
renderer_pixbuf = Gtk.CellRendererPixbuf()
column_pixbuf = Gtk.TreeViewColumn("Image", renderer_pixbuf, icon_name=1)
treeview.append_column(column_pixbuf)
self.add(treeview)
defmain():
win = CellRendererPixbufWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Gtk.CellRendererSpinner
继承关系
Methods
方法修饰词
方法名及参数
static
new ()
Virtual Methods
Properties
Name
Type
Flags
Short Description
active
bool
r/w/en
Whether the spinner is active (ie. shown) in the cell
pulse
vint
r/w/en
Pulse of the spinner
size
Gtk.IconSize
r/w/en
The Gtk.IconSize value that specifies the size of the rendered spinner
Signals
Name
Short Description
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/15# section 086
TITLE = "CellRendererProgress"
DESCRIPTION = """
Gtk.CellRendererSpinner renders a spinning animation in a cell, very similar to Gtk.Spinner.
It can often be used as an alternative to a Gtk.CellRendererProgress for displaying indefinite activity,
instead of actual progress
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject
classCellRendererSpinnerWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="CellRendererSpinner Example")
self.set_default_size(200, 200)
self.liststore = Gtk.ListStore(str, int, bool)
self.current_iter = self.liststore.append(["Sabayon", 0, True])
self.liststore.append(["Zenwalk", 0, True])
self.liststore.append(["SimplyMepis", 0, True])
treeview = Gtk.TreeView(model=self.liststore)
renderer_text = Gtk.CellRendererText()
column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
treeview.append_column(column_text)
renderer_spinner = Gtk.CellRendererSpinner()
column_spinner = Gtk.TreeViewColumn("Spinning", renderer_spinner, pulse=1,
active=2)
treeview.append_column(column_spinner)
renderer_toggle = Gtk.CellRendererToggle()
renderer_toggle.connect("toggled", self.on_inverted_toggled)
column_toggle = Gtk.TreeViewColumn("Active", renderer_toggle,
active=2)
treeview.append_column(column_toggle)
self.add(treeview)
self.timeout_id = GObject.timeout_add(100, self.on_timeout, None)
defon_inverted_toggled(self, widget, path):
self.liststore[path][2] = not self.liststore[path][2]
defon_timeout(self, user_data):if self.liststore isNone:
returnFalsefor row in self.liststore:
pulse, active = row[1], row[2]
if pulse == 999999999:
pulse = 0else:
pulse += 1# self.liststore.set(row.iter, (1, 2), (pulse, active))
row[1], row[2] = pulse, active
returnTruedefmain():
win = CellRendererSpinnerWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Gtk.CellRendererToggle
继承关系
Methods
方法修饰词
方法名及参数
static
new ()
get_activatable ()
get_active ()
get_radio ()
set_activatable (setting)
set_active (setting)
set_radio (radio)
Virtual Methods
do_toggled (path)
Properties
Name
Type
Flags
Short Description
activatable
bool
r/w/en
The toggle button can be activated
active
bool
r/w/en
The toggle state of the button
inconsistent
bool
r/w/en
The inconsistent state of the button
indicator-size
int
d/r/w/en
Size of check or radio indicator deprecated
radio
bool
r/w/en
Draw the toggle button as a radio button
Signals
Name
Short Description
toggled
The ::toggled signal is emitted when the cell is toggled.
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/15# section 087
TITLE = "CellRendererToggle"
DESCRIPTION = """
Gtk.CellRendererToggle renders a toggle button in a cell.
The button is drawn as a radio or a checkbutton, depending on the
Gtk.CellRendererToggle :radio property. When activated,
it emits the Gtk.CellRendererToggle ::toggled signal.
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
classCellRendererToggleWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="CellRendererToggle Example")
self.set_default_size(200, 200)
self.liststore = Gtk.ListStore(str, bool, bool)
self.liststore.append(["Debian", False, True])
self.liststore.append(["OpenSuse", True, False])
self.liststore.append(["Fedora", False, False])
treeview = Gtk.TreeView(model=self.liststore)
renderer_text = Gtk.CellRendererText()
column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
treeview.append_column(column_text)
renderer_toggle = Gtk.CellRendererToggle()
renderer_toggle.connect("toggled", self.on_cell_toggled)
column_toggle = Gtk.TreeViewColumn("Toggle", renderer_toggle, active=1)
treeview.append_column(column_toggle)
renderer_radio = Gtk.CellRendererToggle()
renderer_radio.set_radio(True)
renderer_radio.connect("toggled", self.on_cell_radio_toggled)
column_radio = Gtk.TreeViewColumn("Radio", renderer_radio, active=2)
treeview.append_column(column_radio)
self.add(treeview)
defon_cell_toggled(self, widget, path):
self.liststore[path][1] = not self.liststore[path][1]
defon_cell_radio_toggled(self, widget, path):
selected_path = Gtk.TreePath(path)
for row in self.liststore:
row[2] = (row.path == selected_path)
defmain():
win = CellRendererToggleWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()