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

Re: [pygame] Testing for button in a table in OcempGUI



On, Thu Dec 29, 2005, Johan Geldenhuys wrote:

> Hi all,
> 
> I have a Table(15, 15).
> In this table I put specific buttons at random positions and at the rest 
> of the positions I want to put random letters.
> 
> The way I do it now is to put my specific buttons in first and then the 
> random ones.
> The problem is that when I get to a position in the table where a 
> specific buttons is in, my script stop: "Exception: Cell (7, 13) already 
> occupied". I understand this, but how do I test for a position in a 
> table and go on to the next available position? Is there a 

try:
    ...
except ...:
    ...

may help.

> 'table.have_child()' or something else I can test it with?

The table.grid is a dict, that contains key-value pairs of the children
as explained in the docs.

Regards
Marcus

Attachment: pgpa6IJPBhnoU.pgp
Description: PGP signature