Python gi.repository.Gtk.TreeViewColumn() Examples

The following are 30 code examples of gi.repository.Gtk.TreeViewColumn(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: workspace.py    From badKarma with GNU General Public License v3.0 6 votes vote down vote up
def _search_service(self, widget):
		# search an host in hostlist and hint it

		# get the search value
		keyword = self.services_search.get_text()
		result  = ""

		row = 0
		for service in self.servicestree.get_model():
			if keyword in service[0]:
				break

			row += 1

		# hint the result row
		self.servicestree.row_activated(Gtk.TreePath.new_from_string(str(row)), Gtk.TreeViewColumn(None))
		self.servicestree.set_cursor(Gtk.TreePath.new_from_string(str(row))) 
Example #2
Source File: treeviews.py    From bokken with GNU General Public License v2.0 6 votes vote down vote up
def create_functions_columns(self):

        rendererText = Gtk.CellRendererText()
        rendererText.tooltip_handle = self.connect('motion-notify-event', self.fcn_tooltip)
        rendererPix = Gtk.CellRendererPixbuf()
        self.fcn_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('function.png'))
        self.bb_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('block.png'))
        column = Gtk.TreeViewColumn("Function")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(1)
        self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING)
        self.append_column(column)
        self.set_model(self.store) 
Example #3
Source File: treeviews.py    From bokken with GNU General Public License v2.0 6 votes vote down vote up
def create_relocs_columns(self):

        self.data_sec_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('data-sec.png'))
        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2)
        self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Size", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column) 
Example #4
Source File: editform.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #5
Source File: MediaVerify.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #6
Source File: DenominoViso.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #7
Source File: managers.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def set_column_titles(self, column_titles, column_offset=0, renderers=None):
		"""
		Populate the column names of a GTK TreeView and set their sort IDs. This
		also populates the :py:attr:`.column_titles` attribute.

		:param list column_titles: The titles of the columns.
		:param int column_offset: The offset to start setting column names at.
		:param list renderers: A list containing custom renderers to use for each column.
		:return: A dict of all the :py:class:`Gtk.TreeViewColumn` objects keyed by their column id.
		:rtype: dict
		"""
		self.column_titles.update((v, k) for (k, v) in enumerate(column_titles, column_offset))
		columns = gui_utilities.gtk_treeview_set_column_titles(self.treeview, column_titles, column_offset=column_offset, renderers=renderers)
		for store_id, column_title in enumerate(column_titles, column_offset):
			self.column_views[column_title] = columns[store_id]
		return columns 
Example #8
Source File: ui.py    From runsqlrun with MIT License 6 votes vote down vote up
def _setup_list_page(self, builder):
        page = builder.get_object('page_list')

        store = Gtk.ListStore(str, str, str)
        store.set_sort_column_id(2, Gtk.SortType.ASCENDING)
        self.conn_list = builder.get_object('conn_list')
        column = Gtk.TreeViewColumn(
            'Connection', Gtk.CellRendererText(), markup=1)
        self.conn_list.append_column(column)
        self.conn_list.set_model(store)
        sel = self.conn_list.get_selection()
        sel.connect('changed', self.on_selected_conn_changed)
        self.refresh_connection_list()
        self.conn_list.connect('row-activated', self.on_connlist_row_activated)

        btn_add = builder.get_object('btn_add')
        btn_add.connect('clicked', self.on_add_connection)

        btn_del = builder.get_object('btn_delete')
        btn_del.connect('clicked', self.on_delete_connection)

        btn_edit = builder.get_object('btn_edit')
        btn_edit.connect('clicked', self.on_edit_connection)

        return page 
Example #9
Source File: plot.py    From WattmanGTK with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #10
Source File: backendstree.py    From gtg with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #11
Source File: results.py    From runsqlrun with MIT License 6 votes vote down vote up
def __init__(self):
        super(QueryLog, self).__init__()
        model = Gtk.ListStore(str, Gdk.RGBA)
        self.set_model(model)
        column = Gtk.TreeViewColumn(
            '', Gtk.CellRendererText(), markup=0, foreground_rgba=1)
        self.append_column(column)
        self.set_headers_visible(False)
        self.set_reorderable(False)
        self.set_enable_search(False)
        lbl = Gtk.Label()
        context = lbl.get_style_context()
        self.dimmed_fg = context.get_color(Gtk.StateFlags.INSENSITIVE)
        self.col_error = self.dimmed_fg.copy()
        self.col_error.red = max(self.col_error.red * 1.7, 1)
        self.col_error.green *= 0.7
        self.col_error.blue *= 0.7
        font_desc = Pango.FontDescription.from_string('Ubuntu Mono 12')
        self.modify_font(font_desc) 
