[pygtk] quit problem in dialog.....
zabeeh khan
zabeehkhan at gmail.com
Wed Apr 16 00:32:03 WST 2008
Skipped content of type multipart/alternative-------------- next part -----=
---------
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 =3D "names.glade"
self.wTree =3D 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 =3D {'on_quit1_activate':gtk.main_quit,'o=
n_about2_clicked':self.show_about, 'on_home_page1_clicked':self.homepage_cl=
icked}
=
#Here I have connected the dictionary together with the int=
erface reference 'wTree'
self.wTree.signal_autoconnect(self.dic_handlers)
=
=
# this is a callback function which is called when we click on 'Abo=
ut Names' at toolbar or using help menu
# def about_clicked(self,*args):
# object =3D About_Dialog()
# object.run()
=
def homepage_clicked(self,*args):
object =3D Homepage_Dialog()
object.run()
=
def show_about(self, *args, **kwds):
dialog =3D 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 =3D dialog.vbox
label =3D gtk.Label()
label.set_text(
'Names, the 99 beautiful names\n\n'
'Pathanisation.pakhtosoft.com'
)
box.pack_start(label, True, True, 0)
button =3D gtk.Button()
button.connect('clicked', quit)
button_label =3D 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 =3D "names.glade"
=
def run(self):
self.wTree =3D gtk.glade.XML(self.gladefile, "about_dialog"=
) =
self.dlg =3D self.wTree.get_widget("about_dialog")
=
self.dlg.run()
=
self.dlg.destroy()
class Homepage_Dialog:
def __init__(self):
self.gladefile =3D "names.glade"
=
def run(self):
self.wTree =3D gtk.glade.XML(self.gladefile, "homepage_dial=
og") =
self.dlg =3D self.wTree.get_widget("homepage_dialog")
=
self.dlg.run()
=
self.dlg.destroy()
instance =3D Program()
instance.main()
More information about the pygtk
mailing list