本文整理汇总了Python中gi.repository.Gtk.CellRenderer方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.CellRenderer方法的具体用法?Python Gtk.CellRenderer怎么用?Python Gtk.CellRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.CellRenderer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _on_library_name_changed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def _on_library_name_changed(self, renderer, path, new_library_name):
"""Callback handling a change of a library name
:param Gtk.CellRenderer renderer: Cell renderer showing the library name
:param path: Path of library within the list store
:param str new_library_name: New library name
"""
old_library_name = self.library_list_store[int(path)][self.KEY_STORAGE_ID]
if old_library_name == new_library_name:
return
library_path = self.library_list_store[int(path)][self.VALUE_STORAGE_ID]
library_config = self.core_config_model.get_current_config_value("LIBRARY_PATHS", use_preliminary=True,
default={})
del library_config[old_library_name]
library_config[new_library_name] = library_path
self.core_config_model.set_preliminary_config_value("LIBRARY_PATHS", library_config)
self._select_row_by_column_value(self.view['library_tree_view'], self.library_list_store,
self.KEY_STORAGE_ID, new_library_name)
示例2: _on_shortcut_changed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def _on_shortcut_changed(self, renderer, path, new_shortcuts):
"""Callback handling a change of a shortcut
:param Gtk.CellRenderer renderer: Cell renderer showing the shortcut
:param path: Path of shortcuts within the list store
:param str new_shortcuts: New shortcuts
"""
action = self.shortcut_list_store[int(path)][self.KEY_STORAGE_ID]
old_shortcuts = self.gui_config_model.get_current_config_value("SHORTCUTS", use_preliminary=True)[action]
from ast import literal_eval
try:
new_shortcuts = literal_eval(new_shortcuts)
if not isinstance(new_shortcuts, list) and \
not all([isinstance(shortcut, string_types) for shortcut in new_shortcuts]):
raise ValueError()
except (ValueError, SyntaxError):
logger.warning("Shortcuts must be a list of strings")
new_shortcuts = old_shortcuts
shortcuts = self.gui_config_model.get_current_config_value("SHORTCUTS", use_preliminary=True, default={})
shortcuts[action] = new_shortcuts
self.gui_config_model.set_preliminary_config_value("SHORTCUTS", shortcuts)
self._select_row_by_column_value(self.view['shortcut_tree_view'], self.shortcut_list_store,
self.KEY_STORAGE_ID, action)
示例3: change_fg_colour
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def change_fg_colour(self, lc, cell, model, m_iter, data):
"""
:Description: Changes the foreground colour of a cell
:param lc: :class:`Gtk.TreeViewColumn` The column we are interested in
:param cell: :class:`Gtk.CellRenderer` The cell we want to change
:param model: :class:`Gtk.TreeModel`
:param iter: :class:`Gtk.TreeIter`
:param data: :py:class:`dict` (key=int,value=bool) value is true if channel already highlighted
:return: None
"""
for chan in data:
if model[m_iter][0] == chan:
if data[chan]:
cell.set_property('foreground_rgba',
Gdk.RGBA(0.9, 0.2, 0.2, 1))
else:
cell.set_property('foreground_rgba', Gdk.RGBA(0, 0, 0, 1))
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def __init__(self, treeview, max_colour_val):
Gtk.CellRenderer.__init__(self)
prop = GObject.Value()
prop.init(GObject.TYPE_INT)
treeview.style_get_property("horizontal-separator", prop)
self.cell_padding = old_div(prop.get_int(),2)
treeview.style_get_property("grid-line-width", prop)
self.cell_padding += prop.get_int()
self.selected_action = None
self.max_colour_val = max_colour_val
示例5: do_get_request_mode
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def do_get_request_mode(self):
""" Implementation of Gtk.CellRenderer.get_request_mode()."""
return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH
示例6: do_get_preferred_height
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def do_get_preferred_height(self, widget):
""" Implementation of Gtk.CellRenderer.get_preferred_height()."""
preferred_height = self.item_height + self.item_spacing
return (preferred_height, preferred_height)
示例7: do_get_preferred_width
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def do_get_preferred_width(self, widget):
""" Implementation of Gtk.CellRenderer.get_preferred_width()."""
actions = self.get_property("actions").actions
preferred_width = (len(actions)*(self.item_width + self.item_spacing +
self.line_width) + self.cell_padding)
return (preferred_width, preferred_width)
示例8: _on_checkbox_toggled
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def _on_checkbox_toggled(self, renderer, path, config_m, config_list_store):
"""Callback method handling a config toggle event
:param Gtk.CellRenderer renderer: Cell renderer that has been toggled
:param path: Path within the list store
:param ConfigModel config_m: The config model related to the toggle option
:param Gtk.ListStore config_list_store: The list store related to the toggle option
"""
config_key = config_list_store[int(path)][self.KEY_STORAGE_ID]
config_value = bool(config_list_store[int(path)][self.TOGGLE_VALUE_STORAGE_ID])
config_value ^= True
config_m.set_preliminary_config_value(config_key, config_value)
示例9: _on_library_path_changed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def _on_library_path_changed(self, renderer, path, new_library_path):
"""Callback handling a change of a library path
:param Gtk.CellRenderer renderer: Cell renderer showing the library path
:param path: Path of library within the list store
:param str new_library_path: New library path
"""
library_name = self.library_list_store[int(path)][self.KEY_STORAGE_ID]
library_config = self.core_config_model.get_current_config_value("LIBRARY_PATHS", use_preliminary=True,
default={})
library_config[library_name] = new_library_path
self.core_config_model.set_preliminary_config_value("LIBRARY_PATHS", library_config)
self._select_row_by_column_value(self.view['library_tree_view'], self.library_list_store,
self.KEY_STORAGE_ID, library_name)
示例10: _on_config_value_changed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def _on_config_value_changed(self, renderer, path, new_value, config_m, list_store):
"""Callback handling a change of a config value
:param Gtk.CellRenderer renderer: Cell renderer showing the shortcut
:param path: Path of shortcuts within the list store
:param ConfigModel config_m: The config model that is to be changed
:param Gtk.ListStore list_store: The list store that is to be changed
"""
config_key = list_store[int(path)][self.KEY_STORAGE_ID]
old_value = config_m.get_current_config_value(config_key, use_preliminary=True)
if old_value == new_value:
return
# Try to maintain the correct data type, which is extracted from the old value
if isinstance(old_value, bool):
if new_value in ["True", "true"]:
new_value = True
elif new_value in ["False", "false"]:
new_value = False
else:
logger.warning("'{}' must be a boolean value".format(config_key))
new_value = old_value
elif isinstance(old_value, (int, float)):
try:
new_value = int(new_value)
except ValueError:
try:
new_value = float(new_value)
except ValueError:
logger.warning("'{}' must be a numeric value".format(config_key))
new_value = old_value
config_m.set_preliminary_config_value(config_key, new_value)
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRenderer [as 别名]
def __init__(self):
Gtk.CellRenderer.__init__(self)
self.data = None