[Tutor] Updating windows

Suzanne Little s349929@student.uq.edu.au
Wed, 5 Jan 2000 14:50:44 +1000 (GMT+1000)


Hello, 

I'm currently a bit confused about how to update windows. I've had a look
at the update and update_idletasks methods but they seem to be doing some
funny things.

Firstly I have a main window with a listbox which contains elements from a
list. I delete/add etc to this list and want the listbox to reflect the
changes. I have a function defined in the main window's class, updateList,
    self.listbox.delete(0, END)
    for i in names:
	self.listbox.insert(END, i)
    self.update_idletasks()
which removes all the members of the listbox and adds the ones now
contained in the list. The other class, which does the adding and removing
calls this method to refresh the listbox after stuff has been done. Now we
come to the bit I can't figure out. If I run this by entering 
    %python main.py (I'm in Unix btw) 
and try to perform functions, the functions work but the listbox isn't
updated at all but if I start up python, %python, and then enter 
    >>> from main import *
    >>> s = MainGUI()
and then use the GUI as normal it updates perfectly. 

The second update question I have is how do I get a child window to reflect
changes that have taken place in a its parent? I have the main window and
when an item from the listbox is selected, a button can be clicked
which will then bring up a window containing details about the item which
was selected. I can get this to work ok but I want the details window to
be updated when the item's attributes change. I don't really mind
how. Ideally it should happen automatically but since I really had no idea
how to do this I've added a button to the details window, Update, which I
hoped I could click to refresh the information contained there. The
function that I called just said self.update() and I'm not really sure
what else to try.

If anyone has some ideas why the first update only happens when I run the
program through command prompt and any ideas for how to set about doing
the second refresh, that would be great. Also any references about how
updating works.

TIA, 
Suzanne  

-----------------------------------------------------------------------
"Contrariwise," continued Tweedledee, "If it was so, it might be; and if
it were so, it would be; but as it isn't, it ain't.  That's logic"
                             -Lewis Carroll
------------------------------------------------------------------------