The difference of it?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The difference of it?

Lu Zhilin
The difference of it?

Friend:
        Can you tell me ,the difference of :
                import wx
                from wxPython.wx import *
        I have studied the source code of wxPython : __init__.py,_wx.py,_core.py,_window.py.
        I have know a little about it,but i won't know the detail of it.
        Can you tell me ,Sorry ,my english is poor.
        Thanks.

-------------------------------------------
陆志林

万达信息股份有限公司-企业服务事业部-政府应用业务部
电话:021-64950118-2527
地址:上海市漕河泾桂平路481号18号楼5层
邮编:200233

--------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: The difference of it?

Mart Raudsepp
On Mon, 2006-01-16 at 09:28 +0800, Lu Zhilin wrote:

> Friend:
>         Can you tell me ,the difference of :
>                 import wx
>                 from wxPython.wx import *
>         I have studied the source code of wxPython :
> __init__.py,_wx.py,_core.py,_window.py.
>         I have know a little about it,but i won't know the detail of
> it.
>         Can you tell me ,Sorry ,my english is poor.
>         Thanks.

This is basic python importing difference.

import wx imports wx, so you can use it like wx.Button

from wxPython.wx import * (if it works with wxPython in front) imports
wx into the global namespace, so you'd just write Button, instead of
wx.Button

I would advocate the former (import wx).

Next time please ask on the wxForum message boards, wx-users or wxPython
users mailing list. This list (wx-dev) is meant for discussion about the
development of wxWidgets itself.

--
With regards,
Mart Raudsepp

Project manager of wxMUD
E-mail: [hidden email]
http://wxmud.sourceforge.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: The difference of it?

Robin Dunn
In reply to this post by Lu Zhilin
Lu Zhilin wrote:
>
> Friend:
>         Can you tell me ,the difference of :
>                 import wx
>                 from wxPython.wx import *
>         I have studied the source code of wxPython :
> __init__.py,_wx.py,_core.py,_window.py.
>         I have know a little about it,but i won't know the detail of it.


Originally the wxPython modules were located in a package named wxPython
and the code classes and functions were located in a module named wx.
The classes and functions were all named like they are in C++, with a wx
prefix, like wxButton or wxFrame.  Because of this most people used the
"from wxPython.wx import *" method of importing and they were able to
use the names like "wxButton" instead of "wx.wxButton"

Starting in the version 2.4 timeframe I provided a new wx package that
imported and renamed everything from the wxPython package, such that the
leading wx was stripped off.  This let people use just "import wx" and
use names like "wx.Button".  This made most people very happy because
the package architecture was more "Pythonic."  ;-)  See the
wxPackage.html file in the docs dir for more details.

Starting with 2.5 I switched everything around and now the real classes
are located in the wx package and are named without the wx prefix.  The
wxPython package still exists for compatibility, but this time it
contains modules that import from the wx package and adds the wx prefix
back on to the names.  See the "The wx Namespace" section of
http://wxpython.org/migrationguide.php for details.

I expect that I will stop distributing the wxPython package sometime in
the 2.7 release cycle.  So using "import wx" and names like "wx.Button"
is definitely the style you want to use.


--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]