newbie tkinter -- radio buttons
Cynthia Pettit
kiki at pixar.com
Sat Jun 19 23:59:40 EDT 1999
Okay, you get your choice of answering any single one of these questions
to solve my woes! :)
I'm making a color menu in a drawing program. It allows you to add
named colors as you go.
At first, I was adding colors this way:
self.color_menu.add_radiobutton(label=color_name,
value = color_name,
variable = self.current_color)
[Note: a couple other issues: value and variable don't seem to work.
When I choose the button, it does not change the value of
self.current_color.]
This works, but the problem is I can't set the first one to being
"selected", nor can I change the new color to be "selected"... it looks
really dorky to have no colors selected when you start and when you add
new colors. You have to *select* a color to start the radio buttons
working [after that, they're fine and switch properly among them.]
So I changed to this, so I could call the select() method:
temp = Radiobutton(self.color_menu, text=color_name,
value = color_name,
variable = self.current_color)
temp.pack(anchor=W)
temp.select()
But now, of course, this conflicts with other calls, like add_command
and add_separator. [eg "Add Color"] The buttons look to be on top of
eachother. I think this is due to the .pack() calls not working with
the add_radiobutton calls.
Here's a choice of things that if solved would save me [in order of
preference]:
Call .select() on an add_radiobutton [and just how *does* one ever
access these buttons ever again?!?!]
Integrate add_command and .pack() so they don't stomp on eachother
Be able to temp = Separator(self.color_menu)
I'm sure each of these have very simple answers...
Thanx!
Kiki
More information about the Python-list
mailing list