python可以代替vb吗,Python是否像VB一样?

As you may or may not know, Microsoft is discontinuing Visual Basic in favor

of VB.NET and that means I need to find a new easy programming language. I

heard that Python is an interpreted language similar to VB. This means that

it doesn''t have all the hard stuff like pointers, classes and templates like

C, C++ and assembly language.

Where I work we use Microsoft Office with a lot of customization using

Visual Basic. I would like to switch to Python to do it since VB is being

discontinued. Would Python meet our requirements? I need to make lots of

GUI applications (message boxes, forms, etc.) and do the underlying business

logic too.

Thanks in advance.

解决方案First of all, discontinuing VB doesn''t mean you have to stop using it.

I worked on a project which was compiled with Visual C 1.52, for many

years after it was not supported. The project is used by nearly every

engineer at the company where I work.

We are still devleoping the project I work on now in VB6, and have no

reason to bail.

For new projects, it would make sense to look into VB.net or some

alternative.

Python has classes, but not templates. However, you don''t have to use

classes in your program, but it will make life easier if you learned

them.

Python''s classes are not as complicated as C++, it''s a much better

language to learn from.

VB has classes too, and if you haven''t used them in your programs, then

there''s a good chance you can program that way with Python too, but I

wouldn''t make a point of it.

VB has a much better IDE than the IDE''s for Python, although Eric3 is

one of the best, and is absolutely free.

VB''s ide is it''s strongpoint, not the language itsself.

If you need to do Gui''s then it is extremely usefull to learn the

basics of classes, your code will be much simpler in the long run.

There are many gui toolkits/frameworks for Python, but the foreunners

are pyQT, wxPython, pyGTK, and TK/Tkinter.

You don''t have to worry about pointers though :-)

"Would Python meet our requirements? "

Yes and no. Because Python is a very high-level language and

dynamically typed it is easy to learn. Python doesn''t make use of

pointers but you are able to write object-oriented code (as opposed to

just being object-friendly like Visual Basic is). You will find that on

its own you won''t be able to do any Office macro scripting although

there are several packages that will give you added functionality like

access to Com+ objects (see win32 modules by Mark Hammond). Now, this

may require more work than using VBA but it *is* doable. The com

portion of the win32 modules can enable one to create even a

macro-language unto itself!

Python is very powerful. There are many 3rd party modules and

frameworks (Zope, CherryPy). Also, there are many GUI toolkits

available for it (wxWindows, GTK, QT, Tk and on and on) and you can

also use it as a wrapper to write and compile to Java bytecode (see

Jython). The problem for you, however, is it may or may *not* meet

every requirement. For that you''ll have to find out for yourself. I

suggest downloading Python and giving the Python tutorial a whirl and

then taking a look at other Python-related stuff:

[For programmers:] http://docs.python.org/tut/tut.html

[For non-programmers:] http://honors.montana.edu/~jjc/easytut/easytut/

[Win32 stuff:] http://starship.python.net/crew/mhammond/

[Tk ''Tkinter'':]

http://www.pythonware.com/library/tkinter/introduction/

[wxPython:] http://www.wxpython.org/

[PyGTK:] http://www.pygtk.org/

Purusing these links will give you a very good idea of whether Python

is right for you. Naturally we''d all like to say ''YES Python is good

for you!'' but you have to investigate for yourself.

Good luck!

Harlin Seritt

On Wed, 16 Mar 2005 21:33:36 -0800, "Mike Cox"

declaimed the following in comp.lang.python:

As you may or may not know, Microsoft is discontinuing Visual Basic in favor

of VB.NET and that means I need to find a new easy programming language. I

So far as I know, VB.NET is the next version of Visual Basic,

making use of the "common language runtime" -- which, as I understand,

is M

这是一个VB6的IDE插件(Addin),使用VB6的IDE直接设计Python的界面。 PythonVB都是能让人快乐的编程语言,我使用了Python之后,很多自己使用的工具都使用Python开发或改写了,因为最终实现的Python代码实在太短了(相比VB),有时候Python一行代码就可以实现VB一个函数的功能。 Python就是这种让人越用越开心的语言。 不过说实在,使用Python开发GUI界面还是麻烦了一些了,自带的标准库Tkinter使用起来非常简单,不过对于习惯了VB拖放控件完成界面设计的同学来说,还是不够人性化。TK也有一个工具叫GUI Builder,不过它使用Layout布局,不够直观,而且界面简陋,用起来也不爽。 至于PyQt/wxPython等GUI库,尽管有可视化设计工具,但总感觉做一般的轻量级应用是杀鸡用牛刀,学习起来也比较复杂,而且不够环保,不够低碳,要带一个很大的库,需要目标机器上夜同样安装了PyQt/wxPython,做不了绿色软件。 所以最终的结果是我更喜欢Tkinter,用起来很简单,绿色环保,真正的跨平台,一个py文件到处运行(担心泄密就编译成pyc)。 很多人都认为TK的界面不够美观,不过导入Python自带的标准TTK主题库,界面非常Native,不输PyQt/wxPython。 此Addin默认启用TTK支持,也可选择关闭。 总而言之,轻量级GUI,TK+TTK足够。 使用此Addin,你可以不用写一句代码就可以生成一个完整可运行的Python的GUI界面,支持python 2.X和3.X。 安装方法:将压缩包解压到你希望的目录,然后执行Setup.exe完成注册插件过程,打开VB6就可以用了。 在VB窗体上设计完成界面后(你可以大胆的设置各控件的属性,Addin尽量将其翻译为tkinter的控件属性),点工具栏上的VisualTkinter(图标为一片橙红色羽毛),再点'生成代码'按钮,即可生成可运行的Python代码,可以拷贝至剪贴板或保存至文件。 一般情况下你可以不用再改变tkinter的控件属性,但是如果你熟悉tkinter,需要更多的控制,可以一一核对各属性,并且修改,再生成代码。 除了用来设计界面外,此ADDIN内置的各控件属性列表可以做为编程参考,比较完整,除了极少数我认为大多数人都不用的属性外,属性定义基本上是我从官方的tkinter文档直接翻译的。 如果还没有VB6,网上找一个VB6精简版即可(建议使用12M的版本,6M的版本也可以使用,不过工具栏图标无法显示,可以通过菜单执行此插件)。 经过网友测试,完美支持WinXP,Windows 7, Windows 8。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值