hello.py

来自「使用Pygtk写的几个例子」· Python 代码 · 共 32 行

PY
32
字号
#!/usr/bin/env python""" Simple Hello World example similar to the GTK+ Tutorials one """import gtkdef hello(*args):    """ Callback function that is attached to the button """    print "Hello World"    window.destroy()def destroy(*args):    """ Callback function that is activated when the program is destoyed """    window.hide()    gtk.main_quit()# this block creates our main application windowwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)window.connect("destroy", destroy)window.set_border_width(10)# this block creates our button and places it within the windowbutton = gtk.Button("Hello World")# connects the 'hello' function to the clicked signal from the buttonbutton.connect("clicked", hello)window.add(button)button.show()# as the button is within the window this also shows the windowwindow.show_all()gtk.main()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?