该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import sys
from PyQt4 import QtCore, QtGui, uic
from_class = uic.loadUiType(r'D:\python\Python-GUI\tempconv.ui')[0]
class MyWindowClass(QtGui.QMainWindow, from_class):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.setupUi(self)
self.btn_CtoF.clicked.connect(self.btn_CtoF_clicked)
self.btn_FtoC.clidked.connect(self.btn_FtoC_clicked)
def btn_CtoF_clicked(self):
cel = float(self.editCel.text())
fahr = cel * 9 / 5.0 + 32
self.spinFahr.setValue(int(fahr + 0.5))
def btn_FtoC_clicked(self):
fahr = self.spinFahr.value()
cel = (fahr - 32) * 5 / 9.0
self.editCel.setText(str(cel))
app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
myWindow.show()
app.exec_()
下面是运行报错提示:
Traceback (most recent call last):
File "D:\python\python-object\TempGui.py", line 23, in
myWindow = MyWindowClass(None)
File "D:\python\python-object\TempGui.py", line 9, in __init__
self.btn_CtoF.clicked.connect(self.btn_CtoF_clicked)
AttributeError: 'MyWindowClass' object has no attribute 'btn_CtoF'
请问怎么解决啊