from
PyQt5.QtWidgets
import
*
from
PyQt5
import
QtCore, QtGui
from
PyQt5.QtGui
import
*
from
PyQt5.QtCore
import
*
import
sys
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle("Python ")
self
.setGeometry(
100
,
100
,
500
,
400
)
self
.UiComponents()
self
.show()
def
UiComponents(
self
):
toolbar
=
QToolBar(
self
)
toolbar.setGeometry(
50
,
100
,
300
,
35
)
action1
=
QAction("One",
self
)
action2
=
QAction("Two",
self
)
action3
=
QAction("Three",
self
)
action4
=
QAction("Four",
self
)
action1.setCheckable(
True
)
action2.setCheckable(
True
)
action3.setCheckable(
True
)
action4.setCheckable(
True
)
toolbar.addAction(action1)
toolbar.addAction(action2)
toolbar.addAction(action3)
toolbar.addAction(action4)
action_group1
=
QActionGroup(
self
)
action_group1.addAction(action1)
action_group1.addAction(action2)
action_group2
=
QActionGroup(
self
)
action_group2.addAction(action3)
action_group2.addAction(action4)
label
=
QLabel("GeeksforGeeks",
self
)
label.setGeometry(
100
,
150
,
200
,
50
)
action1.triggered.connect(
lambda
: label.setText("Action
1
is
Checked"))
action2.triggered.connect(
lambda
: label.setText("Action
2
is
Checked"))
action3.triggered.connect(
lambda
: label.setText("Action
3
is
Checked"))
action4.triggered.connect(
lambda
: label.setText("Action
4
is
Checked"))
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())