468,133 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Question on importing wxPython

python-2.3.5
wx-2.6

I just bought the wxPython In Action book and I see that all the examples
say to
import wx
All of our pre-existing code was horribly doing a
from wxPython import *

I changed all the code so that it was doing an import wx and found that
everything was broken. In particular, references to wxNewId would fail.

634 python
Python 2.3.5 (#2, May 4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import wx
wx.wxNewId
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'wxNewId'
>>>
In fact, the *only* way to get it was to go back to
import wxPython
and then refer to it as wxPython.wx.wxNewId

Is my system broken or am I missing something? i.e., should I be able to
say import wx?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
Jan 28 '08 #1
1 2168
On Jan 28, 12:06 pm, "Steven W. Orr" <ste...@syslang.netwrote:
python-2.3.5
wx-2.6

I just bought the wxPython In Action book and I see that all the examples
say to
import wx
All of our pre-existing code was horribly doing a
from wxPython import *

I changed all the code so that it was doing an import wx and found that
everything was broken. In particular, references to wxNewId would fail.

634 python
Python 2.3.5 (#2, May 4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>import wx
>wx.wxNewId

Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'wxNewId'

In fact, the *only* way to get it was to go back to
import wxPython
and then refer to it as wxPython.wx.wxNewId

Is my system broken or am I missing something? i.e., should I be able to
say import wx?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
I think the issue is that you are using the old style of wxPython. The
new style is wx.Something, so in this case, you want wx.NewId(). See
sample code below:

import wx
new_id = wx.NewId()

This helps the developer know what library that function comes from. I
see you are using 2.6. Just so you know, 2.8 is out now...you may want
to upgrade. Also, there's a really nice wxPython community mailing
list you can join, which you'll find here: http://wxpython.org/maillist.php

Mike

Jan 28 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Harlin Seritt | last post: by
4 posts views Thread by Bo Peng | last post: by
26 posts views Thread by Kevin Walzer | last post: by
3 posts views Thread by Gandalf | last post: by
reply views Thread by gooli | last post: by
3 posts views Thread by ron.reidy | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.