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

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



Marcus,
I tried this
"""
try:
for i in range(tbl_words.rows):
for j in range(tbl_words.columns):
letter = self.letters()
button = Button(letter)
button.border = BORDER_NONE
button.padding = 0
button.connect_signal(SIG_CLICKED, self.clicked, button, i, j, letter)
tbl_words.add_child(i, j, button)
self.button_list(i, j, letter)
except:
pass
"""
I am not sure what to put in at the except part. With the above, it stops as soon as it gets to the first position that is already occupied. Any ideas what to use there?


I will look at the docs.
Johan

Marcus von Appen wrote:

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