Example #12
Source File: pyspc_gui.py    From pyspc with GNU General Public License v3.0 6 votes vote down vote up
def add_treeview(self):
        num_columns = [float for x in range(len(self.data.columns))]

        liststore = Gtk.ListStore(*num_columns)
        for ref in self.data.values.tolist():
            liststore.append(ref)

        treeview = Gtk.TreeView.new_with_model(liststore)
        for i, column_title in enumerate(self.data.columns):
            renderer = Gtk.CellRendererText()
            column = Gtk.TreeViewColumn(column_title, renderer, text=i)
            treeview.append_column(column)

        self.scrollable_treelist = Gtk.ScrolledWindow()
        self.scrollable_treelist.add(treeview)
        self.scrollable_treelist.set_vexpand(True)
        self.scrollable_treelist.set_hexpand(True)
        self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0)
        self.verticalbox.show_all() 
Example #13
Source File: strings_treeview.py    From bokken with GNU General Public License v2.0 6 votes vote down vote up
def create_strings_columns(self):

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Address", rendererText, text=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Size", rendererText, text=1)
        #self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(1)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("String", rendererText, text=2)
        column.set_sort_column_id(2)
        self.append_column(column) 
Example #14
Source File: workspace.py    From badKarma with GNU General Public License v3.0 6 votes vote down vote up
def _search_host(self, widget):
		# search an host in hostlist and hint it

		# get the search value
		keyword = self.host_search.get_text()
		result  = ""

		row = 0
		for host in self.hosttree.get_model():
			if keyword in host[1]:
				break

			row += 1

		# hint the result row
		self.hosttree.row_activated(Gtk.TreePath.new_from_string(str(row)), Gtk.TreeViewColumn(None))
		self.hosttree.set_cursor(Gtk.TreePath.new_from_string(str(row))) 
Example #15
Source File: widgets.py    From badKarma with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, database, host, *args, **kwargs):
		super(PortsTree, self).__init__(*args, **kwargs)
		""" Single host ports treeview class """

		self.set_model(Gtk.ListStore(GdkPixbuf.Pixbuf, int, str, str, str, str, str, int))
		self.port_liststore = self.get_model()
		
		for i, column_title in enumerate(["#","Port", "State", "Type", "Service", "Banner", "Fingerprint"]):
			if i == 0:

				renderer = Gtk.CellRendererPixbuf()
				column = Gtk.TreeViewColumn(column_title, renderer, pixbuf=0)
			else:
				renderer = Gtk.CellRendererText()
				column = Gtk.TreeViewColumn(column_title, renderer, text=i)

			self.append_column(column)

		self.show_all()

		self.database = database
		self.host     = host

		self.refresh(self.database, self.host) 
Example #16
Source File: gtk3ui.py    From deluge-webapi with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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() 
Example #17
Source File: completions.py    From vimiv with MIT License 6 votes vote down vote up
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) 
Example #18
Source File: io_data_port_list.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
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 
Example #19
Source File: modification_history.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
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' 
Example #20
Source File: semantic_data_editor.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
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']) 
Example #21
Source File: tree.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def make_column_title_elllipsable(column, title=None, tooltip=None):
        """Replaces the column title widget with a similar title widget allowing to be ellipsized

        :param Gtk.TreeViewColumn column: The column to be modified
        :param str title: Optional new title, if not set, the current title will be used
        :param str tooltip: Optional tooltip, if not set, no tooltip will be set
        """
        title = title or column.get_title()
        label = Gtk.Label(label=title)
        if tooltip:
            label.set_tooltip_text(tooltip)
        label.set_ellipsize(Pango.EllipsizeMode.END)
        label.set_width_chars(1)
        label.show()
        column.set_widget(label)
        column.set_expand(True) 
Example #22
Source File: file_parser.py    From innstereo with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #23
Source File: gui_utilities.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def gtk_treeview_set_column_titles(treeview, column_titles, column_offset=0, renderers=None):
	"""
	Populate the column names of a GTK TreeView and set their sort IDs.

	:param treeview: The treeview to set column names for.
	:type treeview: :py:class:`Gtk.TreeView`
	:param list column_titles: The names of the columns.
	:param int column_offset: The offset to start setting column names at.
	:param list renderers: A list containing custom renderers to use for each column.
	:return: A dict of all the :py:class:`Gtk.TreeViewColumn` objects keyed by their column id.
	:rtype: dict
	"""
	columns = {}
	for column_id, column_title in enumerate(column_titles, column_offset):
		renderer = renderers[column_id - column_offset] if renderers else Gtk.CellRendererText()
		if isinstance(renderer, Gtk.CellRendererToggle):
			column = Gtk.TreeViewColumn(column_title, renderer, active=column_id)
		elif hasattr(renderer.props, 'python_value'):
			column = Gtk.TreeViewColumn(column_title, renderer, python_value=column_id)
		else:
			column = Gtk.TreeViewColumn(column_title, renderer, text=column_id)
		column.set_property('min-width', 25)
		column.set_property('reorderable', True)
		column.set_property('resizable', True)
		column.set_sort_column_id(column_id)
		treeview.append_column(column)
		columns[column_id] = column
	return columns 
Example #24
Source File: workspace.py    From badKarma with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, database):
		builder	 = Gtk.Builder() # glade
		builder.add_from_file(os.path.dirname(os.path.abspath(__file__)) + "/../assets/ui/hostlist.glade")

		self.database = database

		self.services_search = builder.get_object("hosts_search")
		self.services_list	 = builder.get_object("hostlist")
		self.services_box    = builder.get_object("host-box")

		self.services_search.connect("search-changed", self._search_service)

		self.services_liststore = Gtk.ListStore(str)

		#creating the treeview, making it use the filter as a model, and adding the columns
		self.servicestree = Gtk.TreeView(model=self.services_liststore) #.new_with_model(self.language_filter)
		for i, column_title in enumerate(["service"]):
			renderer = Gtk.CellRendererText()
			column = Gtk.TreeViewColumn(column_title, renderer, text=i)
			
		self.servicestree.append_column(column)


		self.services_list.add(self.servicestree)
		
		#self.servicestree.show()
		self.services_box.show()
		self.out_of_scope = True

		self.servicestree.props.activate_on_single_click = True

		self.refresh(self.database) 
Example #25
Source File: widgets.py    From badKarma with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, database, service, *args, **kwargs):
		super(ServicesTree, self).__init__(*args, **kwargs)
		""" Single service ports treeview class """

		self.database = database
		self.service = service

		self.set_model(Gtk.ListStore(GdkPixbuf.Pixbuf, int, str, str, str, str, str, int))
		self.port_liststore = self.get_model()

		for i, column_title in enumerate(["#","Port", "State", "Type", "Host", "Banner", "Fingerprint"]):
			if i == 0:

				renderer = Gtk.CellRendererPixbuf()
				column = Gtk.TreeViewColumn(column_title, renderer, pixbuf=0)
			else:
				renderer = Gtk.CellRendererText()
				column = Gtk.TreeViewColumn(column_title, renderer, text=i)

			self.append_column(column)

		# multi selection
		selection = self.get_selection()
		selection.set_mode(Gtk.SelectionMode.MULTIPLE)

		#self.refresh(self.database, self.host) 
Example #26
Source File: treeviews.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
def create_tree(self, imps):
        # Create the column
        imports = Gtk.TreeViewColumn()
        imports.set_title("Imports")
        imports.set_spacing(5)

        self.treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str)

        self.imp_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('import.png'))
        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        imports.pack_start(rendererPix, False)
        imports.pack_start(rendererText, True)
        imports.set_attributes(rendererText, text=1)
        imports.set_attributes(rendererPix, pixbuf=0)

        # Iterate imports and add to the tree
        for element in imps.keys():
            it = self.treestore.append(None, [self.fcn_pix, element])
            for imp in imps[element]:
                self.treestore.append(it, [self.imp_pix, imp[0] + '\t' + imp[1]])

        # Add column to tree
        self.append_column(imports)
        self.set_model(self.treestore)
        self.expand_all() 
