2006年06月22日 星期四 18:07
中文 windows xp + gtk-win32-devel-2.8.18-rc1.exe + pygtk-2.8.6-1.win32-py2.4.exe + python 2.4.3 程序简单极了. 就是在关闭主窗口的时候弹出一个对话框确认一下。使用了 gtk.STOCK_OK 和 gtk.STOCK_CANCEL,结果这两个 button 显示的汉字是方块状... import pygtk pygtk.require('2.0') import gtk class Base: def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.show() def delete_event(self, widget, event, data=None): print "delete_event" self.dialog = gtk.Dialog("abc", self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) ) ret = self.dialog.run() if ret == gtk.RESPONSE_OK: return False else: self.dialog.destroy() print "cancel delete" return True def destroy(self, widget, data=None): print "destory" gtk.main_quit() def main(self): self.window.connect("destroy", self.destroy) self.window.connect("delete_event", self.delete_event) gtk.main() if __name__ == "__main__": base = Base() base.main()
2006年06月22日 星期四 19:40
字体问题,应该与你的windows里面的字体设置有关系,如你的theme里面的字体设 置。这应该是gtk的问题,以前我用gimp的时候也遇到过这样的现象,可能与gtk的 字体渲染引擎有关吧。 Yingbo Qiu 写道: > 中文 windows xp + gtk-win32-devel-2.8.18-rc1.exe + > pygtk-2.8.6-1.win32-py2.4.exe + python 2.4.3 > > 程序简单极了. 就是在关闭主窗口的时候弹出一个对话框确认一下。使用了 > gtk.STOCK_OK 和 > gtk.STOCK_CANCEL,结果这两个 button 显示的汉字是方块状... > > import pygtk > pygtk.require('2.0') > import gtk > > class Base: > def __init__(self): > self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) > self.window.show() > > def delete_event(self, widget, event, data=None): > print "delete_event" > self.dialog = gtk.Dialog("abc", > self.window, > gtk.DIALOG_MODAL | > gtk.DIALOG_DESTROY_WITH_PARENT, > (gtk.STOCK_OK, gtk.RESPONSE_OK, > gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) > ) > ret = self.dialog.run() > if ret == gtk.RESPONSE_OK: > return False > else: > self.dialog.destroy() > print "cancel delete" > return True > > def destroy(self, widget, data=None): > print "destory" > gtk.main_quit() > > def main(self): > self.window.connect("destroy", self.destroy) > self.window.connect("delete_event", self.delete_event) > gtk.main() > > if __name__ == "__main__": > base = Base() > base.main() > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
Zeuux © 2025
京ICP备05028076号