PDA

View Full Version : Trouble displaying an image in PyQt4



Vysero
29th June 2018, 22:39
I am attempting to learn how to use PyQt4. For some reason I can not seem to display this logo.


import sys
from PyQt4 import QtGui

class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__() #returns parent object (q main window object)
self.setGeometry(50, 50, 500, 300)
self.setWindowTitle("PyQt4 Window")

y = '/home/rob/PycharmProjects/untitled/Logo.jpg'

self.setWindowIcon(QtGui.QIcon(y))
self.show()

app = QtGui.QApplication(sys.argv)
GUI = Window()

sys.exit(app.exec_())


What am I doing wrong?

EDIT: using Ubuntu 16.04 and py3

Added after 31 minutes:

Is there a way to mark these posts as solved? Turns out it is working. I was expecting the image to show up on the actual pop-up window; however, it appears on the icon in the task bar not the window and I just never noticed until a moment ago.