Hi,
Some circular import in Window1 and Window2. You'd better to put class
Window1 and Window2 to one single module Window.
Window.py:
import gtk, pygtk
class Window1:
def __init__(self, gtkfile):
self.gtkfile = gtkfile
builder = gtk.Builder()
builder.add_objects_from_file(gtkfile, ["window1"])
self.gtk_window = builder.get_object("window1")
signals = { "button_cancel_clicked" : self.button_cancel_clicked,
"button_next_clicked" : self.button_next_clicked,
"delete_event" : self.delete_event}
builder.connect_signals(signals)
self.gtk_window.show_all()
def button_cancel_clicked(self, button):
print("button cancel")
gtk.main_quit()
def button_next_clicked(self, button):
print("button next")
window2 = Window2(self.gtkfile)
self.gtk_window.destroy()
def delete_event(self, widget, event):
gtk.main_quit()
class Window2:
def __init__(self, gtkfile):
self.gtkfile = gtkfile
builder = gtk.Builder()
builder.add_objects_from_file(gtkfile, ["window2"])
self.gtk_window = builder.get_object("window2")
signals = { "button_cancel_clicked" : self.button_cancel_clicked,
"button_prev_clicked" : self.button_prev_clicked,
"button_next_clicked" : self.button_next_clicked,
"delete_event" : self.delete_event}
builder.connect_signals(signals)
self.gtk_window.show_all()
def button_cancel_clicked(self, button):
print("button cancel")
gtk.main_quit()
def button_next_clicked(self, button):
print("button next")
gtk.main_quit()
def button_prev_clicked(self, button):
print("button prev")
window1 = Window1(self.gtkfile)
self.gtk_window.destroy()
def delete_event(self, widget, event):
gtk.main_quit()
main.py:
import sys
from Window import *
if __name__ == "__main__":
window = Window1(sys.path[0]+"/windows.ui")
gtk.main()
BRs,
Kimi
顺颂时祺
<http://www.chachafille.com>
On Fri, Mar 11, 2011 at 4:47 PM, Aurélien PROVIN <[email protected]>wrote:
> Ooops :p
>
> http://aprovin.linux62.org/others/forums/pygtk/wizard1/windows.ui
>
> Regards,
>
> Le vendredi 11 mars 2011 à 16:32 +0800, Kimi M a écrit :
> > Hi,
> >
> >
> > It will be better that you can provide also the windows.ui file. Thank
> > you in advance.
> >
> >
> > ---
> > 顺颂时祺
> > http://m.kimi.im/
> >
> >
> >
> > On Fri, Mar 11, 2011 at 3:34 PM, Aurélien PROVIN <[email protected]>
> > wrote:
> > Hi,
> >
> > I'am trying to make a simple wizard which has two windows with
> > just next
> > and previous buttons.
> > But I get an import error with second window when I click on
> > previous
> > button :
> > Window2.py, line 27, in button_prev_clicked
> > window1 = Window1(self.gtkfile)
> > NameError: global name 'Window1' is not defined
> >
> > sources :
> >
> http://aprovin.linux62.org/others/forums/pygtk/wizard1/Window1.py
> >
> http://aprovin.linux62.org/others/forums/pygtk/wizard1/Window2.py
> > http://aprovin.linux62.org/others/forums/pygtk/wizard1/main.py
> >
> > Someone has an idea?
> >
> > Regards,
> >
> > _______________________________________________
> > pygtk mailing list [email protected]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/
> >
> >
>
>
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/