Frame is a very important . It is just like a container and frame is used to manage the layout of “tkinter” Application, which is a rectangular container
Syntax-
w = Frame ( main, option)
Parameter-
Main- parent Window.
Option- attribute of button widget.
Example-
- from tkinter import *
- main = Tk()
- frame = Frame(main)
- frame.pack()
- bttframe = Frame(main)
- bttframe.pack( side = BOTTOM )
- button = Button(frame, text="c# corner", fg="blue")
- button.pack( side = LEFT)
- button1 = Button(frame, text="python", fg="red")
- button1.pack( side = LEFT )
Output-
Option | Description |
bg | Normal background color. |
bd | It sets border width in pixels. Default is 2. |
cursor | Cursor is used to create a cursor in canvas like arrow, circle, dot etc. |
height | It is used to set the height of widgets. |
highlightbackground
| It changes background color of widgets on focus.
|
highlightcolor
| It changes the color of widgets on focus.
|
highlightthickness | It is used to set thickness of the focus highlight.
|
relief | Relief is special type of border. The values are SUNKEN, RAISED, GROOVE, and RIDGE.
|
width
| It is used to set the width of widgets. |
Summary
In this chapter, you learnt what frame widget is and how to use the property of the widget.