Tkinter Frame relief attribute additional support
In the standard Frame framework, for relief properties are not fully supported, for example, solid and sunken properties, at this time you can use tkinter.ttk Frame and Style module. The following will be directly explained by example.
Tkinter Frame relief attribute additional support Example#1
Create 6 frames, each with a different RELIEF.
from tkinter import Tk
from tkinter.ttk import Frame, Style
root = Tk()
root.title("apidemos.com")
style = Style() # Change to Style
style.theme_use("alt") # Change to alt support Style
fm1 = Frame(root,width=150,height=80,relief="flat")
fm1.grid(row=0,column=0,padx=5,pady=5)
fm2 = Frame(root,width=150,height=80,relief="groove")
fm2.grid(row=0,column=1,padx=5,pady=5)
fm3 = Frame(root,width=150,height=80,relief="raised")
fm3.grid(row=0,column=2,padx=5,pady=5)
fm4 = Frame(root,width=150,height=80,relief="ridge")
fm4.grid(row=1,column=0,padx=5,pady=5)
fm5 = Frame(root,width=150,height=80,relief="solid")
fm5.grid(row=1,column=1,padx=5,pady=5)
fm6 = Frame(root,width=150,height=80,relief="sunken")
fm6.grid(row=1,column=2,padx=5,pady=5)
root.mainloop()
Output:
The above program requires the use of tkinter.ttk module Frame as support to properly display the outer frame of the relief, and note that the alt parameter in line 7 is mainly a parameter for relief support within this mechanism.