[pygtk] dialog problem

anusha k anuhacks at gmail.com
Sat Jan 10 17:57:58 WST 2009


hi,
Thanks for ur gr8 help.I solved that issue.Now one more problem has come
up.that is first time when i click on quit menu item it is working
properly,but when i click it for second time it is giving error.
*error is* : 'NoneType' object has no attribute 'show'
It is showing none type even though it is not none .
*Here is my whole code :*
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
import new_org
class mainmenu:
    def show_newOrganisation(self,widget):
        new_org.org()
        self.gladefile_newOrg = "new_org.glade"
        self.wTreenewOrg = gtk.glade.XML(self.gladefile_newOrg)

 self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
 , None, 0)
        self.notebook.set_current_page(self.page)

    def dialogQuit(self,widget):
        self.dialog_quit = self.wTree.get_widget("dialog_quit")
        self.dialog_quit.show()
        self.response = self.dialog_quit.run()
        if self.response == 1:# I assigned 1 to quit and -1 to cancel in
glade

            gtk.main_quit()
        else:
            self.dialog_quit.destroy()


    #To quit the main window
    def on_Mainwindow_destroy(self):
        gtk.main_quit()


    def __init__(self):
        #set the glade file
        self.gladefile = "gnukhata.glade"
        self.wTree = gtk.glade.XML(self.gladefile)

        #get the Main Window and connect the Destroy event
        self.window = self.wTree.get_widget("MainWindow")
        self.window.show()
        self.window.connect('destroy',gtk.main_quit)
        self.notebook = self.wTree.get_widget("notebook_main")
        self.notebook.show()

        self.menuitem_quit = self.wTree.get_widget("menuitem_quit")
        self.menuitem_quit.connect('activate',self.dialogQuit)

        self.menuitem_newOrg =
self.wTree.get_widget("menuitem_new_organisation")
        self.menuitem_newOrg.connect('activate',self.show_newOrganisation)


if __name__ == "__main__":
    mm=mainmenu()
    gtk.main()

Thanks one again

Njoy the share of Freedom,
Anusha
On Sat, Jan 10, 2009 at 2:05 PM, Andi Albrecht <albrecht.andi at googlemail.com
> wrote:

> AFAIK there's not gtk.RESPONSE_QUIT response id. When you create the
> dialog in Glade you're able to define a response ID for a dialog
> button in the properties editor. The response ID should be an integer
> matching one of the response constants in the gtk module, e.g.
>
> >>> import gtk
> >>> int(gtk.RESPONSE_OK)
> -5
> >>> int(gtk.RESPONSE_CANCEL)
> -6
>
> Hope that helps!
>
> Andi
>
> On Sat, Jan 10, 2009 at 9:05 AM, Miguel Ángel García
> <magmaxlistas at gmail.com> wrote:
> > Hello.
> >
> > I'm not too sure, but I think that you have to compare with
> > RESPONSE_CANCEL despite RESPONSE_QUIT. What I'm sure is that you must
> > quit the quotes, because it is a var, not a string.
> >
> > If I had had that problem, I had try to set a:
> > print gtk.RESPONSE_QUIT, self.response
> > between the "run" and the "if" statements, to see what is returning and
> > why it is not entering in the condition.
> >
> > Good luck!
> >
> > El Sat, 10 Jan 2009 12:07:18 +0530
> > "anusha k" <anuhacks at gmail.com> escribió:
> >
> >> hi,
> >> I am developing a account application .In  that i added a quit dialog
> >> with a two stock buttons i.e quit and cancel.but when i triggered the
> >> quit button just closes the dialog not the main window .here is my
> >> code:
> >>
> >> def dialogQuit(self,widget):
> >>         self.dialog_quit = self.wTree.get_widget("dialog_quit")
> >>         self.dialog_quit.show()
> >>         self.response = self.dialog_quit.run()
> >>         if self.response == 'gtk.RESPONSE_QUIT':
> >>             gtk.main_quit()
> >>         self.dialog_quit.destroy() <pygtk at daa.com.au>
> >>
> >> how to solve the issue
> >>
> >> Thanks in advance
> >>
> >> Njoy the share of Freedom,
> >> Anusha
> >
> >
> > --
> > In a world without walls and fences, who needs Windows and Gates?
> > _______________________________________________
> > pygtk mailing list   pygtk at daa.com.au
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/
> >
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090110/5bd193d5/attachment-0001.htm 


More information about the pygtk mailing list