📜  Python Tkinter框架

📅  最后修改于: 2020-10-27 01:49:58             🧑  作者: Mango

Python Tkinter框架

Python Tkinter Frame小部件用于组织小部件组。它就像一个容器,可以用来容纳其他小部件。屏幕的矩形区域用于将小部件组织到Python应用程序。

下面给出了使用框架小部件的语法。

句法

w = Frame(parent,  options)

下面列出了可能的选项。

SN Option Description
1 bd It represents the border width.
2 bg The background color of the widget.
3 cursor The mouse pointer is changed to the cursor type set to different values like an arrow, dot, etc.
4 height The height of the frame.
5 highlightbackground The color of the background color when it is under focus.
6 highlightcolor The text color when the widget is under focus.
7 highlightthickness It specifies the thickness around the border when the widget is under the focus.
8 relief It specifies the type of the border. The default value if FLAT.
9 width It represents the width of the widget.

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()

输出: