本文整理汇总了Python中gi.repository.Gtk.TreeStore方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.TreeStore方法的具体用法?Python Gtk.TreeStore怎么用?Python Gtk.TreeStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.TreeStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tree_data
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def get_tree_data(self, directory, parent=None):
"""Creates TreeStore table"""
for dirs in sorted(os.listdir(directory)):
path = os.path.join(directory, dirs)
if os.path.isdir(path):
os.chdir(dirs)
# count media
vidcount = len(glob.glob("*.MP4"))
imgcount = len(glob.glob("*.JPG"))
# size of directory, subdiretories exclued
size = sum([os.path.getsize(f) for f in os.listdir(".") if os.path.isfile(f)])
humansize = self.sizeof_fmt(size)
try:
# 4th/5th position in file name of last element in sorted list of sequences
# (e.g. Seq_03_010.JPG)
seq = int(sorted(glob.glob("Seq_*_*.*"))[-1][4:6])
except:
seq = 0
# transmit row to treestore
row = self.obj("treestore1").append(parent,
[dirs, vidcount, imgcount, humansize, path, seq, False, size]
)
# read subdirs as child rows
self.get_tree_data(path, row)
os.chdir("..")
示例2: glib_idle_add_store_extend
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def glib_idle_add_store_extend(store, things, clear=False, wait=False):
"""
Extend a GTK store object (either :py:class:`Gtk.ListStore` or
:py:class:`Gtk.TreeStore`) object using :py:func:`GLib.idle_add`. This
function is suitable for use in non-main GUI threads for synchronizing data.
:param store: The GTK storage object to add *things* to.
:type store: :py:class:`Gtk.ListStore`, :py:class:`Gtk.TreeStore`
:param tuple things: The array of things to add to *store*.
:param bool clear: Whether or not to clear the storage object before adding *things* to it.
:param bool wait: Whether or not to wait for the operation to complete before returning.
:return: Regardless of the *wait* parameter, ``None`` is returned.
:rtype: None
"""
if not isinstance(store, Gtk.ListStore):
raise TypeError('store must be a Gtk.ListStore instance')
idle_add = glib_idle_add_wait if wait else glib_idle_add_once
idle_add(_store_extend, store, things, clear)
示例3: on_toolbutton_cut_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def on_toolbutton_cut_clicked(self, toolbutton):
"""
Cuts the selected layer.
The data is copied into the Gdk.Clipboard and then removed from the
TreeStore.
"""
selection = self.layer_view.get_selection()
model, row_list = selection.get_selected_rows()
if len(row_list) == 0:
return
data = self.copy_layer()
self.clipboard.set_text(data, -1)
self.delete_layer(model, row_list)
示例4: parse_eigenvectors
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def parse_eigenvectors(self, treestore, subset=None):
"""
Parses a eigenvector layer and returns a list of each column
This method expect a TreeStore that stores the data of a layer. It
iterates over the rows and adds each column to a list. It returns 3
lists for line_dir, line_dip (the eigenvector) and values (the
eigenvalue)
"""
line_dir = []
line_dip = []
values = []
for key, row in enumerate(treestore):
if subset is not None and key not in subset:
continue
line_dir.append(float(row[0]))
line_dip.append(float(row[1]))
values.append(float(row[2]))
return line_dir, line_dip, values
示例5: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self, model, view):
assert isinstance(model, StateMachineManagerModel)
tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
super(StateMachineTreeController, self).__init__(model, view, view, tree_store)
self.add_controller("state_right_click_ctrl", StateMachineTreeRightClickMenuController(model, view))
self.view_is_registered = False
# view.set_hover_expand(True)
self.state_row_iter_dict_by_state_path = {}
self.__my_selected_sm_id = None
self._selected_sm_model = None
self.__expansion_state = {}
self._ongoing_complex_actions = []
self._state_which_is_updated = None
self.register()
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self, model, view):
"""Constructor
"""
assert isinstance(model, AbstractStateModel)
assert isinstance(view, SemanticDataEditorView)
if isinstance(model.state, LibraryState):
model_to_observe = model.state_copy
else:
model_to_observe = model
# define tree store with the values in [key, value Is Dict]
tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, bool, GObject.TYPE_PYOBJECT)
# unfortunately this cannot be down with super, as gtkmvc3 does not use super() consistently
TreeViewController.__init__(self, model_to_observe, view,
view["semantic_data_tree_view"], tree_store, logger)
AbstractExternalEditor.__init__(self)
self.semantic_data_counter = 0
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self, model=None, view=None):
assert isinstance(model, StateMachineManagerModel)
assert isinstance(view, ExecutionHistoryView)
super(ExecutionHistoryTreeController, self).__init__(model, view)
self.history_tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
# a TreeView
self.history_tree = view['history_tree']
self.history_tree.set_model(self.history_tree_store)
view['history_tree'].set_tooltip_column(self.TOOL_TIP_STORAGE_ID)
self.observe_model(state_machine_execution_model)
self._expansion_state = {}
self._update_lock = RLock()
self.update()
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self):
productgroup.ProductGroup.__init__(self)
self.qntyEntry = decimalentry.DecimalEntry()
self.builder.get_object("qntyBox").add(self.qntyEntry)
self.qntyEntry.show()
self.qntyWrnEntry = decimalentry.DecimalEntry()
self.builder.get_object("qntyWrnBox").add(self.qntyWrnEntry)
self.qntyWrnEntry.show()
self.purchPriceEntry = decimalentry.DecimalEntry()
self.builder.get_object("purchPriceBox").add(self.purchPriceEntry)
self.purchPriceEntry.show()
self.sellPriceEntry = decimalentry.DecimalEntry()
self.builder.get_object("sellPriceBox").add(self.sellPriceEntry)
self.sellPriceEntry.show()
self.treeview = self.builder.get_object("productsTreeView")
self.treestore = Gtk.TreeStore(str, str, str, str, str, str, int)
示例9: populate_tree
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def populate_tree(self, groups):
""" Accepts an array of n rows made of 2 elements each, and returns a TreeView."""
store = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, str)
for group in groups:
#header = '<span background=\"#5a58ff\" foreground=\"white\"><b> ' + group.replace('_', ' ').capitalize() + '\t</b></span>'
header = group.replace('_', ' ').capitalize()
it = store.append(None, [self.pix, header, ''])
for row in eval('self.' + group):
store.append(it, [None, row[0], row[1]])
tv = Gtk.TreeView(store)
#tv.set_rules_hint(True)
#tv.set_enable_tree_lines(True)
tv.set_show_expanders(False)
tv.set_level_indentation(10)
tv.expand_all()
return tv
示例10: _create_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def _create_dialog(self):
"""
Create a dialog box to select a form.
"""
# pylint: disable-msg=E1101
title = _("%(title)s - Gramps") % {'title': _("Select Form")}
top = Gtk.Dialog(title)
top.set_default_size(400, 350)
top.set_modal(True)
top.set_transient_for(self.uistate.window)
top.vbox.set_spacing(5)
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>'
% _("Select Form"))
label.set_use_markup(True)
top.vbox.pack_start(label, 0, 0, 5)
box = Gtk.Box()
top.vbox.pack_start(box, 1, 1, 5)
self.model = Gtk.TreeStore(str, str)
self.tree = Gtk.TreeView(model=self.model)
self.tree.connect('button-press-event', self.__button_press)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn("Source", renderer, text=1)
column.set_sort_column_id(1)
self.tree.append_column(column)
slist = Gtk.ScrolledWindow()
slist.add(self.tree)
slist.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
box.pack_start(slist, 1, 1, 5)
top.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL)
top.add_button(_('_OK'), Gtk.ResponseType.OK)
top.show_all()
return top
示例11: make_new_model
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def make_new_model(self):
# model contains 4 colums: text to show, place handle, action, color
self.model = Gtk.TreeStore(str, object, object, str)
self.tree.set_model(self.model)
self.populate_tree()
self.tree.expand_all()
示例12: create_layer
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def create_layer(self, lyr_type):
"""
Creates a layer according to the passed layer type.
Depending on the layer-type a different TreeStore, TreeView and layer
object is created. For folders all of them are None. Returns the new
layer object, a TreeStore and a TreeView.
"""
if lyr_type == "plane":
store = Gtk.ListStore(float, float, str)
view = PlaneDataView(store, self.redraw_plot, self.add_feature,
self.settings)
lyr_obj_new = PlaneLayer(store, view)
elif lyr_type == "faultplane":
store = Gtk.ListStore(float, float, float, float, str)
view = FaultPlaneDataView(store, self.redraw_plot, self.add_feature,
self.settings)
lyr_obj_new = FaultPlaneLayer(store, view)
elif lyr_type == "line":
store = Gtk.ListStore(float, float, str)
view = LineDataView(store, self.redraw_plot, self.add_feature,
self.settings)
lyr_obj_new = LineLayer(store, view)
elif lyr_type == "smallcircle":
store = Gtk.ListStore(float, float, float)
view = SmallCircleDataView(store, self.redraw_plot, self.add_feature,
self.settings)
lyr_obj_new = SmallCircleLayer(store, view)
elif lyr_type == "eigenvector":
store = Gtk.ListStore(float, float, float)
view = EigenVectorView(store, self.redraw_plot, self.add_feature,
self.settings)
lyr_obj_new = EigenVectorLayer(store, view)
elif lyr_type == "folder":
store = None
view = None
lyr_obj_new = None
return lyr_obj_new, store, view
示例13: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self, model, view):
assert isinstance(model, LibraryManagerModel)
assert isinstance(view, Gtk.TreeView)
ExtendedController.__init__(self, model, view)
self.tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
view.set_model(self.tree_store)
view.set_tooltip_column(3)
# Gtk TODO: solve via Gtk.TargetList? https://python-gtk-3-tutorial.readthedocs.io/en/latest/drag_and_drop.html
view.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [Gtk.TargetEntry.new('STRING', 0, 0)], Gdk.DragAction.COPY)
self.library_row_iter_dict_by_library_path = {}
self.__expansion_state = None
self.update()
示例14: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self, model, view, tree_view, tree_store, logger=None):
assert isinstance(tree_store, Gtk.TreeStore)
super(TreeViewController, self).__init__(model, view, tree_view, tree_store, logger)
self.tree_store = tree_store
self._changed_id_to = {}
示例15: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeStore [as 别名]
def __init__(self, model, view):
"""Constructor
:param model StateMachineModel should be exchangeable
"""
assert isinstance(model, StateMachineManagerModel)
ExtendedController.__init__(self, model, view)
self.view_is_registered = False
self._mode = 'branch'
self.with_tree = True
self.tree_folded = False
assert self._mode in ['trail', 'branch']
self.history_tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING, GObject.TYPE_STRING)
if view is not None:
view['history_tree'].set_model(self.history_tree_store)
view['history_tree'].set_tooltip_column(8)
# view.set_hover_expand(True)
self.__my_selected_sm_id = None
self._selected_sm_model = None
self.doing_update = False
self.no_cursor_observation = False
self.next_activity_focus_self = True
self.on_toggle_mode_check_gaphas_view_is_meta_data_consistent = True
self.register()