We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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")
#icon = QIcon("/usr/share/icons/PiXflat/16x16/apps/web-browser.png")
#style = app.style() #icon = style.standardIcon(QStyle.StandardPixmap.SP_FileDialogNewFolder)
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()
The text was updated successfully, but these errors were encountered:
@flideros Hey! Could you please provide the link to the article where you got the original code?
Sorry, something went wrong.
https://www.pythonguis.com/d/pyqt6-source.zip
No branches or pull requests
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()
The text was updated successfully, but these errors were encountered: