Buttons in a Gtk.CellRenderer

0

I'm trying to make a program that saves some information in a DB, I can display the information in the window without any problem, however I wanted to add 2 buttons per line one "Edit" and another "Delete", however there is no " CellRedererButton "only" spin, spinner, toggle, radio ", I would like to know how I can add this button since there is no method to do this

Login.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Python 3 GTK+ 3

Arquivo LoginWin.py
"""
import gi

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from Index import Index


class LoginWin(Gtk.Window):
    def __init__(self):
        super().__init__()
        # Título da janela.
        self.set_title('Tela de login')
        # Definindo o ícone da janela (caminho relativo ou absoluto).
        # self.set_default_icon_from_file('../../_static/favicon.png')
        # Tamanho da janela.
        self.set_default_size(1366 / 2, 768 / 2)
        # Posição em que a janela será iniciada.
        self.set_position(Gtk.WindowPosition.CENTER)
        # Definindo uma borda entre a janela principal e o container (Grid layout).
        self.set_border_width(10)

        # Grid
        grid = Gtk.Grid.new()
        grid.set_row_spacing(10)
        self.add(grid)

        self.login_txt = Gtk.Entry.new()
        self.login_txt.set_placeholder_text('Login')

        self.senha_txt = Gtk.Entry.new()
        self.senha_txt.set_placeholder_text('Senha')

        self.login_btn = Gtk.Button.new_with_label('Login')
        self.login_btn.connect('clicked', self.login)
        self.set_focus(self.login_btn)

        grid.add(self.login_txt)
        grid.attach_next_to(self.senha_txt, self.login_txt, Gtk.PositionType.BOTTOM, 1, 2)
        grid.attach_next_to(self.login_btn, self.senha_txt, Gtk.PositionType.BOTTOM, 1, 2)



        # sqlite

    def login(self, widget):
        # Escondendo a janela.
        # self.set_visible(False)
        self.hide()

        # Exibindo a outra janela e passando pra ela LoginWin(Gtk.Window).
        # Isso porque vamos precisar exibir essa janela de novo.
        Index(parent=self).show_all()


if __name__ == '__main__':
    win = LoginWin()
    win.connect('destroy', Gtk.main_quit)
    win.show_all()
    Gtk.main()

Index.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Python 3 GTK+ 3.

Arquivo Index.py.

    """
    import gi

    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk

    result_list = [(1, "Pegasus", "g****@.com", "password", "Conta", False, False),
                   (2, "gseganzrla", "g.*@.com", "senha", "Conta", False, False)]


    class Index(Gtk.Window):
        def __init__(self, parent):
            """Construtor.

            :param parent: Está recebendo LoginWin(Gtk.Window).
            """
            super().__init__()
            self.set_title('Table')
            # self.set_default_icon_from_file('../../_static/favicon.png')
            self.set_default_size(1366 / 2, 768 / 2)
            self.set_position(Gtk.WindowPosition.CENTER)
            self.set_border_width(10)

            # Atribuindo parent (LoginWin(Gtk.Window) em uma variável.
            self.parent = parent

            # Widges.
            self.grid = Gtk.Grid()
            self.grid.set_column_homogeneous(True)
            self.grid.set_row_homogeneous(True)
            self.add(self.grid)

            self.box = Gtk.Box()
            self.list_button = Gtk.Button()

            # Criando listsore
            self.result_liststore = Gtk.ListStore(int, str, str, str, str, bool, bool)
            for result_ref in result_list:
                self.result_liststore.append(list(result_ref))
                print("Resultado {}".format(result_ref))

            self.treeview = Gtk.TreeView(model=self.result_liststore)
            self.buton = Gtk.Button()
            for i, column_title in enumerate(["ID", "Usuario", "Email", "Senha", "Conta", "Editar", "Apagar"]):
                renderer = Gtk.CellRendererText()
                column = Gtk.TreeViewColumn(column_title, renderer, text=i)
                self.treeview.append_column(column)

            # sesson_destroy()
            self.session_destroy = Gtk.Button.new_with_label("Seasson Destroy")
            self.session_destroy.connect("clicked", self.encerrar_sessao)

            self.fechar = Gtk.Button(label="Fechar")
            self.fechar.connect("clicked", Gtk.main_quit)

            self.scrollable_treelist = Gtk.ScrolledWindow()
            self.scrollable_treelist.set_vexpand(True)
            self.grid.attach(self.scrollable_treelist, 0, 0, 8, 10)
            self.grid.attach_next_to(self.session_destroy, self.scrollable_treelist, Gtk.PositionType.BOTTOM, 1, 1)
            self.grid.attach_next_to(self.fechar, self.session_destroy, Gtk.PositionType.RIGHT, 1, 1)

            self.scrollable_treelist.add(self.treeview)

            self.show_all()


        def encerrar_sessao(self, widget):
            print('Encerrando a sessão')

            # Escondendo a janela.
            # self.set_visible(False)
            # self.hide()

            # Destruindo a janela.
            self.destroy()

            # Exibindo a tela de login (LoginWin(Gtk.Window)).
            # self.parent.set_visible(True)
            self.parent.show_all()

        def close(self, widget):
            print('Fechando aplicativo')

            # Encerrando o aplicativo.
            Gtk.main_quit()
    
asked by anonymous 30.09.2018 / 19:15

0 answers