Example #27
Source File: recipe-578773.py    From code with MIT License 5 votes vote down vote up
def __init__(self):

        Gtk.Window.__init__(self, title='My Window Title')
        self.connect('delete-event', Gtk.main_quit)        
        
        store = Gtk.ListStore(str, str)
        self.populate_store(store)
        
        self.treeview = Gtk.TreeView(model=store)

        renderer = Gtk.CellRendererText()
        
        column_name = Gtk.TreeViewColumn('Song Name', renderer, text=0)
        column_name.set_sort_column_id(0)        
        self.treeview.append_column(column_name)
        
        column_artist = Gtk.TreeViewColumn('Artist', renderer, text=1)
        column_artist.set_sort_column_id(1)
        self.treeview.append_column(column_artist)
        
        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(
            Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(self.treeview)
        scrolled_window.set_min_content_height(200)
        
        button = Gtk.Button('Delete Selected Row')
        button.connect('clicked', self.on_button_clicked) 

        box = Gtk.Box()
        box.pack_start(scrolled_window, True, True, 1)
        box.pack_start(button, False, False, 1)

        self.add(box)
        self.show_all() 
Example #28
Source File: ObjectCollection.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self):

        ### Icons for the list view
        self.icons = {}
        for kind in ObjectCollection.icon_files:
            self.icons[kind] = GdkPixbuf.Pixbuf.new_from_file(ObjectCollection.icon_files[kind])

        ### GUI List components
        ## Model
        self.store = Gtk.ListStore(FlatCAMObj)

        ## View
        self.view = Gtk.TreeView(model=self.store)
        #self.view.connect("row_activated", self.on_row_activated)
        self.tree_selection = self.view.get_selection()
        self.change_subscription = self.tree_selection.connect("changed", self.on_list_selection_change)

        ## Renderers
        # Icon
        renderer_pixbuf = Gtk.CellRendererPixbuf()
        column_pixbuf = Gtk.TreeViewColumn("Type", renderer_pixbuf)

        def _set_cell_icon(column, cell, model, it, data):
            obj = model.get_value(it, 0)
            cell.set_property('pixbuf', self.icons[obj.kind])

        column_pixbuf.set_cell_data_func(renderer_pixbuf, _set_cell_icon)
        self.view.append_column(column_pixbuf)

        # Name
        renderer_text = Gtk.CellRendererText()
        column_text = Gtk.TreeViewColumn("Name", renderer_text)

        def _set_cell_text(column, cell, model, it, data):
            obj = model.get_value(it, 0)
            cell.set_property('text', obj.options["name"])

        column_text.set_cell_data_func(renderer_text, _set_cell_text)
        self.view.append_column(column_text) 
Example #29
Source File: uistuff.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def appendAutowrapColumn(treeview, name, **kvargs):
    cell = Gtk.CellRendererText()
    # cell.props.wrap_mode = Pango.WrapMode.WORD
    # TODO:
    # changed to ellipsize instead until "never ending grow" bug gets fixed
    # see https://github.com/pychess/pychess/issues/1054
    cell.props.ellipsize = Pango.EllipsizeMode.END
    column = Gtk.TreeViewColumn(name, cell, **kvargs)
    treeview.append_column(column)

    def callback(treeview, allocation, column, cell):
        otherColumns = [c for c in treeview.get_columns() if c != column]
        newWidth = allocation.width - sum(c.get_width() for c in otherColumns)

        hsep = GObject.Value()
        hsep.init(GObject.TYPE_INT)
        hsep.set_int(0)
        treeview.style_get_property("horizontal-separator", hsep)
        newWidth -= hsep.get_int() * (len(otherColumns) + 1) * 2
        if cell.props.wrap_width == newWidth or newWidth <= 0:
            return
        cell.props.wrap_width = newWidth
        store = treeview.get_model()
        store_iter = store.get_iter_first()
        while store_iter and store.iter_is_valid(store_iter):
            store.row_changed(store.get_path(store_iter), store_iter)
            store_iter = store.iter_next(store_iter)
        treeview.set_size_request(0, -1)
    # treeview.connect_after("size-allocate", callback, column, cell)

    scroll = treeview.get_parent()
    if isinstance(scroll, Gtk.ScrolledWindow):
        scroll.set_policy(Gtk.PolicyType.NEVER, scroll.get_policy()[1])

    return cell 
Example #30
Source File: context.py    From runsqlrun with MIT License 5 votes vote down vote up
def __init__(self, worksheet):
        super(EditorContext, self).__init__(
            orientation=Gtk.Orientation.VERTICAL)
        self.worksheet = worksheet

        self.set_size_request(200, 200)
        self.set_border_width(6)
        self.set_spacing(6)

        self.lbl_conn = Gtk.Label('')
        self.lbl_conn.set_xalign(0)
        self.pack_start(self.lbl_conn, False, True, 0)

        self.lst_statements = Gtk.TreeView()
        renderer = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.MIDDLE)
        column = Gtk.TreeViewColumn("Statements", renderer, text=0)
        self.lst_statements.append_column(column)
        self.lst_statements_model = Gtk.ListStore(str, object)
        self.lst_statements.set_model(self.lst_statements_model)
        self.pack_start(self.lst_statements, True, True, 0)
        self.lst_statements.connect(
            'row-activated', self.on_statement_row_activated)

        self.browser = Gtk.TreeView()
        renderer = Gtk.CellRendererText(
            ellipsize=Pango.EllipsizeMode.MIDDLE)
        column = Gtk.TreeViewColumn("Tables / Views", renderer, text=0)
        self.browser.append_column(column)
        self.browser_model = Gtk.ListStore(str)
        self.browser.set_model(self.browser_model)
        self.pack_start(self.browser, True, True, 0)

        self.worksheet.connect(
            'connection-changed', self.on_connection_changed)
        self.on_connection_changed(worksheet)

        self.worksheet.editor.connect(
            'statements-changed', self.on_statements_changed)