RE: Tkinter - changing existing Dialog?

2006-06-02 Thread Michael Yanowitz
Thanks.

  That is what I was looking for. The configure command (as you and John
pointed out),
should do what I need. The first response of starting a new thread was not
what I was
looking for.

Michael Yanowitz


-Original Message-

In article [EMAIL PROTECTED],
Michael Yanowitz [EMAIL PROTECTED] wrote:
Hello:


   I have a Tkinter GUI Dialog with many buttons and labels and text
widgets.
What I would like to do is, can I:

1) Disable/deactivate/hide a button, text widget that is already drawn (and
   of course the opposite enable/activate/show it)?
.
.
.
  import Tkinter

  root = Tkinter.Tk()

  def actions():
  print Someone pushed the button.
  b.configure(state = Tkinter.DISABLED)

  b = Tkinter.Button(root, text = Push me, command = actions)
  b.pack()
  root.mainloop()


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - changing existing Dialog?

2006-06-01 Thread John Machin

Michael Yanowitz wrote:
 Hello:


I have a Tkinter GUI Dialog with many buttons and labels and text
 widgets.


So start a *new* thread.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - changing existing Dialog?

2006-06-01 Thread John McMonagle
On Thu, 2006-06-01 at 08:31 -0400, Michael Yanowitz wrote:
 Hello:
 
 
I have a Tkinter GUI Dialog with many buttons and labels and text
 widgets.
 What I would like to do is, can I:
 
 1) Disable/deactivate/hide a button, text widget that is already drawn (and
of course the opposite enable/activate/show it)?
 
 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?
 
   Sorry for what probably is such a trivial and basic question. I just can't
 find the answer or know what the technical term for what I want to do is to
 search for it myself.

To disable/deactivate a button widget, use the keyword 'state'.  For
example, 


import Tkinter as Tk
root = Tk.Tk()
bid = Tk.Button(root, text='test', state=Tk.NORMAL)
bid.pack()
bid.configure(state=Tk.DISABLED)

If you want to hide the button (using Pack geometry manager):

bid.pack_forget()

You can pack it again using bid.pack() but it may be difficult to pack
it back where you originally intended.

If you are using the Grid geometry manager:

bid.grid_forget()

To put it back simply call grid again with the same row, column.



Changing the text of a label or button already drawn is simply done by a
call to the configure method on the button or label's text attribute:

bid.configure(text='Help')

Regards,

John







-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - changing existing Dialog?

2006-06-01 Thread Cameron Laird
In article [EMAIL PROTECTED],
Michael Yanowitz [EMAIL PROTECTED] wrote:
Hello:


   I have a Tkinter GUI Dialog with many buttons and labels and text
widgets.
What I would like to do is, can I:

1) Disable/deactivate/hide a button, text widget that is already drawn (and
   of course the opposite enable/activate/show it)?
.
.
.
  import Tkinter

  root = Tkinter.Tk()

  def actions():
  print Someone pushed the button.
  b.configure(state = Tkinter.DISABLED)

  b = Tkinter.Button(root, text = Push me, command = actions)
  b.pack()
  root.mainloop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - changing existing Dialog?

2006-06-01 Thread Cameron Laird
In article [EMAIL PROTECTED],
Michael Yanowitz [EMAIL PROTECTED] 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()

-- 
http://mail.python.org/mailman/listinfo/python-list