你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu下PyGtk的小程序开发之gtkhello.py(图)

[日期:2007-12-09] 来源:Linux公社  作者:Linux [字体:大 中 小]

  Ubuntu下有趣的漂亮的小程序实在是太多了,真想知道那些天才般的程序员是如何做到的,所以想学习linux下图形界面程序的开发。
  校园网在访问国外网站时是很要命的,幸好同学有用网通上网的,先去找了一些教程和资料试着编了一个hello world小程序。正如预料的那样,出错是难免的!通过dir(gtk)查找函数再加上自己的一点猜测,竟把那个例子改好了,最后明白原来是那些例子是老版本gtk的,现在2.0版本的函数名称有很多都变了。

gtkhello.py

from gtk import *                                           # importing all the widgets from gtk

window = Window(WINDOW_TOPLEVEL)        # create a top level window          
window.connect("destroy", main_quit)      # quit the event loop on destruction 
window.set_border_width(10)                     # set padding round child widget     

button = Button("Hello World")                  # A button with the "Hello World" label
window.add(button)                                       # add button to window               

window.show_all()                                       # Show the window with his widgets
main()                                                             # enter the main event loop

Ubuntu下PyGtk的小程序开发之gtkhello.py(图)

linux
相关资讯       Ubuntu程序 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款