当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.ListStore方法代码示例

本文整理汇总了Python中gi.repository.Gtk.ListStore方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.ListStore方法的具体用法?Python Gtk.ListStore怎么用?Python Gtk.ListStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gtk的用法示例。


在下文中一共展示了Gtk.ListStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def __init__(self, **kwargs):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        GObject.GObject.__init__(self)

        self.is_edit = kwargs.get("edit", False)
        self._account = kwargs.get("account", None)

        self._providers_store = Gtk.ListStore(str, str)

        self.logo_img = Gtk.Image()
        self.username_entry = Gtk.Entry()
        self.provider_combo = Gtk.ComboBox.new_with_model_and_entry(
            self._providers_store)
        self.token_entry = Gtk.Entry()
        self._build_widgets()
        self._fill_data() 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:18,代码来源:add.py

示例2: glib_idle_add_store_extend

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [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) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:20,代码来源:gui_utilities.py

示例3: gtk_list_store_search

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def gtk_list_store_search(list_store, value, column=0):
	"""
	Search a :py:class:`Gtk.ListStore` for a value and return a
	:py:class:`Gtk.TreeIter` to the first match.

	:param list_store: The list store to search.
	:type list_store: :py:class:`Gtk.ListStore`
	:param value: The value to search for.
	:param int column: The column in the row to check.
	:return: The row on which the value was found.
	:rtype: :py:class:`Gtk.TreeIter`
	"""
	for row in list_store:
		if row[column] == value:
			return row.iter
	return None 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:18,代码来源:gui_utilities.py

示例4: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def __init__(self, *args, **kwargs):
		super(ClonePageDialog, self).__init__(*args, **kwargs)
		self.resources = Gtk.ListStore(*tuple(column.g_type for column in self.view_columns))
		treeview = self.gobjects['treeview_resources']
		treeview.set_model(self.resources)
		self.treeview_manager = managers.TreeViewManager(treeview)
		self.treeview_manager.set_column_titles(
			tuple(column.title for column in self.view_columns),
			renderers=tuple(column.cell_renderer() for column in self.view_columns)
		)
		self.popup_menu = self.treeview_manager.get_popup_menu()

		self.button_cancel = self.gobjects['button_cancel']
		self.entry_directory = self.gobjects['entry_clone_directory']
		# managed separately to be kept out of the config
		self.entry_target = self.gtk_builder_get('entry_target')
		self.label_status = self.gobjects['label_status']
		self.spinner_status = self.gobjects['spinner_status'] 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:20,代码来源:clone_page.py

示例5: set_emulation_modes

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def set_emulation_modes(self, modes, startup = False):
        if startup:
            if modes == None:
                self.emulation_mode_combobox.set_sensitive(False)
                return
            else:
                self.emulation_mode_combobox.set_sensitive(True)
        model = self.emulation_mode_combobox.get_model()
        if model == None:
            model = Gtk.ListStore(str, str)
        else:
            self.emulation_mode_combobox.set_model(None)
            model.clear()
        for key, values in enumerate(modes):
            model.append(values[:2])
            if values[2]:
                self.emulation_mode_combobox.set_active(key)
        self.emulation_mode_combobox.set_model(model) 
开发者ID:berarma,项目名称:oversteer,代码行数:20,代码来源:gtk_ui.py

示例6: build_interface

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [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) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:26,代码来源:editform.py

示例7: create_tab

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [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) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:26,代码来源:MediaVerify.py

示例8: build_gui

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def build_gui(self):
        """
        Build the GUI interface.
        """
        tip = _("Click name to change active\n"
                "Double-click name to edit")
        self.set_tooltip(tip)
        top = Gtk.TreeView()
        top.connect('button-press-event', self._button_press)
        renderer = Gtk.CellRendererText()
        renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        column = Gtk.TreeViewColumn(_('Person'), renderer, text=0)
        column.set_expand(True)
        column.set_resizable(True)
        column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
        column.set_sort_column_id(0)
        top.append_column(column)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_('Descendants'), renderer, text=1)
        column.set_sort_column_id(1)
        top.append_column(column)
        self.model = Gtk.ListStore(str, int, str)
        top.set_model(self.model)
        return top 
开发者ID:gramps-project,项目名称:addons-source,代码行数:26,代码来源:DescendantCount.py

示例9: create_lstore

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def create_lstore(self,list_of_lists):
        lstore_args = []
        for cell in list_of_lists[0]:
            if type(cell) == type("string"):
                lstore_args.append(GObject.TYPE_STRING)
            elif type(cell) == type(1):
                lstore_args.append(GObject.TYPE_UINT)
            elif type(cell) == type(False):
                lstore_args.append(GObject.TYPE_BOOLEAN)
            else:
                raise TypeError("%s" % type(cell))
        lstore = Gtk.ListStore(*lstore_args)
        for row in list_of_lists:
            iter = lstore.append()
            index_values = []
            for i,v in enumerate(row):
                index_values.append(i)
                index_values.append(v)
            lstore.set(iter,*index_values)
        return lstore 
