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

  • SEARCH
  • Home
  • 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 8385037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:34:01+00:00 2026-06-09T17:34:01+00:00

I’m trying to create an application with pygtk that opens a subwindow, but I’m

  • 0

I’m trying to create an application with pygtk that opens a subwindow, but I’m having some trouble with the creation/showing and the destruction/hiding process of this window. As a test, I’ve made a simple application that opens a main window with a single button that, when clicked, opens a subwindow with three buttons. I’ve used glade to design the interface. My code is as following:

main.py

import gobject
import pygtk
import gtk.gtkgl
import gtk.glade
from interface import *

if __name__ == "__main__":
    gtk.gdk.threads_init()
    settings = gtk.settings_get_default()
    settings.props.gtk_button_images = True
    intf = interface()
    gtk.main()

and interface.py

import pygtk
import gtk.gtkgl
import gtk.glade

class interface(object):

    def __init__(self):

        self.builder = gtk.Builder()
        self.builder.add_from_file("web-interface.glade")

        self.main_window = self.builder.get_object("main_window")
        self.camera_window = self.builder.get_object("cam_window")
        self.main_window.show()

        self.builder.connect_signals(self)

    def on_main_window_destroy(self, widget):
        gtk.main_quit()

    def on_camera_clicked(self, widget):
        self.camera_window.show()

    def on_bt1_clicked(self, widget):
        self.camera_window.hide()

    def on_cam_window_destroy(self, widget):
        self.camera_window.hide()
        return

where ‘bt1’ is a button on camera_window to hide it and ‘camera’ is a button on the main window that opens the subwindow.

Now, when I try to open the sub window with ‘camera’ and close it with ‘bt1’, it works just fine. But if I try to close the sub window with the ‘X’ button, the next time I open it I get a gray, empty window, even though I changed the destroy event to only hide the window. What am I doing wrong?

Thanks in advance!

  • 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-09T17:34:02+00:00Added an answer on June 9, 2026 at 5:34 pm

    Connect to the delete-event signal instead of destroy. The destroy signal can’t be blocked.

    Also, make sure you return True from your delete-event handler. This means that you have handled the event, and further handling will be blocked. If you don’t, then the default handler will still be called after yours, and so the window will be hidden and then still destroyed anyway.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.