我没有显示在Python广告这个园艺计划的Qt4PyQt的,小部件
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
color = QtGui.QColor(99, 0, 0)
class colorButton(QtGui.QWidget):
def __init__(self, args):
QtGui.QWidget.__init__(self,args)
self.setGeometry(150, 22, 50, 50)
self.setStyleSheet("QWidget { background-color: %s }" % color.name())
class ColorDialog(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(40, 40, 220, 100)
self.setWindowTitle('ColorDialog')
button=colorButton(self)
app = QtGui.QApplication(sys.argv)
cd = ColorDialog()
cd.show()
app.exec_()
的intrpreter不给我任何错误,但“有色”窗口小部件不显示。为什么? 谢谢
类colorButton(QtGui.QWidget)缺少一个“:”,但这样会产生一个SyntaxError ... – miku 2010-01-04 16:15:09
在Python中,类名一般用大写字母开头。 – 2010-01-04 22:32:00