用PyGTK创建Dialog对话框

PyGTK创建Dialog的函数如下:
gtk.Dialog(title=None, parent=None, flags=0, buttons=None)

原文地址:http://www.pygtk.org/docs/pygtk/class-gtkdialog.html#constructor-gtkdialog

下面是一个例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import gtk
label = gtk.Label(u"龙昌博客 http://www.xefan.com")
dialog = gtk.Dialog(u"测试对话框",
None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
dialog.vbox.pack_start(label)
label.show()
checkbox = gtk.CheckButton("Useless checkbox")
dialog.action_area.pack_end(checkbox)
checkbox.show()
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_ACCEPT.real:
print u"确定"
if response == gtk.RESPONSE_REJECT.real:
print u"取消"