Tkinter Python 框架集件组被用于组织的微件。它像一个容器 , 该容器可以用来保持其他部件。该矩形区域的屏幕的小部件以用于组织的 Python 应用。
语法框架控件的使用如下。
语法
w = Frame(parent, options)
可能选项的列表如下。
| SN |
选项 |
描述 |
| 1 | bd | 它表示边框宽度 |
| 2 | bg |
小部件的背景颜色 |
| 3 | cursor |
鼠标指针被更改为光标类型,设置为不同的值,如箭头、圆点等 |
| 4 | height |
框架的高度 |
| 5 | highlightbackground |
对焦时背景颜色的颜色 |
| 6 | highlightcolor |
小部件处于焦点时的文本颜色 |
| 7 | highlightthickness |
当小部件位于焦点下时,它指定边框周围的厚度 |
| 8 | relief |
它指定边框的类型。默认值FLAT |
| 9 | width |
它表示小部件的宽度 |
实例
from tkinter import *
top = Tk()
top.geometry("140x100")
frame = Frame(top)
frame.pack()
leftframe = Frame(top)
leftframe.pack(side = LEFT)
rightframe = Frame(top)
rightframe.pack(side = RIGHT)
btn1 = Button(frame, text="Submit", fg="red",activebackground = "red")
btn1.pack(side = LEFT)
btn2 = Button(frame, text="Remove", fg="brown", activebackground = "brown")
btn2.pack(side = RIGHT)
btn3 = Button(rightframe, text="Add", fg="blue", activebackground = "blue")
btn3.pack(side = LEFT)
btn4 = Button(leftframe, text="Modify", fg="black", activebackground = "white")
btn4.pack(side = RIGHT)
top.mainloop()
输出 :

第1章 Python简介
