TypeError: addWidget(self, QWidget, stretch: int = 0, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 1 has unexpected type 'method' PS C:\Users\woody\OneDrive\바탕 화면\Python Workspace>
몇시간을 돌려봐도 선생님이 짠 코드랑 똑같이 짰는데
실행이 안되요.....한번 봐주시겠어요????
from PyQt5.QtCore import Qt
import sys
from PyQt5.QtWidgets import *
class myapp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.s = ''
self.one = QPushButton('1')
self.one.clicked.connect(lambda:self.clickedNum('1'))
self.plus = QPushButton('+')
self.plus.clicked.connect(lambda:self.clickedNum('+'))
self.three = QPushButton('3')
self.three.clicked.connect(lambda:self.clickedNum('3'))
self.one = QPushButton('=')
self.one.clicked.connect(self.calc)
hbox = QHBoxLayout()
hbox.addWidget(self.one)
hbox.addWidget(self.plus)
hbox.addWidget(self.three)
hbox.addWidget(self.calc)
self.setLayout(hbox)
self.setWindowTitle("계산기")
self.show()
def clickedNum(self, text):
self.s += text
print(self.s)
def calc(self):
print(eval(self.s))
self.s = ''
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = myapp()
app.exec_()