Python Forum
NameError: name 'self' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'self' is not defined
#1
This is the code for opening .tif on a PyQT window:

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow

app = QApplication(sys.argv)

window = QMainWindow()
window.show()

def getFrame(self):
	fp = r'/home/UbuntuUser/Desktop/UAV.tif'
	self.img = cv2.imdecode(np.fromfile(fp, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
	print(self.img)

self.getFrame()

# Start the event loop.
app.exec_()
Why do I get this error??

Error:
Traceback (most recent call last): File "mycode.py", line 14, in <module> self.getFrame() NameError: name 'self' is not defined
Thank you
Reply


Messages In This Thread
NameError: name 'self' is not defined - by hobbyist - Jan-03-2021, 05:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Kivy] NameError: name 'App' is not defined nengkya 4 13,667 Apr-02-2017, 07:15 PM
Last Post: metulburr
  [WxPython] NameError: global name 'PyAssertionError' is not defined merlem 5 6,317 Jan-28-2017, 01:59 PM
Last Post: merlem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020