What is wxpython?
什么是wxpython?
wxpython is a GUI toolkit for the python programming language. It allows python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a python extension module (native code) that wraps the popular wxWidgets cross platform GUI library, which is written in C++.
wxpython是一个python编程语言的GUI工具包。他能够支持python程序员利用一种健壮的,高功能的图形用户界面进行创作程序,简洁且简单。他是python的一个扩展模块,该模块封装了流行的wxWidgets跨平台的GUI库,该库是由C++所写。
Like python and wxWidgets, wxpython is Open Source, which means that it is free for anyone to use and the source code is available for anyone to look at and modify. And anyone can contribute fixes or enhnacments to the project.
和python和wxWidgets一样,wxpython也是开放源代码的,这意味着任何人都可以免费使用,可以看,可以修改他的源代码。并且,每个人也可以为这个项目贡献他的智慧。
wxpython is a cross-platform toolkit. This means that the same program will run on multiple platforms without modification. Currently supported platforms are 32-bit Microsoft windows, most Unix or unix-like systems, and Macintosh OS X.
wxpython是一个跨平台的工具包,这意味着相同的程序可以运行在多个平台上而不用修改。目前,支持的平台是32-bit的Microsoft windows,大多数Unix和类Unix系统,以及Macintosh操作系统。
Since the language is python, wxpython programs are simple, easy to write and easy to understand.
由于所用语言是python,wxpython程序简洁,简单易写并且易与理解。
wxpython Overview
wxpython 概述
To set a wxpython application going, you will need to derive an App class and override App.OnInit.
为了运行一个一个wxpython应用程序,你必须从App类中派生一个类,并且重载App.OnInit方法。
An application must have a top-level Frame or Dialog window. Each frame may contain one or more instances of classes such as Panel, SplitterWindow or other windows and controls.
一个应用程序必须有一个顶级Frame或者Dialog窗口。每一个Frame可以包含一个或者多个类的实例,比如Panel,SplitterWindow或者其他的窗口或者控件。
A frame can have a MenuBar, a ToolBar, a status line, and an Icon for when the frame is iconized.
一个Frame可以有一个MenuBar,一个ToolBar,一个状态栏和该标志该Frame的图标。
A Panel is used to place controls (classes derived from Control) which are used for user interaction. Examples of controls are Button, CheckBox, Choice, ListBox, RadioBox, Slider.
一个Panel可以用来放置控件(从Cotrol派生出的类),这些控件被用来和用户交互。一些controls的例子:Button,CheckBox,Choice,ListBox,RadioBox,Slider等。
Instances of Dialog can also be used for controls, and they have the advantage of not requiring a separate frame.
一个对话框实例也可以用来放置controls,并且他们具有不需要一个单独的Frame的优点。
Instead of creating a dialog box and populating it with items, it is possible to choose one of the convenient common dialog classes, such as MessageDialog and FileDialog.
不用直接创建一个对话框并组合多个items,我们可以选一个方便的通用的对话框类,比如MessageDialog类和FileDialog类。
You never draw directly onto a window. Instead, you use a device context (DC). DC is the base for ClientDC, PaintDC, MemoryDC, PostScriptDC, MemoryDC, MetafileDC and PrinterDC. If your drawing functions have DC as a parameter, you can pass any of these DCs to the function, and thus use the same code to draw to several different devices. You can draw using the member functions of DC, such as DC.DrawLine and DC.DrawText. Control colour on a window (Colour) with brushes (Brush) and pens (Pen).
你永远不能直接中窗口中直接绘画,反之,你是利用device context(DC)。DC是ClientDC,PaintDC, MemoryDC, PostScriptDC, MemoryDC, MetafileDC和PrinterDC的基类。如果你的一个绘图函数有一个参数是DC,你可以传递上述的任意一个DC给这个函数,并且可以利用相同的代码画出几个不同的Devices。你可以利用DC的从成员函数绘图,比如DC.DrawText。窗口上(颜色)Control的颜色利用brushes(Brush)和pens(Pen)。
Most modern applications will have an on-line, hypertext help system; for this, you need Help and the HelpController class to control Help.
大多数最新的应用程序都有一个在线的,超文本帮助系统,为此,你需要Help和HelpController类来控制Help。
GUI applications aren”t all graphical wizardry. You”ll also need lists and hash tables. But since you”re working with python, you should use the ones python provides (list, tuple, dict), rather than the wxWidgets versions. Same goes for the database related classes. The basic rule of thumb is this: If you can do it directly in python, you probably should. If there is a reason not to use a python data type, wxpython will provide a wrapper for the wxWidgets class.
GUI应用程序不是所有图形的巫术,你也需要列表和哈希表等。但是,你是利用python工作,你应当用python提供的之一(list, tuple, dict),而不是wxWidgets版本的。用到的数据库相关类是相同的。一个基本原则是:如果你可以直接利用python完成,那么你应该利用。如果有一个理由你不适用python的数据类型,wxpython将要提供一个wWidgets类的封装。
This post has been viewed 145 times.
Share This
Tags:
python,
wxpython
Related posts