帮助从类中调用 def
菜鸟问题...
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!','')
这样我得到一个错误: messageBox().done() TypeError: did() 恰好需要 2 个参数(给定 1 个)
我怎样才能使带有“请等待”的对话框在第二个带有“完成”的对话框出现之前关闭?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎想要
关闭现有的“请稍候...”消息框。
msgbox().done()
创建一个新的消息框,然后在此新实例上调用done
。至于额外的参数,您没有使用它,因此将其从
done
的定义中删除:Off Topic
Class
msgbox
应该继承自object
> 这样你就得到了一个新样式类。在
msgbox
上定义一个 析构函数,然后你不需要显式调用msgbox.done
,您可能会忘记这样做。It looks like you want
to close the existing "Please wait..." message box.
msgbox().done()
creates a new message box, then callsdone
on this new instance.As for the extra parameter, you aren't using it, so remove it from the definition of
done
:Off Topic
Class
msgbox
should inherit fromobject
so you get a new-style class.Define a destructor on
msgbox
and you don't need to explicitly callmsgbox.done
, which you might forget to do.您选择像这样定义
done
方法:因此它确实需要两个参数 - 您调用它的
msgbox
实例,以及第二个神秘的w
参数,然后它就不再使用它了。当您调用done
时,您不会传递那个神秘且完全无用的参数。那么为什么不将def
更改为:摆脱您当前需要但未提供的神秘、无用的
w
呢?You've chosen to define the
done
method like this:so it does need two arguments -- the
msgbox
instance you're calling it on, and a second mysteriousw
argument which it then never uses. When you calldone
, you don't pass that mysterious and totally useless argument. So why not change thedef
to:getting rid of the mysterious, useless
w
which you're currently requiring but not supplying?