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


Python Gtk.TreeView方法代码示例

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


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

示例1: load_campaigns

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def load_campaigns(self):
		"""Load campaigns from the remote server and populate the :py:class:`Gtk.TreeView`."""
		store = self._model
		store.clear()
		campaigns = self.application.rpc.graphql_find_file('get_campaigns.graphql')
		for campaign in campaigns['db']['campaigns']['edges']:
			campaign = campaign['node']
			company = campaign['company']['name'] if campaign['company'] else None
			created_ts = utilities.datetime_utc_to_local(campaign['created'])
			created_ts = utilities.format_datetime(created_ts)
			campaign_type = campaign['campaignType']['name'] if campaign['campaignType'] else None
			expiration_ts = campaign['expiration']
			if expiration_ts is not None:
				expiration_ts = utilities.datetime_utc_to_local(expiration_ts)
				expiration_ts = utilities.format_datetime(expiration_ts)
			store.append((
				campaign['id'],
				False,
				campaign['name'],
				company,
				campaign_type,
				campaign['user']['name'],
				created_ts,
				expiration_ts
			)) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:27,代码来源:compare_campaigns.py

示例2: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def __init__(self, treeview, selection_mode=None, cb_delete=None, cb_refresh=None):
		"""
		:param treeview: The treeview to wrap and manage.
		:type treeview: :py:class:`Gtk.TreeView`
		:param selection_mode: The selection mode to set for the treeview.
		:type selection_mode: :py:class:`Gtk.SelectionMode`
		:param cb_delete: An optional callback that can be used to delete entries.
		:type cb_delete: function
		"""
		self.treeview = treeview
		"""The :py:class:`Gtk.TreeView` instance being managed."""
		self.cb_delete = cb_delete
		"""An optional callback for deleting entries from the treeview's model."""
		self.cb_refresh = cb_refresh
		"""An optional callback for refreshing the data in the treeview's model."""
		self.column_titles = collections.OrderedDict()
		"""An ordered dictionary of storage data columns keyed by their respective column titles."""
		self.column_views = {}
		"""A dictionary of column treeview's keyed by their column titles."""
		self.treeview.connect('key-press-event', self.signal_key_press_event)
		if selection_mode is None:
			selection_mode = Gtk.SelectionMode.SINGLE
		treeview.get_selection().set_mode(selection_mode)
		self._menu_items = {} 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:26,代码来源:managers.py

示例3: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def __init__(self, uistate, data, parent):
        super().__init__(uistate, [], self)
        self.window = Gtk.Dialog()
        self.set_window(self.window, None, _("Database Information"))
        self.window.set_modal(True)
        self.ok = self.window.add_button(_('_OK'), Gtk.ResponseType.OK)
        self.ok.connect('clicked', self.on_ok_clicked)
        self.window.set_position(Gtk.WindowPosition.CENTER)
        self.window.set_default_size(600, 400)
        s = Gtk.ScrolledWindow()
        titles = [
            (_('Setting'), 0, 150),
            (_('Value'), 1, 400)
        ]
        treeview = Gtk.TreeView()
        model = Gtk.ListModel(treeview, titles)
        for key, value in sorted(data.items()):
            model.add((key, str(value),), key)
        s.add(treeview)
        self.window.vbox.pack_start(s, True, True, 0)
        if parent:
            self.window.set_transient_for(parent)
        self.show() 
开发者ID:gramps-project,项目名称:addons-source,代码行数:25,代码来源:libtmg.py

示例4: build_gui

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def build_gui(self):
        """
        Build the GUI interface.
        """
        tip = _('Double-click on a row to edit the selected event.')
        self.set_tooltip(tip)
        top = Gtk.TreeView()
        titles = [('', NOSORT, 50,),
                  (_('Type'), 1, 100),
                  (_('Date'), 3, 100),
                  ('', 3, 100),
                  (_('Age'), 4, 35),
                  (_('Where Born'), 5, 160),
                  (_('Condition'), 6, 75),
                  (_('Occupation'), 7, 160),
                  (_('Residence'), 8, 160)]
        self.model = ListModel(top, titles, event_func=self.edit_event)
        return top 
