Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 880297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:04:28+00:00 2026-05-15T12:04:28+00:00

This is a program I’m writing that’s supposed to display some text in a

  • 0

This is a program I’m writing that’s supposed to display some text in a window…

import pyglet
from pyglet import window
from pyglet.text.layout import TextLayout

class Window(pyglet.window.Window):
    def __init__(self):
        super(Window, self).__init__(width = 800, height = 600,
                                 caption = "Prototype")

        self.disclaimer = pyglet.text.Label("Hello World",
                                   font_name = 'Times New Roman',
                                   font_size=36,
                                   color = (255, 255, 255, 255),
                                   x = TextLayout.width / 2,
                                   y = TextLayout.height / 2,
                                   anchor_x='center', anchor_y='center')

def on_draw(self):
    self.clear()
    self.disclaimer.draw()

if __name__ == '__main__':
    window = Window()
    pyglet.app.run()

…however every time I try to run it I get this error

line 16
x = TextLayout.width / 2,
TypeError: unsupported operand type(s) for /: 'property' and 'int'

I’m pretty sure this means that I tried to divide a string but in the Pyglet Documentation it says that width and height are ints. I have no idea what I’m doing wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:04:29+00:00Added an answer on May 15, 2026 at 12:04 pm

    TextLayout is a class — so TextLayout.width is a raw property, pretty useless to you; you want to get width from an instance of the TextLayout class, not from the class itself! Moreover, the class is specifically used to lay out text documents, so I don’t really see why you would want to get it at all (since you have no document object around).

    I suspect that what actually you want is:

                                   x = self.width / 2,
                                   y = self.height / 2,
    

    and remove the import of, and all mentions of, TextLayout.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's this program, pdftotext, that can convert a pdf file to a text file.
I have an executable that is started by a windows service, this program will
Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable
I am writing this java program to find all the prime numbers up to
This program takes 2 numbers from user input, asks them whether they'd like to
This program reads strings of numbers from a txt file, converts them to integers,
This program supposed to find command line arguments entered on Unix which ends with
I have this program in c++: #include <iostream> using namespace std; int main() {
I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const
Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.