嗨:)有人能帮我吗。我必须在Qtdesigner的对话框中添加一个LCDNumber小部件,将ui文件转换为py,然后创建一个单独的脚本来导入代码来调用ui设计和显示,它还必须包含一个计时器来不断更新LCD显示。 这是我得到的错误
Traceback (most recent call last):
File "C:\PythonPrograms\showtime.pyw", line 4, in <module>
class MyForm(QtGui.QDialog):
AttributeError: 'module' object has no attribute 'QDialog'
下一个是文件showtime.pyw假设从中导入代码显示时间.py调用UI设计和显示
import sys
from disptime import *
class MyForm(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.__init__(self, parent)
self.ui =Ui_Dialog()
self.ui.setupUi(self)
timer = QtCore.QTimer(self)
timer.timeout.connect(self.showlcd)
timer.start(1000)
self.showlcd()
def showlcd(self):
time = QtCore.QTime.currentTime()
text = time.toString('hh:mm')
self.ui.lcdNumber.display(text)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
试试看:
相关问题 更多 >
编程相关推荐