开发者ID:gramps-project,项目名称:addons-source,代码行数:20,代码来源:Overview.py

示例5: build_interface

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [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

示例6: create_tab

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [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

示例7: build_gui

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [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

示例8: create_treeview

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [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

示例9: parse_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def parse_file(self, start_line=0):
        """
        Parses the file according to the settings and updates the TreeView.

        The old parsing result are cleared from the TreeStore. Then each
        row of the file is re-iterated and all rows before the starting
        row are omitted. The rows are passed to the append_data-method.
        """
        self.store.clear()
        parse_file = open(self.file, "r")
        for key, line in enumerate(parse_file):
            if key < start_line:
                continue
            else:
                line = line.rstrip()
                string_list = re.split(r"[;,]", line)
                self.append_data(string_list) 
开发者ID:innstereo,项目名称:innstereo,代码行数:19,代码来源:file_parser.py

示例10: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def __init__(self, store, redraw_plot, add_feature, settings):
        """
        Initializes the treeview. Requires a model and the main window
        redraw-function. Sets selection mode to MULTIPLE. Connect the
        key-press event.
        """
        Gtk.TreeView.__init__(self, model=store)
        self.store = store
        self.lyr_obj = None
        self.redraw = redraw_plot
        self.add_feature = add_feature
        self.settings = settings
        self.select = self.get_selection()
        self.select.set_mode(Gtk.SelectionMode.MULTIPLE)
        self.connect("key-press-event", self.on_key_pressed)
        self.select.connect("changed", self.data_selection_changed) 
开发者ID:innstereo,项目名称:innstereo,代码行数:18,代码来源:dataview_classes.py

示例11: __init__

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

示例12: _activate

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def _activate(self, treeview, path, column):
        """Enter the completion text of the treeview into the commandline.

        Args:
            treeview: TreeView that was activated.
            path: Activated TreePath.
            column: Activated TreeViewColumn.
        """
        if treeview:
            count = path.get_indices()[0]
            self._app["commandline"].grab_focus()
        else:
            count = self._tab_position
        comp_type = self._get_comp_type()
        row = self._liststores[comp_type][1][count]
        self._app["commandline"].set_text(":" + self._prefixed_digits + row[0])
        self._app["commandline"].set_position(-1) 
开发者ID:karlch,项目名称:vimiv,代码行数:19,代码来源:completions.py

示例13: file_select

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def file_select(self, treeview, path, column, close):
        """Show image or open directory for activated file in library.

        Args:
            treeview: The Gtk.TreeView which emitted the signal.
            path: Gtk.TreePath that was activated.
            column: Column that was activated.
            close: If True close the library when finished.
        """
        # Empty directory
        if not path:
            self._app["statusbar"].message("No file to select", "error")
            return
        count = path.get_indices()[0]
        fil = self.files[count]
        self[os.getcwd()] = fil
        if os.getcwd() == self._app["tags"].directory:
            self._tag_select(fil, close)
        elif os.path.isdir(fil):  # Open directory
            self.move_up(fil)
        else:
            self._image_select(fil, close) 
开发者ID:karlch,项目名称:vimiv,代码行数:24,代码来源:library.py

示例14: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [as 别名]
def __init__(self, model, columns):
		Gtk.Frame.__init__(self)
		self.perform_scroll = False
		self.model = model
		self.columns = columns
		self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
		self.add(self.vbox)
		## ScrolledWindow
		scrolled_window = Gtk.ScrolledWindow()
		self.vbox.pack_start(scrolled_window, True, True, 0)
		# TreeView
		self.tree_view = Gtk.TreeView(model)
		scrolled_window.add(self.tree_view)
		for column in columns:
			self.tree_view.append_column(column)
		self.tree_view.connect('size-allocate', self.scroll_tree_view)
		self.selection = self.tree_view.get_selection()
		self.selection.set_mode(Gtk.SelectionMode.SINGLE) 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:20,代码来源:custom.py

示例15: populate_tree

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeView [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 
开发者ID:inguma,项目名称:bokken,代码行数:22,代码来源:cheatsheet_dialog.py


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