本文整理汇总了Python中gi.repository.Gtk.CellRendererText方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.CellRendererText方法的具体用法?Python Gtk.CellRendererText怎么用?Python Gtk.CellRendererText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.CellRendererText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_interface
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def build_interface(self):
"""
Builds the interface.
"""
self.model = Gtk.ListStore(str, str)
self.view = Gtk.TreeView(model=self.model)
self.selection = self.view.get_selection()
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(_('Key'), renderer, text=0)
self.view.append_column(column)
renderer = Gtk.CellRendererText()
renderer.set_property('editable', True)
renderer.connect('edited', self.__cell_edited, (self.model, 1))
column = Gtk.TreeViewColumn(_('Value'), renderer, text=1)
self.view.append_column(column)
scrollwin = Gtk.ScrolledWindow()
scrollwin.add(self.view)
scrollwin.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.pack_start(scrollwin, expand=True, fill=True, padding=0)
示例2: create_tab
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def create_tab(self, title):
"""
Create a page in the notebook.
"""
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
view = Gtk.TreeView()
column = Gtk.TreeViewColumn(_('Files'))
view.append_column(column)
cell = Gtk.CellRendererText()
column.pack_start(cell, True)
column.add_attribute(cell, 'text', 0)
column.set_sort_column_id(0)
column.set_sort_indicator(True)
model = Gtk.ListStore(str, str)
view.set_model(model)
page = self.notebook.get_n_pages()
view.connect('button-press-event', self.button_press, page)
scrolled_window.add(view)
self.models.append(model)
self.views.append(view)
label = Gtk.Label(title)
self.notebook.append_page(scrolled_window, label)
示例3: create_treeview
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def create_treeview(self, lstore, list_of_lists, editable_column = None):
self.tv_w = Gtk.TreeView(model=lstore)
self.tv_w.set_size_request(-1, 70)
self.tv_w.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
self.tv_w_renderers = []
for i,v in enumerate(list_of_lists[0]):
if (type(v) == type("string") or
type(v) == type(1)):
renderer = Gtk.CellRendererText()
if editable_column or editable_column == 0:
column = Gtk.TreeViewColumn('',renderer, text=i, \
editable = editable_column)
else:
column = Gtk.TreeViewColumn('',renderer, text=i)
elif type(v) == type(False):
renderer = Gtk.CellRendererToggle()
column = Gtk.TreeViewColumn('',renderer, active=i)
else:
raise TypeError
self.tv_w.append_column(column)
self.tv_w_renderers.append(renderer)
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def __init__(self, builder, GPUs):
self.builder = builder
self.GPUs = GPUs
self.GPU = GPUs[0]
self.init_state = {}
self.set_maximum_values()
self.set_initial_values()
self.init_state = self.create_state_dict()
self.update_gui()
# initialise GPU selection combobox
textrenderer = Gtk.CellRendererText()
self.gpustore = Gtk.ListStore(str)
for i, card in enumerate(GPUs):
self.gpustore.append([f"{i+1}: {card.fancyname}"])
combobox = self.builder.get_object("GPU Selection")
combobox.set_model(self.gpustore)
combobox.pack_start(textrenderer, True)
combobox.add_attribute(textrenderer, "text", 0)
combobox.set_entry_text_column(0)
combobox.set_active(0)
combobox.connect("changed", self.on_GPU_changed)
# TODO implement POLKIT for writing as root, for now --> disable button
self.builder.get_object("Lock").set_sensitive(False)
示例5: init_treeview
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def init_treeview(self):
textrenderer = Gtk.CellRendererText()
self.plotrenderer = Gtk.CellRendererToggle()
self.plotrenderer.connect("toggled", self.on_plot_toggled)
self.normaliserenderer = Gtk.CellRendererToggle()
self.normaliserenderer.connect("toggled", self.on_normalise_toggled)
self.tree = self.builder.get_object("Signal Selection")
self.tree.append_column(Gtk.TreeViewColumn("Plot", self.plotrenderer, active=0))
self.tree.append_column(Gtk.TreeViewColumn("Scale", self.normaliserenderer, active=1, activatable=2))
columnnames=["Name","Unit","min","mean","max","current"]
for i,column in enumerate(columnnames):
tcolumn = Gtk.TreeViewColumn(column,textrenderer,text=i+3,foreground=9)
self.tree.append_column(tcolumn)
for plotsignal in self.Plotsignals:
self.signalstore.append([plotsignal.plotenable, plotsignal.plotnormalise, True, plotsignal.name, convert_to_si(plotsignal.unit)[0], '0', '0', '0', '0', plotsignal.plotcolor])
self.tree.set_model(self.signalstore)
示例6: _init_renderers
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def _init_renderers(self):
"""Initializes the cell renderers"""
# We hide the columns headers
self.set_headers_visible(False)
# For the backend icon
pixbuf_cell = Gtk.CellRendererPixbuf()
tvcolumn_pixbuf = Gtk.TreeViewColumn('Icon', pixbuf_cell)
tvcolumn_pixbuf.add_attribute(pixbuf_cell, 'pixbuf', self.COLUMN_ICON)
self.append_column(tvcolumn_pixbuf)
# For the backend name
text_cell = Gtk.CellRendererText()
tvcolumn_text = Gtk.TreeViewColumn('Name', text_cell)
tvcolumn_text.add_attribute(text_cell, 'markup', self.COLUMN_TEXT)
self.append_column(tvcolumn_text)
text_cell.connect('edited', self.cell_edited_callback)
text_cell.set_property('editable', True)
# For the backend tags
tags_cell = Gtk.CellRendererText()
tvcolumn_tags = Gtk.TreeViewColumn('Tags', tags_cell)
tvcolumn_tags.add_attribute(tags_cell, 'markup', self.COLUMN_TAGS)
self.append_column(tvcolumn_tags)
示例7: cell_edited_callback
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def cell_edited_callback(self, text_cell, path, new_text):
"""If a backend name is changed, it saves the changes in the Backend
@param text_cell: not used. The Gtk.CellRendererText that emitted the
signal. Only here because it's passed by the signal
@param path: the Gtk.TreePath of the edited cell
@param new_text: the new name of the backend
"""
# we strip everything not permitted in backend names
new_text = ''.join(c for c in new_text if (c.isalnum() or
c in [" ", "-", "_"]))
selected_iter = self.liststore.get_iter(path)
# update the backend name
backend_id = self.liststore.get_value(selected_iter,
self.COLUMN_BACKEND_ID)
backend = self.dialog.get_requester().get_backend(backend_id)
if backend:
backend.set_human_name(new_text)
# update the text in the liststore
self.liststore.set(selected_iter, self.COLUMN_TEXT, new_text)
示例8: smartifyComboboxEntry
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def smartifyComboboxEntry(combobox, list_obj, callback):
entry = Gtk.Entry()
# check if Clipboard contains an element of the list
clipboard = Gtk.Clipboard()
ifClipboardTextIsInListCallback(clipboard, list_obj, entry.set_text)
# pressing Enter will cause the callback
ifKeyPressedCallback(entry, "Return", callback)
# wrap the combo-box if it's too long
if len(list_obj) > 15:
combobox.set_wrap_width(5)
# populate the combo-box
if len(list_obj) > 0:
list_store = listStoreFromList(list_obj)
entry.set_completion(completionFromListStore(list_store))
combobox.set_model(list_store)
combobox.set_active(0)
entry.set_text(list_store[0][0])
combobox.add(entry)
combobox.connect('changed', setText, entry)
# render the combo-box drop down menu
cell = Gtk.CellRendererText()
combobox.pack_start(cell, True)
combobox.add_attribute(cell, 'text', 0)
return entry
示例9: create_treeview
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def create_treeview(self):
"""
Creates the viewport and adds it to the dialog window.
The parsing dialog displays the parsing results in a TreeView.
This requires setting up a TreeStore that has enough columns for a
typical file to be imported. The TreeViewColumns are set up for text
and appended to the TreeView. The TreeView is then added to to
the ScrolledWindow defined in Glade.
"""
self.store = Gtk.ListStore(str, str, str, str, str, str, str, str)
self.view = Gtk.TreeView(self.store)
for x in range(8):
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(str(x), renderer, text=x)
column.set_alignment(0.5)
column.set_expand(True)
self.view.append_column(column)
self.scr_win.add(self.view)
self.dialog.show_all()
示例10: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def __init__(self):
super(SemanticDataEditorView, self).__init__()
self.scrollbar_widget = self['semantic_data_scroller']
self['delete_entry'].set_border_width(constants.BUTTON_BORDER_WIDTH)
self['new_dict_entry'].set_border_width(constants.BUTTON_BORDER_WIDTH)
self['new_entry'].set_border_width(constants.BUTTON_BORDER_WIDTH)
tree_view = self["semantic_data_tree_view"]
# prepare tree view columns
key_renderer = Gtk.CellRendererText()
key_renderer.set_property('editable', True)
col = Gtk.TreeViewColumn('Key', key_renderer, text=self.KEY_STORAGE_ID)
tree_view.append_column(col)
value_renderer = Gtk.CellRendererText()
value_renderer.set_property('editable', True)
col = Gtk.TreeViewColumn('Value', value_renderer, text=self.VALUE_STORAGE_ID)
tree_view.append_column(col)
is_dict_renderer = Gtk.CellRendererText()
col = Gtk.TreeViewColumn('Is Dict', is_dict_renderer, text=self.IS_DICT_STORAGE_ID)
tree_view.append_column(col)
gui_helper_label.ellipsize_labels_recursively(self['semantic_data_toolbar'])
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def __init__(self):
View.__init__(self)
Gtk.TreeView.__init__(self)
foreground = 5
tvcolumn = Gtk.TreeViewColumn('Nr', Gtk.CellRendererText(), text=1, foreground=foreground)
tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE)
self.append_column(tvcolumn)
tvcolumn = Gtk.TreeViewColumn('Action', Gtk.CellRendererText(), text=2, foreground=foreground)
tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE)
self.append_column(tvcolumn)
tvcolumn = Gtk.TreeViewColumn('Parameters', Gtk.CellRendererText(), text=7, foreground=foreground)
tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE)
self.append_column(tvcolumn)
tvcolumn = Gtk.TreeViewColumn('Affects', Gtk.CellRendererText(), text=3, foreground=foreground)
tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE)
# tvcolumn.set_min_width(150)
self.append_column(tvcolumn)
self['history_treeview'] = self
self.top = 'history_treeview'
示例12: _setup_widgets
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def _setup_widgets(self):
"""Create/Setup the main widgets of the ActionBar."""
# Save Button
self._save_btn.set_label(_("Save"))
self._save_btn.connect("clicked", self._on_save)
self._save_btn.get_style_context().add_class("suggested-action")
self._save_btn.set_sensitive(False)
self.pack_end(self._save_btn)
# Output format Combo box
model = Gtk.ListStore(str, str)
for mimetype, desc in AUDIO_MIMES.items():
model.append([desc, mimetype])
renderer_text = Gtk.CellRendererText()
self._output_format.pack_start(renderer_text, True)
self._output_format.add_attribute(renderer_text, "text", 0)
self._output_format.set_active(0)
self._output_format.set_model(model)
self._output_format.set_sensitive(False)
self.pack_end(self._output_format)
示例13: createCombo
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def createCombo(combo, data=[], name=None, ellipsize_mode=None):
if name is not None:
combo.set_name(name)
lst_store = Gtk.ListStore(Pixbuf, str)
for row in data:
lst_store.append(row)
combo.clear()
combo.set_model(lst_store)
crp = Gtk.CellRendererPixbuf()
crp.set_property('xalign', 0)
crp.set_property('xpad', 2)
combo.pack_start(crp, False)
combo.add_attribute(crp, 'pixbuf', 0)
crt = Gtk.CellRendererText()
crt.set_property('xalign', 0)
crt.set_property('xpad', 4)
combo.pack_start(crt, True)
combo.add_attribute(crt, 'text', 1)
if ellipsize_mode is not None:
crt.set_property('ellipsize', ellipsize_mode)
示例14: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def __init__(self, database, host, *args, **kwargs):
super(Historyview, self).__init__(*args, **kwargs)
""" Single host's task history """
self.database = database
self.host = host
self.set_model(Gtk.ListStore(int, str, str, int, str))
self.history_liststore = self.get_model()
for i, column_title in enumerate(["id","Started", "Ended", "Pid", "Task"]):
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
self.append_column(column)
self.show_all()
self.refresh(self.database, self.host)
示例15: create_listview
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import CellRendererText [as 别名]
def create_listview(self):
self.model = Gtk.ListStore(str)
self.list = self.builder.get_object('listview_allowed_domains')
self.list.set_model(self.model)
parent = self.list.get_parent()
parent.remove(self.list)
self.scrollTree = self.builder.get_object('scrolledwindow_allowed_domains')
self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.scrollTree.add(self.list)
column = Gtk.TreeViewColumn('domain', Gtk.CellRendererText(), text=0)
column.set_clickable(True)
column.set_resizable(True)
self.list.append_column(column)
self.selection = self.list.get_selection()