Problem with arguments in the connect_signals function

1

I have read several tutorials and can not figure out why the below error is being shown, I suspect there is some problem with syntax. Thanks if anyone can answer:

Message:

    root@kaliJRA:~/Documentos/phyton_learning# python3 teste.py
    Traceback (most recent call last):
    File "teste.py", line 49, in <module>
    app = InverterApp()
    File "teste.py", line 18, in __init__
    "on_button_invert_clicked": self.invert_url,                         
    AttributeError: 'InverterApp' object has no attribute 'invert_url'

Code:

    #!/usr/bin/env python
    #-*- coding: utf-8 -*-

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

    class InverterApp(object):
         def __init__(self):
             builder = Gtk.Builder()
             builder.add_from_file("inverter.glade")
             self.window = builder.get_object("janela1")
             self.text_area = builder.get_object("text_entry")
             self.about = builder.get_object("about_dialog")
             self.window.show()

             Gtk.Builder.connect_signals({"Gtk_main_quit": Gtk.main_quit,
                    "on_button_invert_clicked": self.invert_url,                         
                    "on_text_entry_activate": self.invert_url,                          
                    "on_Copiar_activate": self.copy_text,                           
                    "on_Colar_activate": self.paste_text,                            
                    "on_Apagar_activate": self.delete_text,                           
                    "on_Sobre_activate": self.about_window })

             def invert_url(self, widget):       
                    url = self.text_area.get_text()
                    url = url[::-1]
                    self.text_area.set_text(url)

             def copy_text(self, widget):
                    clipboard = Gtk.clipboard_get()
                    url = self.text_area.get_text()
                    clipboard.set_text(url)
                    clipboard.store()         

             def paste_text(self, widget):
                    clipboard = Gtk.clipboard_get()
                    url = clipboard.wait_for_text()
                    self.text_area.set_text(url)         

             def delete_text(self, widget):
                    self.text_area.set_text("")         

             def about_window(self, widget):
                    self.about.run()
                    self.about.hide()    

             if __name__ == "__main__":
             app = InverterApp()
             Gtk.main() 
    
asked by anonymous 13.07.2017 / 01:05

0 answers