The wxPython module couldn't be loaded after upgrade from wx2.8 unicode to wx2.9

It's glad to find out that the wx2.9 is released, but after install the new
version my development code couldn't compile. The codes contain several
custom grid editor which like the sample code at
http://wiki.wxpython.org/index.cgi/wxGridCellChoiceEditor2
<http://wiki.wxpython.org/index.cgi/wxGridCellChoiceEditor2>
The error triggered when try to load wx and grid module.

from wxPython.wx import *
from wxPython.grid import *

The editor gives a intelligent hint to change the wxPython.wx to
wxPython._wx, but it's not working. The wxPython.grid module couldn't be
found too. Any suggestions? Thanks in advance!

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/The-wxPython-module-couldn-t-be-loaded-after-upgrade-from-wx2-8-unicode-to-wx2-9-tp5719332.html
Sent from the wxPython-users mailing list archive at Nabble.com.

It's glad to find out that the wx2.9 is released, but after install the new
version my development code couldn't compile. The codes contain several
custom grid editor which like the sample code at
http://wiki.wxpython.org/index.cgi/wxGridCellChoiceEditor2
<http://wiki.wxpython.org/index.cgi/wxGridCellChoiceEditor2&gt;
The error triggered when try to load wx and grid module.

from wxPython.wx import *
from wxPython.grid import *

there may be a work around, but that is a VERY old import style!

you never want to do "import *" -- trust me on that.

then teh import was switched, way back when, the "wx" was also stripped
form a bunch of names, so:

import wx
my_frame = wx.Frame(....)

and teh like.

the old namespace has been preserved for years in
a compatibility "wxPython" package, but I think that's gone in 2.9

It's really time to update all your imports and names (not as hard as it
sounds with a decent search and replace tool)

Sorry for the pain!

The editor gives a intelligent hint to change the wxPython.wx to

wxPython._wx, but it's not working.

you really don't want to do that....

···

On Mon, Dec 2, 2013 at 10:43 PM, Erxin <shangerxin@hotmail.com> wrote:

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thank you for your help! Normally I rare to use the code 'import *' I just
follow the wiki of wxpython... Most of my codes are follow the demo of wx
2.8, I think it will be easy to migrate to 2.9. Anyway, the wx is great!
Thanks all the people contribute to it!

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/The-wxPython-module-couldn-t-be-loaded-after-upgrade-from-wx2-8-unicode-to-wx2-9-tp5719332p5719336.html
Sent from the wxPython-users mailing list archive at Nabble.com.

from wxPython.wx import *

from wxPython.grid import *

there may be a work around, but that is a VERY old import style!

you never want to do “import *” – trust me on that.

Yes, That is very old import style and should be eradicated from the general education/demo…
NOTE: If you absolutely have to rely on these versions then it is OK in this instance.

As far as a wildcard import, yes it is usually rare that a programmer should use this.
Ex:

from Constants import *
Usually only specific stuff that will be considered Global in the programmers mind and not to be changed after point of import.
Translated: from Module import EVERYTHING and then some…

Instead of default ids, pos, sizes, similar in this case, import defId, defPos, defSize from a *ConstantsModule.py
And let’s say I want a function sucth as translation…
Ex:

from src.Constants import *

or

from src.Constants import _, defId, defPos, defSize
If I do this the func will cause problems unless specifically imported into namespace…
as where if I do those manually it is ok, but only if the programmer explicitly knows the whole or part of the situation import at hand.

So, in a nutshell… basically don’t use wildcard imports(import *) unless you know that everything you want out of a module will be global, or maybe you are specifically targeting something(debugging oftentimes).

import wx
…is all you really need anyway, since you can get to anything you need from here anyway.
importing specific modules specifically comes with knowledge of how to use them also with the fact that you are not going to overide them with other imports from, example a different library that has similar or same name for stuff.
Ex: open and close keywords are common here.

from * import *
Use with care!

···

On Wednesday, December 4, 2013 6:16:06 PM UTC-6, Chris Barker wrote:

On Mon, Dec 2, 2013 at 10:43 PM, Erxin shang...@hotmail.com wrote:

I just follow the wiki of wxpython...

We really need to go in and clean that up!

But be sure to look at:

http://wiki.wxpython.org/wxPython%20Style%20Guide

-Chris

···

Most of my codes are follow the demo of wx
2.8, I think it will be easy to migrate to 2.9. Anyway, the wx is great!
Thanks all the people contribute to it!

--
View this message in context:
http://wxpython-users.1045709.n5.nabble.com/The-wxPython-module-couldn-t-be-loaded-after-upgrade-from-wx2-8-unicode-to-wx2-9-tp5719332p5719336.html
Sent from the wxPython-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython

I went ahead and fixed the code so it follows the normal import methodologies.

  • Mike
···

On Friday, December 6, 2013 10:48:01 PM UTC-6, Christopher Barker wrote:

I just follow the wiki of wxpython…

We really need to go in and clean that up!

But be sure to look at:

http://wiki.wxpython.org/wxPython%20Style%20Guide

-Chris