Python‎ > ‎tkinter‎ > ‎

tkinter.Frame


Definition
Frame widget can contain other widgets.

Syntax
tkinter.Frame()
Frame()

Options
Frame(background, bd, bg, borderwidth, class,  colormap, container, cursor, height, highlightbackground,
 highlightcolor, highlightthickness, relief, takefocus, visual, width.)

Methods
Examples
Created the frame in default setting.
 >>> from tkinter import*
>>> master=Tk()
>>> frame=Frame(master)
>>> frame.pack()
>>> help(Frame)





tkinter.Frame.grid
The frame is adjusted in grid().
 from tkinter import*

master=Tk()
master.geometry("400x300")

frame1=Frame(master, width=200, height=150, background="Blue")
frame1.grid(row=0, column=0)

frame2=Frame(master, width=200, height=150, background="Red")
frame2.grid(row=1, column=0)

frame3=Frame(master, width=200, height=150, background="Green")
frame3.grid(row=0, column=1)

frame4=Frame(master, width=200, height=150, background="Yellow")
frame4.grid(row=1, column=1)

master.mainloop()







Frame(width, height, color)
The Frame width, height, and background color is created.
from tkinter import*

master=Tk()

frame=Frame(master, width=300, height=300, background="blue")

frame.pack()

master.mainloop()






tkinter


Comments