0

我在文件 Dialog1.py 中有一个自定义对话框类

class Dialog1(wx.Dialog):
def __init__(self, prnt):
    wx.Dialog.__init__(self, id=wxID_DIALOG1, name='Dialog1', parent=prnt,
          pos=wx.Point(110, 140), size=wx.Size(400, 498),
          style=wx.DEFAULT_DIALOG_STYLE, title='Dialog1')

在其他文件 Frame - wx.Frame 中,带有按钮

self.button1.Bind(wx.EVT_BUTTON, self.Dec, id=wxID_FRAME3BUTTON1)

和显示对话框的方法

def Dec(self, event):
    import Dialog1
    self.dialog = Dialog1(self)
    self.dialog.ShowModal()
    #dialog.Destroy()
    return True

当我按下这个按钮时,我有一个错误;

TypeError: 'module' is not Callable

为什么?,请帮帮我

编辑:好的,现在可以工作了,很多复制粘贴方法......对不起

REMOVE THIS QUESTION
4

1 回答 1

1

"'module' is not Callable" errors typically mean you did something like this:

import Foo
...
foo = Foo()

... when you should have done something like:

from Foo import Foo
...
foo = Foo

In other words, you've got a bad import statement somewhere, where you're importing a whole library rather than a class or function from that module.

My guess is, you have a file named Dialog1.py that has the class Dialog1 in it. Which means you need to do:

from Dialog1 import Dialog1
...
self.dialog = Dialog1(self)
于 2010-12-09T19:52:42.483 回答