파이썬 qt5 한번만 도와주세요 성님들... [4]

병장 시드200으로 10억 | 21-11-16 18:31:25 | 조회 : 566 | 추천 : -



교수님 코딩 똑같이 따라했는데 자꾸 QtGui가 정의되지않았다고 하네요..

8번 넘게 확인해도 코드가 똑같은데 왜 이럴까요... ㅠㅠㅠ


한번만 도와주실수 있나요 성님들.. ㅠㅠㅠㅠㅠㅠ



from PyQt5 import QtGui, QtWidgets
from PyQt5.QtCore import Qt

class MainFrame(QtWidgets.QWidget):
    def _init_(self):
        super().__init__()
        self.setupUi()
        self.x,self.y = None,None

    def setupUi(self):
        self.setWindowTitle('Main')
        self.resize(1280,720)
        #self.setMouseTracking(True)
       
       
    def keyPressEvent(self,e):
        self.x = e.x()
        self.y = e.y()
        self.update()

    def paintEvent(self,e):
        if self.x ==None:
            return

        qp = Qtgui.QPainter()
        qp.begin(self)
        qp.drawLine(0,0,self.x,self.y)
        pos = '{0:04d} {1:04d}'.format(self.x,self.y)
        qp.drawText(0,32,pos)
        qp.end()

app = QtWidgets.QApplication([])
MainFrame = MainFrame()
MainFrame.show()

app.exec_()

SNS로 공유하기
< 1 2 3 4 5 >