-2

I am trying to display some text over an image using the pyglet library. However, I keep getting this "Texture Region" popping up instead of the actual text I included..Hoping someone can help. SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

# width of window
width = 900

# height of window
height = 900

# caption i.e title of the window
title = "E MAJOR"

# creating a window
window = pyglet.window.Window(width, height, title)

# text
text = "E MAJOR"

# creating label with following properties
# font = cooper
# position = 250, 150
# anchor position = center
label = pyglet.text.Label("E MAJOR",
                          font_name='Cooper',
                          color=(255,255,255,255),
                          font_size=36,
                          x=425,
                          y=50,
                          anchor_x='center',
                          anchor_y='center')

# creating a batch
batch = pyglet.graphics.Batch()

# loading geeksforgeeks image
image = pyglet.image.load('e-major.png')

# creating sprite object
# it is instance of an image displayed on-screen
sprite = pyglet.sprite.Sprite(image, x=100, y=25)
   
# on draw event
@window.event
def on_draw():
    # clear the window
    window.clear()

    # draw the image on screen
    sprite.draw()

    # draw the label
    label.draw()

# key press event
@window.event
def on_key_press(symbol, modifier):
    # key "C" get press
    if symbol == key.C:
        # printing the message
        print("Key : C is pressed")
  
# image for icon
img = image = pyglet.resource.image("e-major.png")

# setting image as icon
window.set_icon(img)

# loading image resource
value = pyglet.resource.image("e-major.png")

# setting text  of label
label.text = str(value)

# start running the application
pyglet.app.run()
Wheatley
  • 35
  • 3

1 Answers1

1

Looks like getting rid of

# setting text  of label
label.text = str(value)

fixed this issue

AlexK
  • 2,855
  • 9
  • 16
  • 27
Wheatley
  • 35
  • 3
  • For future reference, Stack Overflow [markdown help](https://stackoverflow.com/editing-help). – AlexK Oct 02 '22 at 23:26