import
sys
from
PySide2.QtWidgets
import
QApplication, QWidget, QLabel, QToolTip
from
PySide2.QtGui
import
QIcon, QPixmap, QFont
class
Window(QWidget):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle(
"GeeksforGeeks - ToolTip"
)
self
.setGeometry(
300
,
300
,
500
,
400
)
QToolTip.setFont(QFont(
"Decorative"
,
30
, QFont.Bold))
self
.setToolTip(
'Our Main Window'
)
def
setIconModes(
self
):
icon1
=
QIcon(
"geeksforgeeks.png"
)
label1
=
QLabel(
'Sample'
,
self
)
pixmap1
=
icon1.pixmap(
100
,
100
, QIcon.Active, QIcon.On)
label1.setPixmap(pixmap1)
label1.setToolTip(
"Active Icon"
)
icon2
=
QIcon(
"geeksforgeeks.png"
)
label2
=
QLabel(
'Sample'
,
self
)
pixmap2
=
icon2.pixmap(
100
,
100
, QIcon.Disabled, QIcon.Off)
label2.setPixmap(pixmap2)
label2.move(
100
,
0
)
label2.setToolTip(
"Disable Icon"
)
myApp
=
QApplication(sys.argv)
window
=
Window()
window.setIconModes()
window.show()
myApp.exec_()
sys.exit(
0
)