Introduction to pyglet library for game development in Python Last Updated : 10 Feb, 2020 Comments Improve Suggest changes Like Article Like Report Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc on Windows, Mac OS and Linux. This library is created purely in Python and it supports many features like windowing, user interface event handling, Joysticks, OpenGL graphics, loading images, and videos, and playing sounds and music. pyglet is provided under the BSD open-source license, allowing you to use it for both commercial and other open-source projects with very little restriction. Features No external dependencies or installation requirements: For development of most of the applications, pyglet does not need any external libraries or installation of packages which helps in simplifying distribution and installation Take advantage of multiple windows and multi-monitor desktops: Sometimes multi-monitor desktop setups are use for game development and pyglet is designed in such a way that it lets you use as many windows as needed and also allows fullscreen games and application across multiple screens. Load images, sound, music and video in almost any format pyglet is provided under the BSD open-source license, allowing you to use it for both commercial and other open-source projects with very little restriction. It supports development in Python 2 as well as Python 3 Installation Since pyglet is created entirely in Python, no special tasks are needed to be done for installation. pyglet can be install in many ways, the most basic installation requires typing the following command in your terminal: pip install pyglet Example: Python3 1== import pyglet new_window = pyglet.window.Window() label = pyglet.text.Label('Hello, World !', font_name ='Cooper', font_size = 16, x = new_window.width//2, y = new_window.height//2, anchor_x ='center', anchor_y ='center') @new_window.event def on_draw(): new_window.clear() label.draw() pyglet.app.run() Output: Explanation Begin the program by importing the library: import pyglet Using the default constructor, we can create windows which display the app contents: new_window = pyglet.window.Window() Label is created to display the text Hello, World!: label = pyglet.text.Label('Hello, World !', font_name ='Cooper', font_size = 16, x = new_window.width//2, y = new_window.height//2, anchor_x ='center', anchor_y ='center') The on_draw() event is used to draw its contents on to the window.The pyglet library provides several ways to attach event handlers to objects; a simple way is to use a decorator: @new_window.event def on_draw(): new_window.clear() label.draw() Finally to run the app the following line is appended at the end of the source code: pyglet.app.run() Comment More infoAdvertise with us Next Article Introduction to pyglet library for game development in Python M Meet Parekh Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2019 Python-gui Practice Tags : python Similar Reads Python for Game Development: Getting Started with Pygame For a variety of uses, including web development, data research, automation, and, more and more, game creation, Python has grown to be an immensely popular language. Python allows both novice and seasoned developers to implement all the processes by initiating a very easy and robust approach to crea 5 min read Python Game Development Libraries Python, with its simplicity and versatility, has become a favorite among developers for various applications, including game development. Thanks to its rich ecosystem of libraries and frameworks, creating games with Python has never been easier. In this article, we'll delve into some of the top Pyth 5 min read Difference between Pygame VS Arcade Library in Python Game programming is very rewarding nowadays and it can also be used in advertising or as a teaching tool. Game development encompasses mathematics, logic, physics, AI, and much more and it can be amazingly fun. In Python, up until now, Pygame library was employed for the same, but there is a new mod 3 min read Introduction to Python for Absolute Beginners Are you a beginner planning to start your career in the competitive world of Programming? Looking resources for Python as an Absolute Beginner? You are at the perfect place. This Python for Beginners page revolves around Step by Step tutorial for learning Python Programming language from very basics 6 min read Differences Between Pyglet and Pygame in Python In this article, we will see the difference between Pygame and Pyglet gaming libraries. What is Pyglet? Pyglet is a cross-platform window and media library for Python, intended for developing games and other visually rich applications. It supports windows, UI event handling, gamepads, OpenGL graphic 4 min read PYGLET â Loading Plain Text Document In this article, we will see how we can load a plain text file in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia, etc. A window is a "heavyweight" object occupying operating system resources. Windows may appear 3 min read 6 Best Python Libraries For Fun Being one of the most popular languages in the entire world, Python has created a buzz around among developers over the past few years. This came into the limelight when the number of Python developers outnumbered Java back in 2020. Having easy syntax and easy to understand (just like English), it h 6 min read PYGLET â On Text Motion Event In this article we will see how we can trigger on text motion event in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a "heavyweight" object occupying operating system resources. Windows may ap 2 min read PYGLET â On Text Motion Select Event In this article, we will see how we can trigger on text motion select event in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia, etc. A window is a "heavyweight" object occupying operating system resources. Windo 2 min read PYGLET â Getting Window current Location In this article we will see how we can get the current location of window in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a "heavyweight" object occupying operating system resources. Windows 2 min read Like