Size: 5281
Comment:
|
← Revision 32 as of 2009-12-25 07:16:38 ⇥
Size: 3139
Comment: converted to 1.6 markup
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
## page was renamed from PyGTK 2.0 Tutorial 中文编译 | |
Line 4: | Line 5: |
''' 含有章节索引的中文 文章模板 ''' |
|
Line 8: | Line 6: |
::-- ehu4ever [[[DateTime(2005-08-07T05:40:51Z)]]] [[TableOfContents]] |
<<TableOfContents>> |
Line 18: | Line 17: |
PyGTK 2.0 是一个系列的Python模块,它提供了一个使用 GTK+ 2.X 的接口。在本篇文档的其它部分中,PyGTK是指PyGTK的2.X版本,GTK 和 GTK+ 是指GTK+的2.X 版本。Python的门户是[http://www.pygtk.org www.pygtk.org]。PyGTK的主要作者是 * James Henstridge [mailto:[email protected] [email protected] ] |
|
Line 22: | Line 18: |
who is assisted by the developers listed in the AUTHORS file in the PyGTK distribution and the PyGTK community. | '''[[self:pygtk_into|绪论]]''' |
Line 24: | Line 20: |
Python is an extensible, object-oriented interpreted programming language which is provided with a rich set of modules providing access to a large number of operating system services, internet services (such as HTML, XML, FTP, etc.), graphics (including OpenGL, TK, etc.), string handling functions, mail services (IMAP, SMTP, POP3, etc.), multimedia (audio, JPEG) and cryptographic services. In addition there are many other modules available from third parties providing many other services. Python is licensed under terms similar to the LGPL license and is available for Linux, Unix , Windows and Macintosh operating systems. More information on Python is available at www.python.org . The primary Author of Python is: | === 浅析PyGTK === |
Line 26: | Line 22: |
* Guido van Rossum [mailto:[email protected] [email protected] ] | 这段没什么意思,就不麻烦了 |
Line 28: | Line 24: |
GTK (GIMP Toolkit) is a library for creating graphical user interfaces. It is licensed using the LGPL license, so you can develop open software, free software, or even commercial non-free software using GTK without having to spend anything for licenses or royalties. | == Getting Started == |
Line 30: | Line 26: |
It's called the GIMP toolkit because it was originally written for developing the GNU Image Manipulation Program (GIMP), but GTK has now been used in a large number of software projects, including the GNU Network Object Model Environment (GNOME) project. GTK is built on top of GDK (GIMP Drawing Kit) which is basically a wrapper around the low-level functions for accessing the underlying windowing functions (Xlib in the case of the X windows system). The primary authors of GTK are: | '''[[self:pygtk_getstart|Getting Started]]''' |
Line 32: | Line 28: |
* Peter Mattis [mailto:[email protected] [email protected] ] * Spencer Kimball [mailto:[email protected] [email protected] ] * Josh MacDonald [mailto:[email protected] [email protected] ] |
=== 用PyGTK说“Hello” === |
Line 36: | Line 30: |
GTK is currently maintained by: | '''[[self:pygtk_sayhello|用PyGTK说“Hello”]]''' |
Line 38: | Line 32: |
* Owen Taylor [mailto:[email protected] [email protected] ] * Tim Janik [mailto:[email protected] [email protected] ] |
=== 事件信号 和 函数调用的理论 === |
Line 41: | Line 34: |
GTK是一组面象的编程接口(API)。虽然它是用C语言写的,但是它在实现中遵循了“类”和“回调函数”的理念(pointers to functions)。 | '''[[self:pygtk_callback|事件信号 和 函数调用的理论]]''' |
Line 43: | Line 36: |
另外,还存在一个第三方的类,叫GLib,它包含的一些标准的calls,可以作为替代品。而且,GLib还包含了一些处理linked lists的函数,等等。这些可以作为替代的函数增强了GTK的可迁移性,因为GTK中的一些函数实现在另外一些类UNIX系统中是不标准或是没有的,比如g_strerror()。GLib还在一些地方对于libc版本的GTK更优秀,比如g_malloc有更强的可调试性。 | === Events === |
Line 45: | Line 38: |
在GLib的2.0版本中,使用了作为GTK类继承结构基础的类型系统,这个系统在GTK中使用广泛。有一个线程API,它抽象了各种系统平台的不同的本地线程API,而且还有loading modules的功能。 | '''[[self:pygtk_events|五花八门的事件]]''' |
Line 47: | Line 40: |
GTK使用Pango库来实现i18n的文本输出。 | === Stepping Through Hello World === '''[[self:pygtk_sthello|hello world庖丁解牛]]''' |
Line 50: | Line 45: |
这篇文档描述了GTK+的Python接口,以GTK+2.0版本为基础。由Tony Gale和Ian Main编写。目地在于尽可能详细地描述PyGTK,但并不意味着是完美和完整。 | == COME ON!! 继续前进吧 == |
Line 52: | Line 47: |
这篇文档要求读者对于Python语言、和怎样编写和运行Python程序有一定的了解,如果你对于Python不是很熟,请先搞定[http://www.python.org/doc/current/tut/tut.html Python Tutorial]。这篇文档没有要求读者先前对GTK有了解,如果你是通过PyGTK来学习GTK,请说明你是怎样找到这篇文档的,以及你遇到什么样的困难。 | === 对“信号处理”了解更多 === |
Line 54: | Line 49: |
这篇文档没有包括编译Python、GTK和GTK+的说明。 | === Hello World的火力加强版 === |
Line 56: | Line 51: |
这篇文档以以下类库为基础: | '''[[self:pygtk_movingon|COME ON!! 继续前进吧]]''' |
Line 58: | Line 53: |
*GTK+ 2.0 through GTK+ 2.4 *Python 2.2 *PyGTK 2.0 through PyGTK 2.4 |
== 对widget进行排版 == |
Line 62: | Line 55: |
This document is a "work in progress". Please look for updates on www.pygtk.org. | 一个GUI程序的主窗口一般是不只一二个widget的,我们的第一个程序只有一个widget,所以我们简单地使用了gtk.Container.add()来把widget放进主窗口。那么,当我们要同时在主窗口中组织多个widget时,我们怎么来处理widget之间以及widget和主窗口之间的位置关系呢?????????? |
Line 64: | Line 57: |
I would very much like to hear of any problems you have learning PyGTK from this document, and would appreciate input as to how it may be improved. Please see the section on Contributing for further information. If you encounter bugs please file a bug at bugzilla.gnome.org against the pygtk project. The information at www.pygtk.org about Bugzilla may help. | 这就是我们学习packing的理由了。 |
Line 66: | Line 59: |
The PyGTK 2.0 Reference Manual is available at http://www.pygtk.org/pygtkreference. It describes in detail the PyGTK classes. | === 魔力box === |
Line 68: | Line 61: |
The PyGTK website (www.pygtk.org) contains other resources useful for learning about PyGTK including a link to the extensive FAQ and other articles and tutorials and an active maillist and IRC channel (see www.pygtk.org for details). | '''[[self:pygtk_box|魔力box]]''' |
Line 70: | Line 63: |
=== 浅析PyGTK === | === 打开box === '''[[self:pygtk_openbox|打开box]]''' === 小试牛刀 === '''[[self:pygtk_demo|小试牛刀]]''' === 表格方式排版 === '''[[self:pygtk_packtable|表格方式排版]]''' === 表格排版示例 === '''[[self:pygtk_tabledemo|表格排版示例]]''' == widget初步领略 == 使用widget的一般步骤是: * 调用widget的构造函数:gtk.* * 为widget定义好各种事件处理 * 定义widget的各种属性 * 用适当的方法把widget放入某一个容器中:gtk.Container.add()或是gtk.Box.pack_start()。 * 显示widget:gtk.Widget.show() === Widget们的类型层次结构 === '''[[self:pygtk_widgetshi|Widget们的类型层次结构]]''' === 在离开窗口的日子里 === '''[[self:pygtk_withoutwindows|在离开窗口的日子里]]''' == 按一下按钮 == === 普通货色 === '''[[self:pygtk_buttons|普通货色]]''' === Toggle Buttons === '''[[self:pygtk_togglebuttons|Toggle Buttons]]''' === Check Buttons === '''[[self:pygtk_checkbuttons|Check Buttons]]''' === Radio Buttons === '''[[self:pygtk_radiobuttons|Radio Buttons]]''' == 找准自己的位置 == === 左顾右盼、瞻前顾后 === '''[[self:pygtk_creatingadj|左顾右盼、瞻前顾后]]''' === 画地为牢 === '''[[self:pygtk_usingadj|画地为牢]]''' === 深入讲解 === '''[[self:pygtk_internals|深入讲解]]''' == 只能看见一部分^o^ == == widget大杂烩 == == 可以装别的widget的widget == == 来份菜单 == == 我要涂鸦 == == 1+1在什么情况下不等于2 == |
Contents
1. PyGTK 2.0 Tutorial 中文编译
原作者:John Finlay
Version 2.4
April 13, 2005
1.1. 绪论
1.1.1. 浅析PyGTK
这段没什么意思,就不麻烦了
1.2. Getting Started
1.2.1. 用PyGTK说“Hello”
1.2.2. 事件信号 和 函数调用的理论
1.2.3. Events
1.2.4. Stepping Through Hello World
1.3. COME ON!! 继续前进吧
1.3.1. 对“信号处理”了解更多
1.3.2. Hello World的火力加强版
1.4. 对widget进行排版
一个GUI程序的主窗口一般是不只一二个widget的,我们的第一个程序只有一个widget,所以我们简单地使用了gtk.Container.add()来把widget放进主窗口。那么,当我们要同时在主窗口中组织多个widget时,我们怎么来处理widget之间以及widget和主窗口之间的位置关系呢??????????
这就是我们学习packing的理由了。
1.4.1. 魔力box
1.4.2. 打开box
1.4.3. 小试牛刀
1.4.4. 表格方式排版
1.4.5. 表格排版示例
1.5. widget初步领略
使用widget的一般步骤是:
- 调用widget的构造函数:gtk.*
- 为widget定义好各种事件处理
- 定义widget的各种属性
- 用适当的方法把widget放入某一个容器中:gtk.Container.add()或是gtk.Box.pack_start()。
- 显示widget:gtk.Widget.show()
1.5.1. Widget们的类型层次结构
1.5.2. 在离开窗口的日子里
1.6. 按一下按钮
1.6.1. 普通货色
1.6.2. Toggle Buttons
1.6.3. Check Buttons
1.6.4. Radio Buttons
1.7. 找准自己的位置
1.7.1. 左顾右盼、瞻前顾后
1.7.2. 画地为牢
1.7.3. 深入讲解
1.8. 只能看见一部分^o^
1.9. widget大杂烩
1.10. 可以装别的widget的widget
1.11. 来份菜单
1.12. 我要涂鸦