Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux_icons.py #24

Open
flideros opened this issue Oct 19, 2024 · 2 comments
Open

linux_icons.py #24

flideros opened this issue Oct 19, 2024 · 2 comments

Comments

@flideros
Copy link

flideros commented Oct 19, 2024

I could not get the original code to work so I want to suggest the following code with three methods for getting the icons to work properly.

from PyQt6.QtWidgets import QApplication, QPushButton, QStyle
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import QSize

import sys

app = QApplication(sys.argv)
button = QPushButton("Hello")

Method 1 -- Direct Pointer

#icon = QIcon("/usr/share/icons/PiXflat/16x16/apps/web-browser.png")

Method 2 -- Standard Icons

#style = app.style()
#icon = style.standardIcon(QStyle.StandardPixmap.SP_FileDialogNewFolder)

Method 3 -- Explicit Theme

QIcon.setThemeName("Adwaita")
icon = QIcon.fromTheme("document-new")

button.setIcon(icon)
button.setIconSize(QSize(24,24))
button.show()

iconNull = icon.isNull()
print(iconNull)

app.exec()

@lpozo
Copy link
Collaborator

lpozo commented Oct 23, 2024

@flideros Hey! Could you please provide the link to the article where you got the original code?

@flideros
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants