Tkinter - changing existing Dialog?

Cameron Laird claird at lairds.us
Fri Jun 2 03:03:22 CEST 2006


In article <mailman.6401.1149165099.27775.python-list at python.org>,
Michael Yanowitz <m.yanowitz at kearfott.com> wrote:
			.
			.
			.
>2) Change the text of a label or button that is already drawn?
>
>  based on actions taken by the user. Can it be done without destroying
>the present dialog or the objects in it and creating a new one?
			.
			.
			.
  import Tkinter

  root = Tkinter.Tk()

  counter = 0

      # This is one of several ways one can access the Button's label.
  def set_text():
      b.configure(text = "The button has been pushed %d time(s)." % counter)

  def actions():
      global counter
      counter += 1
      set_text()

  b = Tkinter.Button(root, command = actions)
  set_text()
  b.pack()
  root.mainloop()




More information about the Python-list mailing list