glade+pygtk学习

今天上午参照 A Beginner’s Guide to Using pyGTK and Glade 这篇文章学习,感觉确实很好用。文章开始部分对比几种GUI开发库写得挺好,虽然是2003年写的。还有后面提到如何结合socket编程,正好要用到。

照着Demo实做了一遍,发现一些用法已经deprecated了:

  • gtk.TRUE – 用True就行了
  • gtk.mainquit – 换成gtk.main_quit
  • gtk.mainloop() – 换成gtk.main()

期间犯了个小错误,忘了在glade里为主窗口添加destroy信号,结果没法关闭窗口后没法退出程序。

显示含有中文的页面内容时会在下面这行代码报错,像是编码问题,先不深究了。

self.logwindow.insert_at_cursor(data, len(data))

自己用为Entry控件加了activate信号,响应回车事件。也准备试试如何显示对话框,还没有完成。

可以在这里下载Demo的源代码: http://guoyong.org/?dl=pygtk-demo.tgz

接下来计划按照这篇文章 [ http://www.learningpython.com/2006/05/30/building-an-application-with-pygtk-and-glade/ ]学习,然后准备自己动手写了。

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.
For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>