In general, you'll want to handle the drawing yourself.

Minesweeper might make sense using a bunch of widgets and just changing the
graphic of the wxBitmapButton or wxStaticBitmap as the user clicks on the
widgets, but that is because the play field is small. You'll probably want
to maintain the underlying data of in a list of lists or dictionary.

Using individual widgets for each cell won't scale for something like life
and it restricts the scaling options. There you need to manage the drawing
yourself. Again, you need to maintain the underlying data in a separate data
structure. It turns out that using a dictionary is an elegant way to handle
an unlimited life universe size and the overhead of calculating each new
generation is dependent on the total number of live cells rather than the
universe size.

The calculations necessary to translate between mouse coordinates and your
screen grid so the user can easily toggle a cell are pretty simple. Just
take the x and y position and divide by the scale you're using for drawing;
you obviously don't need the scale if it is 1 to 1.

Anyway, if you want to see one way of doing all this, just look at the
PythonCard life sample.

  http://pythoncard.sourceforge.net/samples/life.html

For more specific questions on game logic and drawing you might want to
check out PyGame and the PyGame mailing list.

  http://www.pygame.org/

ka

> -----Original Message-----
> From: Antoon Pardon [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 05, 2003 1:35 AM
> To: python gtk rondzendlijst; python wx rondzendlijst
> Subject: [wxPython-users] A lot of widgets or only one
>
>
>
> Well I'm still experimenting both with pygtk as well as with wxpython.
>
> The following question I have about programming with a gui toolkit
> however is independant of the toolkit used, so I put it to both
> lists.
>
> The next thing I would like to try is a program like life, mine sweeper,
> or griddler (aka nonogramm or paint by number). Basically this kind
> of program requires a table all with similar data. However this table
> could become quite large so I am a bit hesistant in implementing this
> as a gtk_table/GridSizer, filled with thousands of widgets.
>
> An alternative would be to have just one widget in which I draw al
> elements as they should be, but this would be a little harder to
> code.
>
> So what are your ideas? Shouldn't I worry about having thousand
> of widgets? Is there some kind of limit I should stay under?
> Is there an other approach I didn''t think of.
>
> --
> Antoon Pardon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to