Hello everyone!

I have written this thingy...the file is attached. It is based on Pygtk and
glade. The problem which I have with the program is that when I click the OK
button in the About dialog, the dialog is not closed. But, with double
clicks the whole program is closed. I am sure there are some mistakes in the
coding. Please see the file and fix the error which is there?? please? It is
a small error but I am not seeing it?? It should close the dialog with one
click...
try:
        import gtk,gtk.glade
except:
        print "GTK library not found"

try:
        import pygtk
except:
        print "PyGTK library not found"
        

class Program:
        def __init__(self):
                self.gladefile = "names.glade"
                self.wTree = gtk.glade.XML(self.gladefile,"mainWindow")
                
                
                
                #Here I am creating a dictionary with handlers
                # 'gtk_main_quit' was defined on mainWindow using the glade, 
check it out
                
                
                self.dic_handlers = 
{'on_quit1_activate':gtk.main_quit,'on_about2_clicked':self.show_about, 
'on_home_page1_clicked':self.homepage_clicked}
                
                #Here I have connected the dictionary together with the 
interface reference 'wTree'
                self.wTree.signal_autoconnect(self.dic_handlers)
        
        
        # this is a callback function which is called when we click on 'About 
Names' at toolbar or using help menu
#        def about_clicked(self,*args):
 #               object = About_Dialog()
  #              object.run()
                
        def homepage_clicked(self,*args):
                object = Homepage_Dialog()
                object.run()
                
        def show_about(self, *args, **kwds):
                dialog = gtk.Dialog()
                dialog.set_title('About Names')
                dialog.set_border_width(1)
                dialog.set_size_request(400, 290)
                def quit(*args, **kwds):
                        gtk.main_quit()
                dialog.connect('destroy', lambda *args: quit())
                dialog.connect('delete_event', lambda *args: quit())
                box = dialog.vbox
                label = gtk.Label()
                label.set_text(
                    'Names, the 99 beautiful names\n\n'
                    'Pathanisation.pakhtosoft.com'
                                )
                box.pack_start(label, True, True, 0)
                button = gtk.Button()
                button.connect('clicked', quit)
                button_label = gtk.Label()
                button_label.set_markup('OK')
                button.add(button_label)
                box.pack_start(button, False, False, 0)
                dialog.show_all()
                gtk.main()
        
                
        # This function do the program to run
        def main(self):
                gtk.main()
                
                

class About_Dialog:
        def __init__(self):
                self.gladefile = "names.glade"
        
        def run(self):
                self.wTree = gtk.glade.XML(self.gladefile, "about_dialog") 
                self.dlg = self.wTree.get_widget("about_dialog")
                
                self.dlg.run()
                
                self.dlg.destroy()

class Homepage_Dialog:
        def __init__(self):
                self.gladefile = "names.glade"
        
        def run(self):
                self.wTree = gtk.glade.XML(self.gladefile, "homepage_dialog") 
                self.dlg = self.wTree.get_widget("homepage_dialog")
                
                self.dlg.run()
                
                self.dlg.destroy()


instance = Program()
instance.main()
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to