How to add logo
-
Hi, I'm editing a pc program in PyQT4, how can I add my logo anywhere in the program?
-
@priscilla-v You can add the logo anywhere where You want. If You want to add logo to the window title:
window.setWindowIcon(QtGui.QIcon("Path/To/logo.png"))
for example to the button:
button.setIcon(QtGui.QIcon("Path/To/logo.png"))
-
@Volodymyr14 said in How to add logo:
button.setIcon(QtGui.QIcon("Path/To/logo.png"))
Hello, I try but nothing happens, in what folder should I place the image?
-
@priscilla-v You need to find the folder with PyQt application, then find the file with main application (you_qt_app.py), In this file find the class which realizes the application window and usually in the init function of this class add something like this:
self.setWindowIcon(QtGui.QIcon("Path/To/logo.png"))
or if
window = QtGui.QWidget() window.setWindowIcon(QtGui.QIcon("Path/To/logo.png"))
with buttons, labels, other elements, they are usually in the init function of the application/widget class
self.some_button.setIcon(QtGui.QIcon("Path/To/logo.png"))
or
some_button.setIcon(QtGui.QIcon("Path/To/logo.png"))
the names of the buttons (any elements) can be any.
Usually, buttons have a declaration:self.some_but = QtGui.PushButton()
but it will not necessarily be like this.
Need to read by the content in the app files.
The images is recommended to place in the one folder with app. For example, if app path App/app.py can create in the App folder Icons folder and put to Icons folder logo.png file.
The path will be:self.setWindowIcon(QtGui.QIcon("Icons/logo.png"))
You can put here some part of the file with the application if You have a problems with code.