Hi
I am running a simple application which has three Radio Button and I have two problem with that as following:
1- First of all, two of the radio buttons [R2(Blue) and R3(Green)] are automatically selected when I run the code!(As you can see in attached screen shot). I tried to use a method like this:
self.R2.deselect()
self.R3.deselect()
but they didn't change any thing.
2- The second problem is the size of my second frame(here fm).How I can dock the fm frame to expand all of parent frame?if you take a look at the second attachment you will see when ever I click on the radio button it just change the fm bg color as:
self.fm.configure(bg="BLUE")
an this just make changes on the portion of the radio buttons not all main frame.is this because i am using the grid layout management?If so? How can I solve it?
Here is my code:
from Tkinter import *
class App:
def __init__(self, parent):
self.myParent = parent
self.fm = Frame(parent, width=400, height=300)
self.fm.pack_propagate(0) # to keep the frame size
self.fm.pack()
self.R1 = Radiobutton(self.fm, text="Red", value=1, command=self.make_Red)
self.R1.grid(row =2 , column = 1)
self.R2 = Radiobutton(self.fm, text="Blue", value=2, command=self.make_Blue)
self.R2.grid(row =2 , column = 2)
self.R3 = Radiobutton(self.fm, text="Green", value=3, command=self.make_Green)
self.R3.grid(row =2 , column = 3)
def make_Red(self):
self.fm.configure(bg="RED")
self.R1.configure(bg="RED")
self.R2.configure(bg="RED")
self.R3.configure(bg="RED")
def make_Blue(self):
self.fm.configure(bg="BLUE")
self.R1.configure(bg="BLUE")
self.R2.configure(bg="BLUE")
self.R3.configure(bg="BLUE")
def make_Green(self):
self.fm.configure(bg="GREEN")
self.R1.configure(bg="GREEN")
self.R2.configure(bg="GREEN")
self.R3.configure(bg="GREEN")
root = Tk()
root.title ("Color Option")
app = App(root)
root.mainloop()