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


  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(图)

相关内容

    暂无相关文章