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

Alan Gauld alan.gauld at btinternet.com
Thu Jun 12 15:39:43 CEST 2014


On 12/06/14 05:51, jason sam 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)...

No you are not.
You are importing it and then trying to access something called start 
which doesn't exist. importing is not the same as running a script.
For a start the _name__ attribute will not be __main__ so your if clause 
at the bottom won't be executed. But the class definition
code will have been run so you can access and create those classes
from your wxGUI module.

However, it is very strange practice to try to create a second
GUI program from a first (not totally unheard of but uncommon).
More usually you would define a dialog and open that from
your Execute method.

> top_block.start()
>
> The error is:
>
> AttributeError: 'module' object has no attribute 'start'

Please always post the full error message not just a summary.
It has all sorts of useful extra details in there. In this case it 
doesn't matter because as the error says your module has no start 
attribute - because you didn't create one.


> code are also welcome.The same error is received when i
> use'top_block.run()'.Is there any alternative to this commands?

Yep, you didn't define a run() function either.
modules can only execute what you define within them (and one or two 
special case attributes defined by Python; all starting with __

Thee are several other oddities in your code but this is
probably enough for now.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list