在 pyGTK(2.22版本非常重要)中,我遇到了下面详述的错误。我认为这是一个 pyGTK 问题,但我可能是错的,不想报告非错误。
基本上,我从gtk.Entry()
using.get_text()
中提取文本,即使小部件中有文本,这也会返回一个空字符串。这是一些相关代码(使用 NOOP 定义使其可运行):
import gtk
class Item: pass
def tofile(item): pass
# Described issues begin below
class ItemAddDialog:
"A dialog used when adding a menu item"
def __init__(self):
self.dialog = gtk.Dialog(title="Adding menu item...", buttons=btns)
self.fname, self.name, self.icon, self.exe, self.cats = [gtk.Entry() for i in range(5)]
self.obs = (self.fname, self.name, self.icon, self.exe, self.cats)
self._config()
def _config(self):
_ = self.dialog.vbox
map(lambda x: _.pack_start(x, False, False, 0), self.obs)
map(lambda x: x.show(), self.obs)
map(lambda x: x[1].set_text(x[0]), zip(("Filename", "Name in Menu", "Icon", "Command", "Categories (; Delimited)"), self.obs))
def run(self):
r = self.dialog.run()
self.dialog.destroy()
print _quote(str(r))
if (int(r) == 1): i = Item(self.fname.get_text(), self.name.get_text(), self.icon.get_text(), self.exe.get_text(), self.cats.get_text())
print str(i)
tofile(i)