[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Layout module for Pygame surfaces



Hi!

Some months ago I developed an application that uses Pygame as main media lbrary. One of the problems I saw when I was developing is to structure the layout of the screen, because sometimes you want to make some layout to organize on a best way that screen.

Here is some example: http://sumergiendose.files.wordpress.com/2009/12/layout.png

You have a board, a frame with buttons, other with the names... The position of those elements use to be on code, so it's hard to has some representations. So I develop a module that store and manage that information on a XML file. This way, is possible to has a lot of representations without touching the code. An example of this XML could be:

<label name="exit_button" type="button">
      <propierty name="exit_button_size" type="size">
        <value id="weight">50</value>
        <value id="height">50</value>
      </propierty>
      <propierty name="exit_button_position" type="position">
        <value id="x">650</value>
        <value id="y">500</value>
      </propierty>
      <propierty name="exit_button_images" type="button_images">
        <value id="default">./images/salir.png</value>
        <value id="above">./images/salir_sobre.png</value>
        <value id="pressed">./images/salir_pulsada.png</value>
      </propierty>   
  </label>

Is possible to group elements of this kind on a father element, to abstract them of the position of the screen. The module provides functions to update the environment in some kind signals, draw all the surface with a single function and more.

I want to know if his project could be useful at a general level, to make a library with this feature and share with the community.

Thanks!

--
Pablo Recio Quijano

Estudiante de Ingeniería Informática (UCA)
Alumno colaborador del Departamento de Lenguajes y Sistemas Informáticos