Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to add a GUI to a Pygame application?

Are there any good GUIs that support Pygame surfaces as a widget within the application?

If this isn't possible or practical, what GUI toolkit has the best graphics component? I'm looking to keep the speedy rendering made possible by a SDL wrapper.

like image 913
Bibendum Avatar asked Jan 26 '10 21:01

Bibendum


People also ask

Can you make a GUI with pygame?

Pygame GUI is a module to help you make graphical user interfaces for games written in pygame. The module is firmly forward looking and is designed to work on Pygame 2 and Python 3.

Can you use tkinter and pygame together?

PYGAME and TKINTER in HARMONY. Despite what is said on some forums, Tkinter, the middle weight python GUI, works quite well in conjunction with pygame, the python SDL layer - at least when pygame is not in full screen mode. Pygame has been used as the graphics/media engine for many serious application (eg.

Is tkinter better than pygame?

First, tkinter is definitely not the best GUI toolkit for python. It's one of the simplest and usually comes with the python interpreter. But it's not as powerful as Qt, wx or Gtk. pygame is - as it's name states - a package designed to allow to create games in python very easily, not to create GUIs.


2 Answers

Dont use wxPython, its very hard to get to work well with Pygame, as described over at the GUI section of the Pygame wiki.

First of all, pygame relies on the SDL, which means that it can only have one window at a time. Thus, trying to implement multiple Gtk, Qt, ... application instances that use pygame, is an impossibility. The second problematic reason is that those toolkits use their own main loop, which possibly forces you to pipe their events to your pygame instance and vice versa. And to mention some other points in short: Drawing the toolkit elements on the pygame window is impossible and the SDL/pygame fullscreen mode will be problematic.

Instead, opt for any of the libraries listed at the bottom of that page. I use pgu myself.

like image 103
Mizipzor Avatar answered Oct 04 '22 12:10

Mizipzor


Take a look at Albow, PGU or Ocemp.

like image 38
Brandon Avatar answered Oct 04 '22 11:10

Brandon