开发者ID:gramps-project,项目名称:addons-source,代码行数:22,代码来源:DenominoViso.py

示例10: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [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) 
开发者ID:BoukeHaarsma23,项目名称:WattmanGTK,代码行数:27,代码来源:handler.py

示例11: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def __init__(self, tree):
        """ Initialize entry completion

        Create a list store which is connected to a LibLarch and
        kept updated. """
        super().__init__()

        self.tags = Gtk.ListStore(str)

        tree = tree.get_basetree()
        tree.add_filter(FILTER_NAME, tag_filter, {'flat': True})
        tag_tree = tree.get_viewtree('tag_completion', False)
        tag_tree.register_cllbck('node-added-inview', self._on_tag_added)
        tag_tree.register_cllbck('node-deleted-inview', self._on_tag_deleted)
        tag_tree.apply_filter(FILTER_NAME)

        self.set_model(self.tags)
        self.set_text_column(0)
        self.set_match_func(tag_match, 0)
        self.set_inline_completion(True)
        self.set_inline_selection(True)
        self.set_popup_single_match(False) 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:24,代码来源:tag_completion.py

示例12: __load_icon

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def __load_icon(self):
        """
        Loads emblem icons from the current icon theme

        Sometimes an icon can't be loaded because of a bug in system
        libraries, e.g. bug #1079587. Gracefuly degradate and skip
        the loading of a corrupted icon.
        """
        self.symbol_model = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
        for icon in Gtk.IconTheme.get_default().list_icons(context="Emblems"):
            try:
                img = Gtk.IconTheme.get_default().load_icon(icon, 16, 0)
                self.symbol_model.append([img, icon])
            except GObject.GError:
                log.error(f"Failed to load icon '{icon}'")
        self.symbol_iv.set_model(self.symbol_model)
        self.loaded = True

    # PUBLIC IF ##### 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:21,代码来源:tag_editor.py

示例13: create_treeview

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [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() 
开发者ID:innstereo,项目名称:innstereo,代码行数:23,代码来源:file_parser.py

示例14: _default_value_cell_data_func

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def _default_value_cell_data_func(self, tree_view_column, cell, model, iter, data=None):
        """Function set renderer properties for every single cell independently

        The function controls the editable and color scheme for every cell in the default value column according
        the use_runtime_value flag and whether the state is a library state.

        :param tree_view_column: the Gtk.TreeViewColumn to be rendered
        :param cell: the current CellRenderer
        :param model: the Gtk.ListStore or TreeStore that is the model for TreeView
        :param iter: an iterator over the rows of the TreeStore/Gtk.ListStore Model
        :param data: optional data to be passed: see http://dumbmatter.com/2012/02/some-notes-on-porting-from-pygtk-to-pygobject/
        """
        if isinstance(self.model.state, LibraryState):
            use_runtime_value = model.get_value(iter, self.USE_RUNTIME_VALUE_STORAGE_ID)
            if use_runtime_value:
                cell.set_property("editable", True)
                cell.set_property('text', model.get_value(iter, self.RUNTIME_VALUE_STORAGE_ID))
                cell.set_property('foreground', "white")
            else:
                cell.set_property("editable", False)
                cell.set_property('text', model.get_value(iter, self.DEFAULT_VALUE_STORAGE_ID))
                cell.set_property('foreground', "dark grey")

        return 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:26,代码来源:io_data_port_list.py

示例15: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ListStore [as 别名]
def __init__(self, model, view):
        assert isinstance(model, AbstractStateModel)
        # initiate data base and tree
        # id, name, to-state, to-outcome, name-color, to-state-color, outcome, state, outcome_model
        list_store = Gtk.ListStore(int, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT,
                                   GObject.TYPE_PYOBJECT)
        super(StateOutcomesListController, self).__init__(model, view, view['tree_view'], list_store, logger)

        self.to_state_combo_list = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
        self.to_outcome_combo_list = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
        # key-outcome_id -> label,  to_state_id,  transition_id
        self.dict_to_other_state = {}
        # key-outcome_id ->  label,  to_outcome_id,  transition_id
        self.dict_to_other_outcome = {}
        # not used at the moment key-outcome_id -> label,  from_state_id,  transition_id
        self.dict_from_other_state = {}  # if widget gets extended
        # TODO check why the can happen should not be handed always the LibraryStateModel
        if not (model.state.is_root_state or model.state.is_root_state_of_library):
            self.observe_model(model.parent)

        if self.model.get_state_machine_m() is not None:
            self.observe_model(self.model.get_state_machine_m())
        else:
            logger.warning("State model has no state machine model -> state model: {0}".format(self.model)) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:26,代码来源:outcomes.py


注:本文中的gi.repository.Gtk.ListStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。