哦,我绝对推荐PyQt4。起初,我并没有得到所有这些SIGNAL 和EMIT 的废话,但现在我已经用它编写了一个程序,QThread 模块非常有用。
至于稳定性,我从来没有发生过崩溃。即使我在调试半功能代码,QT 也没有任何问题。每当我单击带有无效信号槽的按钮时,它都会向控制台窗口抛出错误。
另一方面,GTK 只是偶尔“爆发”一次,没有任何错误。只是您极具描述性和友好性的Segmentation Fault。这也是我发现 PyQt 工作愉快的原因之一。当您遇到错误时,您实际上知道出了什么问题。
我很确定这是个人喜好,但另外一个优点是 Mac、Linux 和 Windows 上的原生 GUI。 Windows 上的 GTK+(不要误会我的意思。我使用的是 Ubuntu)对它有一种 X-org 的感觉,这让我感到不安。
祝你好运!
只是为了让 PyQt 更有吸引力,这里摘录我的装订应用程序(有点乱):
class Binder(QtCore.QThread):
'''
Class for binding the actual book
'''
def __init__(self, parent = None):
super(Binder, self).__init__(parent)
def initialize(self, pages, options, outfile):
self.pages = pages
self.options = options
self.outFile = outfile
self.book = organizer.Book()
self.enc = Encoder(self.options)
self.ocr = ocr.OCR(self.options)
self.connect(self.enc, QtCore.SIGNAL('updateProgress(int, int)'), self.updateProgress)
def updateProgress(self, percent, item):
self.emit(QtCore.SIGNAL('updateProgress(int, QString)'), int(percent), 'Binding the book...')
self.emit(QtCore.SIGNAL('updateBackground(int, QColor)'), int(item), QtGui.QColor(170, 255, 170, 120))
if int(percent) == 100:
time.sleep(0.5)
self.emit(QtCore.SIGNAL('finishedBinding'))
def run(self):
self.die = False
for page in self.pages:
self.add_file(page, 'page')
if not self.die:
self.analyze()
if not self.die:
self.book.get_dpi()
if self.options['ocr'] and not self.die:
self.get_ocr()
if not self.die:
self.enc.initialize(self.book, self.outFile)
self.enc.start()