pygame_display /

Filename Size Date modified Message
examples
1.1 KB
2.8 KB
15.6 KB
765 B
833 B

pygame_display is an implementation of the urwid display system for PyGame, making urwid usable on non-Unix OSes.

Features:

  • Windows support
  • Keyboard and mouse support, including "mouse drag"
  • 8-bit color palettes (pygame could do 24-bit color palettes, but Urwid lacks the API for this!)
  • Customizable window titles and starting resolution

Getting Started

If you do not know how to use Urwid, please consult the Urwid documentation before you try to use pygame_display.

If you do, the only difference between using pygame_display and another display for running urwid-based applications is that you specify your screen to be pygame_display.Screen() instead of the default screen (raw_display.Screen()). For concrete examples, a couple of the Urwid tutorial programs were modified in this way and can be seen in the examples/ subdirectory.

Wince urwid runs on pygame, it is additionally possible to run urwid inside a pygame application, and embed an urwid console inside your game. So far this is a bit painful, but see examples/pygame_integration.py for an example of how to do it. For an example of how to use pygame_display only when on Windows, and raw_display otherwise, see examples/cross_platform.py.

Please keep in mind that this module is new, and written by a non-Urwid-user. I'm sure that bugs are present, some of them even due to misunderstandings of how urwid is meant to work. I welcome any helpful advice and bug reports.

Using pygame_display on Microsoft Windows

As mentioned before, Urwid+pygame_display can run on Windows, but only if you comment out the imports for the modules pty, termios, and fnctl. A fork of urwid that works on Unix as well as Windows is available at this address:

https://bitbucket.org/devin.jeanpierre/urwid/

Since the required changes are very small, hopefully this or a more structured change will make its way into Urwid's main repository, so that Windows support exists out of the box.

So does this mean I can use existing Urwid apps on Windows?

Since pygame_display is not the default screen (the Unix-only raw_display is), apps will not work on Windows without slight modifications. However, as proof-of-concept the (minimum) necessary modifications have been made to the popular urwid-using application bpython and pudb.

Contacting the author

I will pay close attention to bug reports filed on bitbucket. I am also available on IRC, via the nickname "ssbr". You can find me on Freenode's #python and OFTC's #urwid.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.