Python Forum
[Tkinter] changing the frame colour
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] changing the frame colour
#2
Hi nick123

Now it should work:
import tkinter as tk
 
root = tk.Tk()
root.geometry("100x100")
frame = tk.Frame(root, height=100, width=100)
 
 
def change_bg():
    frame.config(background='red')
     
 
button = tk.Button(frame, text="Paint",command=change_bg)
 
 
button.pack()
frame.pack(fill='both', expand=True)
root.mainloop()
wuf :-)
Reply


Messages In This Thread
changing the frame colour - by nick123 - Apr-25-2019, 02:13 PM
RE: changing the frame colour - by wuf - Apr-25-2019, 04:35 PM
RE: changing the frame colour - by nick123 - May-14-2019, 02:48 PM
RE: changing the frame colour - by LegacyCoding - Jul-24-2020, 02:30 AM
RE: changing the frame colour - by LegacyCoding - Jul-24-2020, 07:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't change the colour of Tk button text Pilover 6 15,333 Nov-15-2022, 10:11 PM
Last Post: woooee
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,371 Sep-30-2021, 05:57 PM
Last Post: menator01
  Making a colour field Leo_Red 11 5,219 Jan-22-2021, 04:15 PM
Last Post: BashBedlam
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 6,149 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  Why is wx.NO_BORDER changing panels within a frame MeghansUncle2 4 2,649 Jul-12-2020, 12:32 PM
Last Post: Yoriz
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 9,226 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 11,453 Apr-18-2019, 05:36 PM
Last Post: atlass218
  [Tkinter] Frame size only works if frame is empty(Solved) Tuck12173 7 6,677 Jan-29-2018, 10:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020