i have a big problem (for me!) with python gtk module.
i can open multi windows; but i can't close singly ( one time , one window ). if i close a window, all windows close automatically. i want to close the first window only. after closing firt window, come a new window ( by my choice).
for example :
#!/usr/bin/env python import pygtk pygtk.require20() import gtk class CLS1(object): def __init__(self): self.mywindow = gtk.Window(gtk.WINDOW_TOPLEVEL) self.mywindow.connect("delete_event", gtk.main_quit) self.btn = gtk.Button("Cls1|Btn") self.mywindow.add(self.btn) self.mywindow.show_all() def main(self): gtk.main() class CLS2(object): def __init__(self): self.mywindow = gtk.Window(gtk.WINDOW_TOPLEVEL) self.mywindow.connect("delete_event", gtk.main_quit) self.btn = gtk.Button("Cls2|Btn") self.mywindow.add(self.btn) self.mywindow.show_all() def main(self): gtk.main() class APP(object): def __init__(self): self.mywindow = gtk.Window(gtk.WINDOW_TOPLEVEL) self.mywindow.connect("delete_event", gtk.main_quit) self.hori = gtk.HBox() self.btn1 = gtk.Button("AppBtn1") self.btn2 = gtk.Button("AppBtn2") self.btn1.connect("clicked", self.show_me , "AppBtn1") self.btn2.connect("clicked", self.show_me , "AppBtn2") self.hori.pack_start(self.btn1) self.hori.pack_start(self.btn2) self.mywindow.add(self.hori) self.mywindow.show_all() def show_me(self, penar, data): if data=="AppBtn1" : CLS1().main() if data=="AppBtn2": CLS2().main() gtk.main_quit() def main(self): gtk.main() APP().main() i want this :
1- i will run the program
2- the "APP" class will work and will come "APP" window
3- if i click a button (AppBt1 or AppBtn2) ; the "APP" window will close (automatically ; not by me!)
4- if i was clicked "AppBtn1" button on "APP" window (@step 3) ; the "CLS1" class will work and its window will open
,or if i was clicked "AppBtn2" button on "APP" window (@step 3) ; the "CLS2" class will work and its window will open
i wanna only one window on the screen while program running; if i click a button ; its window will close and a new window will open (by my choice, and automatically!)
how can i do this? and can you write its code :) thanks a lot !