Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:31:01+00:00 2026-06-01T18:31:01+00:00

I am coding a simple text editor, so I am trying to check unsaved

  • 0

I am coding a simple text editor, so I am trying to check unsaved changes before closing the application. Now I know it has to be something with ‘delete-event’, and by googling around I have found a way, but it gives an error.

This is my code:

__gsignals__ = {
  "delete-event" : "override"
}

def do_delete(self, widget, event):
    print 'event overriden'
    tabsNumber = self.handler.tabbar.get_n_pages()
    #self.handler.tabbar.set_current_page(0)
    for i in range(tabsNumber, 0):
        doc = self.handler.tabbar.docs[i]
        lines = self.handler.tabbar.lineNumbers[i]
        self.handler.tabbar.close_tab(doc, lines)

#        if self.handler.tabbar.get_n_pages() == 0:
#            self.destroy_app()

  def destroy_app(self):
    gtk.main_quit()

And this is the error I get:

TypeError: Gtk.Widget.delete_event() argument 1 must be gtk.Widget, not gtk.gdk.Event

What is the right way to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:31:02+00:00Added an answer on June 1, 2026 at 6:31 pm

    I found the answer,

    self.connect('delete-event', self.on_delete_event)
    

    and

    __gsignals__ = {
        "delete-event" : "override"
    }
    def on_delete_event(event, self, widget):
        tabsNumber = self.handler.tabbar.get_n_pages()
        #self.handler.tabbar.set_current_page(0)
        for i in range(tabsNumber, 0):
            doc = self.handler.tabbar.docs[i]
            lines = self.handler.tabbar.lineNumbers[i]
                self.handler.tabbar.close_tab(doc, lines)
        self.hide()
        self.destroy_app()
        return True
    

    The key is in return True. It prevents the default handler to take place and for somehow the error doesn’t appear any more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm coding a simple websocket server on netty. Before a client connection has been
I'm coding a simple text editor using Windows Forms. As in many editors, when
I'm coding a simple text game to learn ruby. The hash has to be
I'm coding a simple android application which contains a list, populated with a SimpleCursorAdapter.
I'm relatively new to coding; most of my work has been just simple GUI
I am trying to avoid hard-coding each instance of this WYSIWYG editor so I
I have a very simple console application that creates a text file. Below is
I am trying to write a simple table view editor for a Core Data
I'm coding a simple code editor for a very simple scripting language we use
I'm trying to create my first simple but real application based on wxPython. And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.