Reputation: 373
Noob question...
class msgbox:
def __init__(self, lbl_msg = '', dlg_title = ''):
self.wTree = gtk.glade.XML('msgbox.glade')
self.wTree.get_widget('dialog1').set_title(dlg_title)
self.wTree.get_widget('label1').set_text(lbl_msg)
self.wTree.signal_autoconnect( {'on_okbutton1_clicked':self.done} )
def done(self,w):
self.wTree.get_widget('dialog1').destroy()
class Fun(object):
wTree = None
def __init__(self):
self.wTree = gtk.glade.XML( "main.glade" )
self.wTree.signal_autoconnect( {'on_buttonOne' : self.one,} )
gtk.main()
@yieldsleep
def one(self, widget, data=None):
self.msg = msgbox('Please wait...','')
yield 500
self.msg = msgbox().done() # <----------------???
self.msg = msgbox('Done!','')
With this i get an error: messageBox().done() TypeError: done() takes exactly 2 arguments (1 given)
How can i make the dialog box with "please wait" to close before the second dialog box with "done" appears??
Thank you.
Upvotes: 0
Views: 487
Reputation: 77400
It looks like you want
self.msg.done()
to close the existing "Please wait..." message box. msgbox().done()
creates a new message box, then calls done
on this new instance.
As for the extra parameter, you aren't using it, so remove it from the definition of done
:
def done(self):
self.wTree.get_widget('dialog1').destroy()
Class msgbox
should inherit from object
so you get a new-style class.
Define a destructor on msgbox
and you don't need to explicitly call msgbox.done
, which you might forget to do.
class Msgbox(object):
...
def __del__(self):
self.wTree.get_widget('dialog1').destroy()
class Fun(object):
...
@yieldsleep
def one(self, widget, data=None):
self.msg = Msgbox('Please wait...','')
yield 500
# actually, you probably need to delete the old self.msg
# so it gets destroyed before the new message box is created
del self.msg
self.msg = Msgbox('Done!','')
Upvotes: 1
Reputation: 881705
You've chosen to define the done
method like this:
def done(self,w):
so it does need two arguments -- the msgbox
instance you're calling it on, and a second mysterious w
argument which it then never uses. When you call done
, you don't pass that mysterious and totally useless argument. So why not change the def
to:
def done(self):
getting rid of the mysterious, useless w
which you're currently requiring but not supplying?
Upvotes: 1