WebMasterMsk Wiki

метод pack ()

метод pack ()

Этот менеджер геометрии организует виджеты в блоки перед размещением их в родительском виджете.

Синтаксис:

widget.pack( pack_options )

Вот список возможных вариантов -

Пример:

from tkinter import *

root = Tk()
frame = Frame(root)
frame.pack()

bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )

redbutton = Button(frame, text = "Red", fg = "red")
redbutton.pack( side = LEFT)

greenbutton = Button(frame, text = "Brown", fg = "brown")
greenbutton.pack( side = LEFT )

bluebutton = Button(frame, text = "Blue", fg = "blue")
bluebutton.pack( side = LEFT )

blackbutton = Button(bottomframe, text = "Black", fg = "black")
blackbutton.pack( side = BOTTOM)

root.mainloop()

Когда приведенный выше код выполняется, он дает следующий результат -