When we use tkinter as a tool for writing our GUI, Frame is a widget that is often used. Unfortunately, the poor documentation doesn't show exactly what each style of Frame looks like, so that's why I write this article.
Here is some of the code that will be used (note: this is not the complete runnable code, just a small part)
1 2 3 4 5 6 7 8 9 10 11 from tkinter import *from tkinter.ttk import *window = Tk() frame_bot = Frame(window) frame_bot.pack(side=BOTTOM, fill=X, padx=8 , pady=6 ) frame_bot['borderwidth' ] = 2 frame_bot['relief' ] = 'flat' window.mainloop()
The code above is one way to write it, but it can actually be written like this:
1 2 3 4 5 6 7 8 9 10 from tkinter import *from tkinter.ttk import *window = Tk() frame_bot = Frame(window, relief=FLAT) frame_bot.pack(side=BOTTOM, fill=X, padx=8 , pady=6 ) frame_bot['borderwidth' ] = 2 window.mainloop()
That is, we initialize the parameters of relief when we create the Frame widget.
Or if we are using a different import method, we can use the following code.
1 frame_bot = Frame(window, relief=tkinter.FLAT)
Flat
1 frame_bot['relief'] = 'flat'
Groove
1 frame_bot['relief'] = 'groove'
Raised
1 frame_bot['relief'] = 'raised'
Ridge
1 frame_bot['relief'] = 'ridge'
Solid
1 frame_bot['relief'] = 'solid'
Sunken
1 frame_bot['relief'] = 'sunken'
Follow my Website: https://vincent-huang-2000.github.io/