import
pyglet
import
pyglet.window.key as key
width
=
500
height
=
500
title
=
"Geeksforgeeks"
window
=
pyglet.window.Window(width, height, title)
text
=
"Welcome to GeeksforGeeks Have a nice day"
batch
=
pyglet.graphics.Batch()
document
=
pyglet.text.document.FormattedDocument(text)
document.set_style(
0
,
len
(document.text),
dict
(
font_name
=
'Arial'
, font_size
=
16
,
color
=
(
255
,
255
,
255
,
255
)))
layout
=
pyglet.text.layout.IncrementalTextLayout(
document,
400
,
350
, batch
=
batch)
layout.multiline
=
True
caret
=
pyglet.text.caret.Caret(layout, color
=
(
255
,
255
,
255
))
window.push_handlers(caret)
caret.set_style(
dict
(font_name
=
"Arial"
))
@window
.event
def
on_draw():
window.clear()
batch.draw()
window.push_handlers(caret)
@window
.event
def
on_key_press(symbol, modifier):
if
symbol
=
=
key.C:
print
(
"Key : C is pressed"
)
img
=
image
=
pyglet.resource.image(
"gfg.png"
)
value
=
pyglet.window.mouse.buttons_string(
2
|
5
)
text
=
"Mouse Button String : "
+
str
(value)
document.text
=
text
window.set_icon(img)
pyglet.app.run()