Here I am trying to create a very simple function to change a Frame background color as by a btn event handling as following:
from Tkinter import * class App: def __init__(self, parent): self.myParent = parent self.fm = Frame(parent) self.fm.pack() self.btnBlue = Button(self.fm, text = "Blue") self.btnBlue.bind("<Button-1>", self.make_blue) self.btnBlue.pack() def make_blue(self, event): self.fm = Frame(self.fm, bg="blue").pack() root = Tk() root.title ("Color Option") app = App(root) root.mainloop()
as you can see I have a button which is suppose to change the Frame's back ground color to BLUE but every time that I click on the button it just create a vertical thin line at bottom of the button and if you continue clicking it increase!
Can you please take a look at this code and let me know what I am doing wrong?
Edited 5 Years Ago by Behseini: n/a