[Tutor] AttributeError: 'module' object has no attribute 'start'

Walter Prins wprins at gmail.com
Thu Jun 12 12:41:58 CEST 2014


Hi,

On 12 June 2014 05:51, jason sam <user0873 at gmail.com> wrote:
>
> Hi All,
> I am new to wxPython.I have made a simple GUI that contains a button and by pressing that button i am calling another .py file(top_block.py)...But i am getting error using the command:
>
> top_block.start()
>
> The error is:
>
> AttributeError: 'module' object has no attribute 'start'

The message states that there's no attribute in the module called
'start', which is correct -- top_block.py doesn't contain anything
named 'start'.  (What made you think that modules have a magic method
start() that causes them to run?)  You should probably learn more
about Python itself, name binding, module objects etc.

>
> The code is as attached.I am using python 2.7.3.Any improvements in the code are also welcome.The same error is received when i use'top_block.run()'.Is there any alternative to this commands?

I'm not a wxPython expert but you should probably be creating an
instance of the the frame class defined in top_block and then call
show() that, from your wxgui.py, when your button click handler is
called.  I would also rename the classes to represent what they are.
(MyFrame is not exactly useful and is doubly ambiguous as you have 2
defined in different modules.)   Suggestion: Try to fix your program
with both the main program and the top bar in one module.  And then
only when this works try moving it back out to another module again,
if required.

HTH

Walter


More information about the Tutor mailing list