pygtk closing popup - destroy function doesn't work for button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • drzoo2
    New Member
    • Feb 2009
    • 3

    #1

    pygtk closing popup - destroy function doesn't work for button

    Completely noob question as I am not a programmer but really trying hard to learn Python (Object oriented programming in general).

    I am writing a program in python that calls a popup window with some general information with an ok button. If I close the window using the window's close button I have no problems but If I call the same destroy function using the button call, it will not kill the popup.


    Code:
    def destroy(self, widget, data=None):
    		print("Delete event occurred")
    		return False
    
    self.popup.connect("destroy", self.destroy)
    
    self.button_pop.connect("clicked", self.destroy)
    self.popup.conn ect("destroy", self.destroy)
    is the gtk window and......

    self.button_pop .connect("click ed", self.destroy)
    is the button widget in the window. How do I handle this?

    z
  • drzoo2
    New Member
    • Feb 2009
    • 3

    #2
    I realize this is a really beginner question. I'm really stuck on this. I can't find an answer. Currently I'm hiding the window with a button call to a function that just runs.....

    self.popup.hide ()

    I don't think this is the right way to handle the popup window since the window's close is tied to the destroy function. It works when called from the window but not from the button.

    z

    Comment

    • micmast
      New Member
      • Mar 2008
      • 144

      #3
      I would try to destroy the popup window itself:

      for example this is code I used in an application to display errors

      [CODE=python]
      self.errorm = gtk.MessageDial og(parent = self.mainwindow , buttons = gtk.BUTTONS_OK, flags = gtk.DIALOG_MODA L, type = gtk.MESSAGE_ERR OR, message_format = "Error occured:\n"+mes sage)
      self.errorm.set _title("Error occured")
      result = self.errorm.run ()
      self.errorm.des troy()
      [/CODE]

      Comment

      • drzoo2
        New Member
        • Feb 2009
        • 3

        #4
        micmast,
        Thanks you very much.

        I modified this code........
        Code:
        def destroy(self, widget, data=None):
        		print("Delete event occurred")
        		return False
        
        self.popup.connect("destroy", self.destroy)
        
        self.button_pop.connect("clicked", self.destroy)
        too this.......

        Code:
        def destroy(self, widget, data=None):
        		print("Delete event occurred")
        		self.popup.destroy()
        
        self.popup.connect("destroy", self.destroy)
        
        self.button_pop.connect("clicked", self.destroy)
        and all is well. All I added was self.popup.dest roy(). I swear I tried that! This has been haunting me for a week. I just couldn't get it. Your help is very much appreciated.... ...back to coding.

        z

        Comment

        Working...