Matt said:
I don't quite understand (if I'm interpreting you correctly) why you
want separate widgets, all displayed at once, for several hundred
records - surely better to just reuse the one set of widgets and have
the scrollbar or back-forward buttons change which record is being
displayed in the widgets.
I need to re-think things a little. I wanted to be able to quickly
scroll through several hundred entries in the db, and check off (yes/no)
which have been reviewed, updated, or whatever.
I will look at having a fixed number of display widgets and scrolling
through the underlying data to determine which records are currently
displayed/editable.
My first pass was db -> display/edit widgets -> db. So I jumped
(incorrectly) to wanting to 'hold' all record in widgets for
editing.There's no reason I can't use:
db -> master list -> slice -> display/edit widgets -> master list -> db.
i.e. a list holding all the data, display/edit slices controlled by a
scrollbar, and storing the final list when done.
If you're after replacing widgets, then you need to destroy them first.
Use the self.destroy method and unset/change any variables referencing
the widget so it get a chance to be garbage collected.
However, if you want a scrollable view onto a larger area, what you
need to do is use a Canvas, with a window shape on it. You then put a
frame into that window.
canvas = Tkinter.Canvas( <parent> )
canvas.grid( ... )
winID = self.canvas.create_window(0,0, anchor=Tkinter.NW)
Then later you can add a frame to that window on the canvas:
canvas.itemconfigure( winID, window = <my frame> )
canvas['scrollregion'] = canvas.bbox('all')
Make sure you've created the frame and perhaps called
update_idletasks() to give it a chance to size itself before shoving it
onto the canvas.
And of course, the scrollbar!
yscroll = Tkinter.Scrollbar( <parent>, orient=Tkinter.VERTICAL)
yscroll.grid( ... )
yscroll['command'] = canvas.yview
canvas['yscrollcommand'] = yscroll.set
Probably, not needed now that I have re-thought the situation, but I do
have several occasions where i need to view and select/deselect 50 or 60
options (checkbuttons). So this will make them much more manageable.
Thanks,
Bill