[pygtk] A design question

Gary Jaffe gfj555 at gmail.com
Tue Jan 3 01:06:28 WST 2006


A.T.Hofkamp wrote:
> Hello,
> 
> Gary Jaffe wrote:
> 
>> I wrote a pygtk application that displays ascii letters and spaces 
>> arranged as 70 columns by 20 rows.  Each letter and its background 
>> color represents a potential appointment spot in a doctor's office.  
>> The user can click on any of the letters to either make or view an 
>> appointment. This is working, but is too slow.  It takes about a 
>> second to redraw the letters, even when using pyrex or psyco.
> 
> 
> Do you redraw everything each time, or do you use rectangles to mark 
> which parts should be redrawn?

When an appointment is made, I just modify that one letter.  There is no 
speed problem there.  But when the week or the doctor is changed, I need 
to redraw the entire 70 * 20 array.  That's when it takes about a second 
to redraw.

> 
>> I implemented this by using an EventBox() for each letter (to catch 
>> the clicks) and then added a label to each EventBox() to display the 
>> letter with its background color.  I'm considering using a TextView() 
>> instead to display the letters and managing the letters with pango.
>>
>> Is this likely to be faster, or is there some other way of 
>> implementing this that would be faster?
> 
> 
> Would a single large bitmap with the letters be faster?
> (a simple test would be to create an arbitrary bitmap with the right 
> size, and see how fast that is blitted to the screen).
> 
> Another option may be to have a set of bitmaps (one for each letter for 
> example), and a canvas on which you blit the right bitmap at the right 
> place.
> This may have no effect, depending on what pango does with caching.
> 

These are good suggestions, thanks.  I'll try a few of them and probably 
settle on the first one that has resonable speed.  :)

> Albert
> 



More information about the pygtk mailing list