tkinter: loading file before entering mainloop

Peter Billam peter at
Sat Mar 14 11:26:02 CET 2009

On 2009-03-14, Peter Otten <__peter__ at> wrote:
> Well, I don't know where the ymid[...] values come from. If you can
> guarantee that ymid[track_num] - ymid[track_num-1] > 50 at some point
> you could reschedule loadFile() from within loadFile() and return
> immediately as long as that condition is not met.

They're multiplied up from
  canvas_height = self.canvas.winfo_height()
so I guess mainloop already think it's idle, while grid is still taking
10ms to work out what goes where. It's not a specifically canvas thing,
because to the left of the canvas there is a frame (called trackbar)
which has the same height, and self.trackbar.winfo_height() gives the
same effects.

Your suggestion would also defend me against small screens, or midi-
-files with large numbers of tracks (I'll impose a max_retries)...

Thanks,  Regards,  Peter

Peter Billam

More information about the Python-list mailing list