Attributeerror('Handler %s not found') python3 gtk3

Asked

Viewed 60 times

1

I recently made a code in python3.x and for the interface I used a file . However when I execute the code the interface opens but does not perform any action and interpreter returns me the error "Attributeerror: Handler Gtk_main_quit not found" and so for all other functions of the code. Python:

`#!/usr/bin/python3
# coding: utf-8

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


class InverterApp():
    def __init__(self):

        builder = Gtk.Builder()
        builder.add_from_file("Inverter.glade")

    #Obter a janela principal
        self.window = builder.get_object("window1")

    # Obtendo o widget text_entry (a área de texto do nosso programa) pois
    # iremos utiliza-la nas funções de inversão da URL e para adicionar o a
    # URL já invertida
        self.text_area = builder.get_object("text_entry")

    # Obtendo o widget about_dialog (janelinha com as informações do programa)
        self.about = builder.get_object("about_dialog")

    #Exibe a janela do programa
        self.window.show_all()

        builder.connect_signals({"gtk_main_quit": Gtk.main_quit,
                            "on_button_invert_clicked": self.invert_url,
                            "on_text_entry_activate": self.invert_url,
                            "on_copy_activate": self.copy_text,
                            "on_paste_activate": self.paste_text,
                            "on_delete_activate": self.delete_text,
                            "on_about_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()`

Code Glade:

`<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
  <requires lib="gtk+" version="3.12"/>
  <object class="GtkAboutDialog" id="about_dialog">
    <property name="width_request">320</property>
    <property name="height_request">260</property>
    <property name="can_focus">False</property>
    <property name="type">popup</property>
    <property name="resizable">False</property>
    <property name="window_position">center</property>
    <property name="type_hint">normal</property>
    <property name="program_name">Inverter</property>
    <property name="version">1.0</property>
    <property name="comments" translatable="yes">Simples Inversor
Versão 1.0</property>
    <property name="website">www.teste.com.br</property>
    <property name="website_label" translatable="yes">Licença-web</property>
    <property name="license" translatable="yes">Huehuehue</property>
    <property name="authors">Guilherme</property>
    <property name="logo">heart.png</property>
    <property name="wrap_license">True</property>
    <child internal-child="vbox">
      <object class="GtkBox" id="aboutdialog-vbox1">
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <property name="spacing">2</property>
        <child internal-child="action_area">
          <object class="GtkButtonBox" id="aboutdialog-action_area1">
            <property name="can_focus">False</property>
            <property name="layout_style">end</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">False</property>
            <property name="position">0</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
  <object class="GtkWindow" id="window1">
    <property name="width_request">650</property>
    <property name="height_request">110</property>
    <property name="can_focus">False</property>
    <property name="title" translatable="yes">Teste</property>
    <property name="resizable">False</property>
    <property name="window_position">center</property>
    <property name="icon">heart.png</property>
    <signal name="destroy" handler="Gtk_main_quit" swapped="no"/>
    <child>
      <object class="GtkBox" id="box1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <child>
          <object class="GtkMenuBar" id="menubar1">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="GtkMenuItem" id="Editar">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">_Editar</property>
                <property name="use_underline">True</property>
                <child type="submenu">
                  <object class="GtkMenu" id="menu2">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <child>
                      <object class="GtkImageMenuItem" id="Copy">
                        <property name="label">gtk-copy</property>
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                        <signal name="activate" handler="on_Copy_activate" swapped="no"/>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="Paste">
                        <property name="label">gtk-paste</property>
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                        <signal name="activate" handler="on_Paste_activate" swapped="no"/>
                      </object>
                    </child>
                    <child>
                      <object class="GtkImageMenuItem" id="Delete">
                        <property name="label">gtk-delete</property>
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                        <signal name="activate" handler="on_Delete_activate" swapped="no"/>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>
            <child>
              <object class="GtkMenuItem" id="Ajuda">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Aj_uda</property>
                <property name="use_underline">True</property>
                <child type="submenu">
                  <object class="GtkMenu" id="menu3">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <child>
                      <object class="GtkImageMenuItem" id="About">
                        <property name="label">gtk-about</property>
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="use_underline">True</property>
                        <property name="use_stock">True</property>
                        <signal name="activate" handler="on_About_activate" swapped="no"/>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkEntry" id="text_entry">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="text" translatable="yes">Digite a URL aqui...</property>
            <signal name="activate" handler="on_text_entry_activate" swapped="no"/>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="padding">17</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkButtonBox" id="buttonbox1">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="orientation">vertical</property>
            <property name="layout_style">start</property>
            <child>
              <object class="GtkButton" id="Button_invert">
                <property name="label" translatable="yes">Inverter</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="relief">none</property>
                <signal name="clicked" handler="on_Button_invert_clicked" swapped="no"/>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>`
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.