From: Chris Hare on 1 Aug 2010 20:12 Here is the situation: I have a window with a bunch of widgets in it. I want to clear the objects in a given frame and recreate them to update them. The example below destroys the top level frame, and so I can't recreate the widgets. I am likely doing this wrong. should I be doing this in a class? Thanks for the help. from Tkinter import * def createLeftWidgets(left): # # Add the Net Status Section # conditions = LabelFrame(left, text="Net Conditions",bg="Gray") conditions.grid(row=0,column=0); button = Button(conditions, text="Refresh", command=refreshNetConditions, highlightbackground="Green") button.grid(row=0,column=1, sticky=E) cText = Text(conditions,bg="Gray") cText.insert(END, root.netHistory.get()) cText.config(height=12,width=40) cText.grid(row=1,column=0,columnspan=2) status = LabelFrame(left, text="Net Details",bg="Gray") status.grid(row=1,column=0,sticky=N+E+W+S); lblNetNumber = Label(status, text="Net Number") lblNetNumber.grid( row=19, column=0, columnspan=2,sticky=W) return(conditions) def refreshNetConditions(): global frameLeft frameLeft.destroy() root.netHistory.set( "inserting text\n" + root.netHistory.get()) createLeftWidgets(frameLeft) root = Tk() root.netHistory = StringVar() root.netHistory.set("goes into the text widget") frame = Frame(root) frame.grid() frameLeft = createLeftWidgets(frame) root.mainloop()
From: rantingrick on 1 Aug 2010 23:13 On Aug 1, 7:12 pm, Chris Hare <ch...(a)labr.net> wrote: > Here is the situation: > > I have a window with a bunch of widgets in it. I want to clear the objects in a given frame and recreate them to update them. You need to check out the "w.update" and "w.update_idletasks" methods available on all Tkinter widgets. Just FYI: to remove a widget from view without destroying it use "w.pack_forget" or "w.grid_forget". However if you are simply trying to refresh a widget use one of the update methods.
From: Chris Hare on 2 Aug 2010 16:17 On Aug 1, 2010, at 10:13 PM, rantingrick wrote: > On Aug 1, 7:12 pm, Chris Hare <ch...(a)labr.net> wrote: >> Here is the situation: >> >> I have a window with a bunch of widgets in it. I want to clear the objects in a given frame and recreate them to update them. > > You need to check out the "w.update" and "w.update_idletasks" methods > available on all Tkinter widgets. Just FYI: to remove a widget from > view without destroying it use "w.pack_forget" or "w.grid_forget". > However if you are simply trying to refresh a widget use one of the > update methods. > -- > http://mail.python.org/mailman/listinfo/python-list I will have a look at those. Consider a frame with a label and a button. How do I address the label to change it from another function in the class?
From: Mark Lawrence on 2 Aug 2010 17:52 On 02/08/2010 04:13, rantingrick wrote: > On Aug 1, 7:12 pm, Chris Hare<ch...(a)labr.net> wrote: >> Here is the situation: >> >> I have a window with a bunch of widgets in it. I want to clear the objects in a given frame and recreate them to update them. > > You need to check out the "w.update" and "w.update_idletasks" methods > available on all Tkinter widgets. Just FYI: to remove a widget from > view without destroying it use "w.pack_forget" or "w.grid_forget". > However if you are simply trying to refresh a widget use one of the > update methods. I don't understand the technical content of this thread, but I'm very pleased to see rantingrick being positive, well done!!! :) I know that we've crossed swords in the past but believe that bygones should be bygones. Can we call it quits and help to take Python forward? Kindest regards. Mark Lawrence.
|
Pages: 1 Prev: Why is python not written in C++ ? Next: timeit function |